1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 sts=2 expandtab
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * This wraps nsSimpleURI so that all calls to it are done on the main thread.
11 #ifndef mozilla_NullPrincipalURI_h
12 #define mozilla_NullPrincipalURI_h
15 #include "nsISizeOf.h"
17 #include "mozilla/Attributes.h"
18 #include "nsIIPCSerializableURI.h"
19 #include "mozilla/MemoryReporting.h"
20 #include "NullPrincipal.h"
22 #include "nsIURIMutator.h"
24 // {51fcd543-3b52-41f7-b91b-6b54102236e6}
25 #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
26 {0x51fcd543, 0x3b52, 0x41f7, \
27 {0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6} }
33 class NullPrincipalURI final
: public nsIURI
35 , public nsIIPCSerializableURI
38 NS_DECL_THREADSAFE_ISUPPORTS
40 NS_DECL_NSIIPCSERIALIZABLEURI
43 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf
) const override
;
44 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const override
;
46 // Returns null on failure.
47 static already_AddRefed
<NullPrincipalURI
> Create();
51 NullPrincipalURI(const NullPrincipalURI
& aOther
);
53 ~NullPrincipalURI() {}
57 nsAutoCStringN
<NSID_LENGTH
> mPath
;
59 nsresult
Clone(nsIURI
** aURI
);
60 nsresult
SetSpecInternal(const nsACString
&input
);
61 nsresult
SetScheme(const nsACString
&input
);
62 nsresult
SetUserPass(const nsACString
&input
);
63 nsresult
SetUsername(const nsACString
&input
);
64 nsresult
SetPassword(const nsACString
&input
);
65 nsresult
SetHostPort(const nsACString
&aValue
);
66 nsresult
SetHost(const nsACString
&input
);
67 nsresult
SetPort(int32_t port
);
68 nsresult
SetPathQueryRef(const nsACString
&input
);
69 nsresult
SetRef(const nsACString
&input
);
70 nsresult
SetFilePath(const nsACString
&input
);
71 nsresult
SetQuery(const nsACString
&input
);
72 nsresult
SetQueryWithEncoding(const nsACString
&input
, const Encoding
* encoding
);
73 bool Deserialize(const mozilla::ipc::URIParams
&);
77 : public nsIURIMutator
78 , public BaseURIMutator
<NullPrincipalURI
>
81 NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI
)
83 NS_IMETHOD
Deserialize(const mozilla::ipc::URIParams
& aParams
) override
85 return InitFromIPCParams(aParams
);
88 NS_IMETHOD
Finalize(nsIURI
** aURI
) override
94 NS_IMETHOD
SetSpec(const nsACString
& aSpec
, nsIURIMutator
** aMutator
) override
97 nsCOMPtr
<nsIURIMutator
> mutator
= this;
98 mutator
.forget(aMutator
);
100 return NS_ERROR_NOT_IMPLEMENTED
;
103 explicit Mutator() { }
105 virtual ~Mutator() { }
107 friend class NullPrincipalURI
;
110 friend class BaseURIMutator
<NullPrincipalURI
>;
113 } // mozilla namespace
115 #endif // mozilla_NullPrincipalURI_h