Bug 1440355 [wpt PR 9634] - Updating test_element to correctly test for 'checked...
[gecko.git] / caps / NullPrincipalURI.h
blobda3813da55fdfc3cfcaa189e31356030e82ab391
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/. */
7 /**
8 * This wraps nsSimpleURI so that all calls to it are done on the main thread.
9 */
11 #ifndef __NullPrincipalURI_h__
12 #define __NullPrincipalURI_h__
14 #include "nsIURI.h"
15 #include "nsISizeOf.h"
16 #include "nsString.h"
17 #include "mozilla/Attributes.h"
18 #include "nsIIPCSerializableURI.h"
19 #include "mozilla/MemoryReporting.h"
20 #include "NullPrincipal.h"
21 #include "nsID.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} }
29 namespace mozilla {
30 class Encoding;
33 class NullPrincipalURI final : public nsIURI
34 , public nsISizeOf
35 , public nsIIPCSerializableURI
37 public:
38 NS_DECL_THREADSAFE_ISUPPORTS
39 NS_DECL_NSIURI
40 NS_DECL_NSIIPCSERIALIZABLEURI
42 // nsISizeOf
43 virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
44 virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
46 // Returns null on failure.
47 static already_AddRefed<NullPrincipalURI> Create();
49 private:
50 NullPrincipalURI();
51 NullPrincipalURI(const NullPrincipalURI& aOther);
53 ~NullPrincipalURI() {}
55 nsresult Init();
57 nsAutoCStringN<NSID_LENGTH> mPath;
59 nsresult SetSpecInternal(const nsACString &input);
60 nsresult SetScheme(const nsACString &input);
61 nsresult SetUserPass(const nsACString &input);
62 nsresult SetUsername(const nsACString &input);
63 nsresult SetPassword(const nsACString &input);
64 nsresult SetHostPort(const nsACString &aValue);
65 nsresult SetHost(const nsACString &input);
66 nsresult SetPort(int32_t port);
67 nsresult SetPathQueryRef(const nsACString &input);
68 nsresult SetRef(const nsACString &input);
69 nsresult SetFilePath(const nsACString &input);
70 nsresult SetQuery(const nsACString &input);
71 nsresult SetQueryWithEncoding(const nsACString &input, const mozilla::Encoding* encoding);
72 bool Deserialize(const mozilla::ipc::URIParams&);
74 public:
75 class Mutator final
76 : public nsIURIMutator
77 , public BaseURIMutator<NullPrincipalURI>
79 NS_DECL_ISUPPORTS
80 NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
82 NS_IMETHOD Deserialize(const mozilla::ipc::URIParams& aParams) override
84 return InitFromIPCParams(aParams);
87 NS_IMETHOD Finalize(nsIURI** aURI) override
89 mURI.forget(aURI);
90 return NS_OK;
93 NS_IMETHOD SetSpec(const nsACString & aSpec, nsIURIMutator** aMutator) override
95 if (aMutator) {
96 nsCOMPtr<nsIURIMutator> mutator = this;
97 mutator.forget(aMutator);
99 return NS_ERROR_NOT_IMPLEMENTED;
102 explicit Mutator() { }
103 private:
104 virtual ~Mutator() { }
106 friend class NullPrincipalURI;
109 friend class BaseURIMutator<NullPrincipalURI>;
112 #endif // __NullPrincipalURI_h__