Bug 1494333 - index crons just like artifacts r=Callek
[gecko.git] / caps / NullPrincipalURI.h
blobbfc3092e0f87faaf7e4985752953d5d80bd0ee14
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 mozilla_NullPrincipalURI_h
12 #define mozilla_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 {
31 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(MallocSizeOf aMallocSizeOf) const override;
44 virtual size_t SizeOfIncludingThis(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 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&);
75 public:
76 class Mutator final
77 : public nsIURIMutator
78 , public BaseURIMutator<NullPrincipalURI>
80 NS_DECL_ISUPPORTS
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
90 mURI.forget(aURI);
91 return NS_OK;
94 NS_IMETHOD SetSpec(const nsACString & aSpec, nsIURIMutator** aMutator) override
96 if (aMutator) {
97 nsCOMPtr<nsIURIMutator> mutator = this;
98 mutator.forget(aMutator);
100 return NS_ERROR_NOT_IMPLEMENTED;
103 explicit Mutator() { }
104 private:
105 virtual ~Mutator() { }
107 friend class NullPrincipalURI;
110 friend class BaseURIMutator<NullPrincipalURI>;
113 } // mozilla namespace
115 #endif // mozilla_NullPrincipalURI_h