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
);
48 void operator=(const NullPrincipalURI
& aOther
) = delete;
50 ~NullPrincipalURI() {}
52 nsAutoCStringN
<NSID_LENGTH
> mPath
;
54 nsresult
Clone(nsIURI
** aURI
);
55 nsresult
SetSpecInternal(const nsACString
& input
);
56 nsresult
SetScheme(const nsACString
& input
);
57 nsresult
SetUserPass(const nsACString
& input
);
58 nsresult
SetUsername(const nsACString
& input
);
59 nsresult
SetPassword(const nsACString
& input
);
60 nsresult
SetHostPort(const nsACString
& aValue
);
61 nsresult
SetHost(const nsACString
& input
);
62 nsresult
SetPort(int32_t port
);
63 nsresult
SetPathQueryRef(const nsACString
& input
);
64 nsresult
SetRef(const nsACString
& input
);
65 nsresult
SetFilePath(const nsACString
& input
);
66 nsresult
SetQuery(const nsACString
& input
);
67 nsresult
SetQueryWithEncoding(const nsACString
& input
,
68 const Encoding
* encoding
);
69 bool Deserialize(const mozilla::ipc::URIParams
&);
72 class Mutator final
: public nsIURIMutator
,
73 public BaseURIMutator
<NullPrincipalURI
> {
75 NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI
)
77 NS_IMETHOD
Deserialize(const mozilla::ipc::URIParams
& aParams
) override
{
78 return InitFromIPCParams(aParams
);
81 NS_IMETHOD
Finalize(nsIURI
** aURI
) override
{
86 NS_IMETHOD
SetSpec(const nsACString
& aSpec
,
87 nsIURIMutator
** aMutator
) override
{
89 nsCOMPtr
<nsIURIMutator
> mutator
= this;
90 mutator
.forget(aMutator
);
92 return NS_ERROR_NOT_IMPLEMENTED
;
100 friend class NullPrincipalURI
;
103 friend class BaseURIMutator
<NullPrincipalURI
>;
106 } // namespace mozilla
108 #endif // mozilla_NullPrincipalURI_h