Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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
namespace mozilla {
21
namespace net {
22
23
class nsSimpleNestedURI : public nsSimpleURI, public nsINestedURI {
24
protected:
25
nsSimpleNestedURI() = default;
26
explicit nsSimpleNestedURI(nsIURI* innerURI);
27
28
~nsSimpleNestedURI() = default;
29
30
public:
31
NS_DECL_ISUPPORTS_INHERITED
32
NS_DECL_NSINESTEDURI
33
34
// Overrides for various methods nsSimpleURI implements follow.
35
36
// nsSimpleURI overrides
37
virtual nsresult EqualsInternal(nsIURI* other,
38
RefHandlingEnum refHandlingMode,
39
bool* result) override;
40
virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode,
41
const nsACString& newRef) override;
42
NS_IMETHOD Mutate(nsIURIMutator** _retval) override;
43
NS_IMETHOD_(void) Serialize(ipc::URIParams& aParams) override;
44
45
// nsISerializable overrides
46
NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
47
NS_IMETHOD Write(nsIObjectOutputStream* aStream) override;
48
49
// Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
50
// nsISerializable impl works right.
51
NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) override;
52
53
protected:
54
nsCOMPtr<nsIURI> mInnerURI;
55
56
nsresult SetPathQueryRef(const nsACString& aPathQueryRef) override;
57
nsresult SetQuery(const nsACString& aQuery) override;
58
nsresult SetRef(const nsACString& aRef) override;
59
bool Deserialize(const mozilla::ipc::URIParams&);
60
nsresult ReadPrivate(nsIObjectInputStream* stream);
61
62
public:
63
class Mutator final : public nsIURIMutator,
64
public BaseURIMutator<nsSimpleNestedURI>,
65
public nsISerializable,
66
public nsINestedURIMutator {
67
NS_DECL_ISUPPORTS
68
NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
69
70
explicit Mutator() = default;
71
72
private:
73
virtual ~Mutator() = default;
74
75
MOZ_MUST_USE NS_IMETHOD
76
Deserialize(const mozilla::ipc::URIParams& aParams) override {
77
return InitFromIPCParams(aParams);
78
}
79
80
NS_IMETHOD
81
Write(nsIObjectOutputStream* aOutputStream) override {
82
return NS_ERROR_NOT_IMPLEMENTED;
83
}
84
85
MOZ_MUST_USE NS_IMETHOD Read(nsIObjectInputStream* aStream) override {
86
return InitFromInputStream(aStream);
87
}
88
89
MOZ_MUST_USE NS_IMETHOD Finalize(nsIURI** aURI) override {
90
mURI.forget(aURI);
91
return NS_OK;
92
}
93
94
MOZ_MUST_USE NS_IMETHOD SetSpec(const nsACString& aSpec,
95
nsIURIMutator** aMutator) override {
96
if (aMutator) {
97
NS_ADDREF(*aMutator = this);
98
}
99
return InitFromSpec(aSpec);
100
}
101
102
MOZ_MUST_USE NS_IMETHOD Init(nsIURI* innerURI) override {
103
mURI = new nsSimpleNestedURI(innerURI);
104
return NS_OK;
105
}
106
107
friend class nsSimpleNestedURI;
108
};
109
110
friend BaseURIMutator<nsSimpleNestedURI>;
111
};
112
113
} // namespace net
114
} // namespace mozilla
115
116
#endif /* nsSimpleNestedURI_h__ */