Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/netwerk/base/nsSimpleNestedURI.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
/**
7
 * URI class to be used for cases when a simple URI actually resolves to some
8
 * other sort of URI, with the latter being what's loaded when the load
9
 * happens.
10
 */
11
12
#ifndef nsSimpleNestedURI_h__
13
#define nsSimpleNestedURI_h__
14
15
#include "nsCOMPtr.h"
16
#include "nsSimpleURI.h"
17
#include "nsINestedURI.h"
18
#include "nsIURIMutator.h"
19
20
#include "nsIIPCSerializableURI.h"
21
22
namespace mozilla {
23
namespace net {
24
25
class nsSimpleNestedURI : public nsSimpleURI,
26
                          public nsINestedURI
27
{
28
protected:
29
0
    nsSimpleNestedURI() = default;
30
    explicit nsSimpleNestedURI(nsIURI* innerURI);
31
32
0
    ~nsSimpleNestedURI() = default;
33
public:
34
    NS_DECL_ISUPPORTS_INHERITED
35
    NS_DECL_NSINESTEDURI
36
37
    // Overrides for various methods nsSimpleURI implements follow.
38
39
    // nsSimpleURI overrides
40
    virtual nsresult EqualsInternal(nsIURI* other,
41
                                    RefHandlingEnum refHandlingMode,
42
                                    bool* result) override;
43
    virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
44
                                    const nsACString& newRef) override;
45
    NS_IMETHOD Mutate(nsIURIMutator * *_retval) override;
46
47
    // nsISerializable overrides
48
    NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
49
    NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
50
51
    // nsIIPCSerializableURI overrides
52
    NS_DECL_NSIIPCSERIALIZABLEURI
53
54
    // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
55
    // nsISerializable impl works right.
56
    NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) override;
57
58
protected:
59
    nsCOMPtr<nsIURI> mInnerURI;
60
61
    nsresult SetPathQueryRef(const nsACString &aPathQueryRef) override;
62
    nsresult SetQuery(const nsACString &aQuery) override;
63
    nsresult SetRef(const nsACString &aRef) override;
64
    bool Deserialize(const mozilla::ipc::URIParams&);
65
    nsresult ReadPrivate(nsIObjectInputStream *stream);
66
67
public:
68
    class Mutator final
69
        : public nsIURIMutator
70
        , public BaseURIMutator<nsSimpleNestedURI>
71
        , public nsISerializable
72
        , public nsINestedURIMutator
73
    {
74
        NS_DECL_ISUPPORTS
75
        NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
76
77
0
        explicit Mutator() = default;
78
    private:
79
0
        virtual ~Mutator() = default;
80
81
        MOZ_MUST_USE NS_IMETHOD
82
        Deserialize(const mozilla::ipc::URIParams& aParams) override
83
0
        {
84
0
            return InitFromIPCParams(aParams);
85
0
        }
86
87
        NS_IMETHOD
88
        Write(nsIObjectOutputStream *aOutputStream) override
89
0
        {
90
0
            return NS_ERROR_NOT_IMPLEMENTED;
91
0
        }
92
93
        MOZ_MUST_USE NS_IMETHOD
94
        Read(nsIObjectInputStream* aStream) override
95
0
        {
96
0
            return InitFromInputStream(aStream);
97
0
        }
98
99
        MOZ_MUST_USE NS_IMETHOD
100
        Finalize(nsIURI** aURI) override
101
0
        {
102
0
            mURI.forget(aURI);
103
0
            return NS_OK;
104
0
        }
105
106
        MOZ_MUST_USE NS_IMETHOD
107
        SetSpec(const nsACString& aSpec, nsIURIMutator** aMutator) override
108
0
        {
109
0
            if (aMutator) {
110
0
                NS_ADDREF(*aMutator = this);
111
0
            }
112
0
            return InitFromSpec(aSpec);
113
0
        }
114
115
        MOZ_MUST_USE NS_IMETHOD
116
        Init(nsIURI* innerURI) override
117
0
        {
118
0
            mURI = new nsSimpleNestedURI(innerURI);
119
0
            return NS_OK;
120
0
        }
121
122
        friend class nsSimpleNestedURI;
123
    };
124
125
    friend BaseURIMutator<nsSimpleNestedURI>;
126
};
127
128
} // namespace net
129
} // namespace mozilla
130
131
#endif /* nsSimpleNestedURI_h__ */