Bug 1687263: part 4) Defer and in some cases avoid removing spellchecking-ranges...
[gecko.git] / caps / NullPrincipalURI.h
blob905f233ff241a0d3779e680dd98d958aa94fe341
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 "mozilla/MemoryReporting.h"
19 #include "NullPrincipal.h"
20 #include "nsID.h"
21 #include "nsIURIMutator.h"
23 // {51fcd543-3b52-41f7-b91b-6b54102236e6}
24 #define NS_NULLPRINCIPALURI_IMPLEMENTATION_CID \
25 { \
26 0x51fcd543, 0x3b52, 0x41f7, { \
27 0xb9, 0x1b, 0x6b, 0x54, 0x10, 0x22, 0x36, 0xe6 \
28 } \
31 namespace mozilla {
33 class Encoding;
35 class NullPrincipalURI final : public nsIURI, public nsISizeOf {
36 public:
37 NS_DECL_THREADSAFE_ISUPPORTS
38 NS_DECL_NSIURI
40 NullPrincipalURI();
42 // nsISizeOf
43 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
44 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
46 private:
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&);
71 public:
72 class Mutator final : public nsIURIMutator,
73 public BaseURIMutator<NullPrincipalURI> {
74 NS_DECL_ISUPPORTS
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 {
82 mURI.forget(aURI);
83 return NS_OK;
86 NS_IMETHOD SetSpec(const nsACString& aSpec,
87 nsIURIMutator** aMutator) override {
88 if (aMutator) {
89 nsCOMPtr<nsIURIMutator> mutator = this;
90 mutator.forget(aMutator);
92 return NS_ERROR_NOT_IMPLEMENTED;
95 explicit Mutator() {}
97 private:
98 virtual ~Mutator() {}
100 friend class NullPrincipalURI;
103 friend class BaseURIMutator<NullPrincipalURI>;
106 } // namespace mozilla
108 #endif // mozilla_NullPrincipalURI_h