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 "mozilla/MemoryReporting.h"
19 #include "NullPrincipal.h"
21 #include "nsIURIMutator.h"
23 // {51fcd543-3b52-41f7-b91b-6b54102236e6}
24 #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
26 0x51fcd543, 0x3b52, 0x41f7, { \
27 0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6 \
35 class NullPrincipalURI final
: public nsIURI
, public nsISizeOf
{
37 NS_DECL_THREADSAFE_ISUPPORTS
43 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf
) const override
;
44 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const override
;
47 NullPrincipalURI(const NullPrincipalURI
& aOther
);
49 ~NullPrincipalURI() {}
51 nsAutoCStringN
<NSID_LENGTH
> mPath
;
53 nsresult
Clone(nsIURI
** aURI
);
54 nsresult
SetSpecInternal(const nsACString
& input
);
55 nsresult
SetScheme(const nsACString
& input
);
56 nsresult
SetUserPass(const nsACString
& input
);
57 nsresult
SetUsername(const nsACString
& input
);
58 nsresult
SetPassword(const nsACString
& input
);
59 nsresult
SetHostPort(const nsACString
& aValue
);
60 nsresult
SetHost(const nsACString
& input
);
61 nsresult
SetPort(int32_t port
);
62 nsresult
SetPathQueryRef(const nsACString
& input
);
63 nsresult
SetRef(const nsACString
& input
);
64 nsresult
SetFilePath(const nsACString
& input
);
65 nsresult
SetQuery(const nsACString
& input
);
66 nsresult
SetQueryWithEncoding(const nsACString
& input
,
67 const Encoding
* encoding
);
68 bool Deserialize(const mozilla::ipc::URIParams
&);
71 class Mutator final
: public nsIURIMutator
,
72 public BaseURIMutator
<NullPrincipalURI
> {
74 NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI
)
76 NS_IMETHOD
Deserialize(const mozilla::ipc::URIParams
& aParams
) override
{
77 return InitFromIPCParams(aParams
);
80 NS_IMETHOD
Finalize(nsIURI
** aURI
) override
{
85 NS_IMETHOD
SetSpec(const nsACString
& aSpec
,
86 nsIURIMutator
** aMutator
) override
{
88 nsCOMPtr
<nsIURIMutator
> mutator
= this;
89 mutator
.forget(aMutator
);
91 return NS_ERROR_NOT_IMPLEMENTED
;
99 friend class NullPrincipalURI
;
102 friend class BaseURIMutator
<NullPrincipalURI
>;
105 } // namespace mozilla
107 #endif // mozilla_NullPrincipalURI_h