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/. */
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
12 #ifndef nsSimpleNestedURI_h__
13 #define nsSimpleNestedURI_h__
16 #include "nsSimpleURI.h"
17 #include "nsINestedURI.h"
18 #include "nsIURIMutator.h"
23 class nsSimpleNestedURI
: public nsSimpleURI
, public nsINestedURI
{
25 nsSimpleNestedURI() = default;
26 explicit nsSimpleNestedURI(nsIURI
* innerURI
);
28 ~nsSimpleNestedURI() = default;
31 NS_DECL_ISUPPORTS_INHERITED
34 // Overrides for various methods nsSimpleURI implements follow.
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
;
45 // nsISerializable overrides
46 NS_IMETHOD
Read(nsIObjectInputStream
* aStream
) override
;
47 NS_IMETHOD
Write(nsIObjectOutputStream
* aStream
) override
;
50 nsCOMPtr
<nsIURI
> mInnerURI
;
52 nsresult
SetPathQueryRef(const nsACString
& aPathQueryRef
) override
;
53 nsresult
SetQuery(const nsACString
& aQuery
) override
;
54 nsresult
SetRef(const nsACString
& aRef
) override
;
55 bool Deserialize(const mozilla::ipc::URIParams
&);
56 nsresult
ReadPrivate(nsIObjectInputStream
* stream
);
59 class Mutator final
: public nsIURIMutator
,
60 public BaseURIMutator
<nsSimpleNestedURI
>,
61 public nsISerializable
,
62 public nsINestedURIMutator
{
64 NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI
)
66 explicit Mutator() = default;
69 virtual ~Mutator() = default;
71 [[nodiscard
]] NS_IMETHOD
Deserialize(
72 const mozilla::ipc::URIParams
& aParams
) override
{
73 return InitFromIPCParams(aParams
);
77 Write(nsIObjectOutputStream
* aOutputStream
) override
{
78 return NS_ERROR_NOT_IMPLEMENTED
;
81 [[nodiscard
]] NS_IMETHOD
Read(nsIObjectInputStream
* aStream
) override
{
82 return InitFromInputStream(aStream
);
85 [[nodiscard
]] NS_IMETHOD
Finalize(nsIURI
** aURI
) override
{
90 [[nodiscard
]] NS_IMETHOD
SetSpec(const nsACString
& aSpec
,
91 nsIURIMutator
** aMutator
) override
{
93 NS_ADDREF(*aMutator
= this);
95 return InitFromSpec(aSpec
);
98 [[nodiscard
]] NS_IMETHOD
Init(nsIURI
* innerURI
) override
{
99 mURI
= new nsSimpleNestedURI(innerURI
);
103 friend class nsSimpleNestedURI
;
106 friend BaseURIMutator
<nsSimpleNestedURI
>;
110 } // namespace mozilla
112 #endif /* nsSimpleNestedURI_h__ */