1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef DefaultURI_h__ 6 #define DefaultURI_h__ 7 8 #include "nsIURI.h" 9 #include "nsISerializable.h" 10 #include "nsISizeOf.h" 11 #include "nsIURIMutator.h" 12 #include "mozilla/net/MozURL.h" 13 14 namespace mozilla { 15 namespace net { 16 17 class DefaultURI : public nsIURI, public nsISerializable, public nsISizeOf { 18 public: 19 NS_DECL_THREADSAFE_ISUPPORTS 20 NS_DECL_NSIURI 21 NS_DECL_NSISERIALIZABLE 22 23 virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override; 24 virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override; 25 26 class Mutator final : public nsIURIMutator, public nsISerializable { 27 NS_DECL_ISUPPORTS 28 NS_DECL_NSIURISETSPEC 29 NS_DECL_NSIURISETTERS 30 NS_DECL_NSIURIMUTATOR 31 32 NS_IMETHOD Write(nsIObjectOutputStream * aOutputStream)33 Write(nsIObjectOutputStream* aOutputStream) override { 34 MOZ_ASSERT_UNREACHABLE("nsIURIMutator.write() should never be called"); 35 return NS_ERROR_NOT_IMPLEMENTED; 36 } 37 38 [[nodiscard]] NS_IMETHOD Read(nsIObjectInputStream* aStream) override; 39 40 explicit Mutator() = default; 41 42 private: 43 virtual ~Mutator() = default; Init(DefaultURI * aFrom)44 void Init(DefaultURI* aFrom) { mMutator = Some(aFrom->mURL->Mutate()); } 45 46 Maybe<MozURL::Mutator> mMutator; 47 48 friend class DefaultURI; 49 }; 50 51 private: 52 virtual ~DefaultURI() = default; 53 RefPtr<MozURL> mURL; 54 }; 55 56 } // namespace net 57 } // namespace mozilla 58 59 #endif // DefaultURI_h__ 60