tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DefaultURI.h (1363B)


      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 "nsIURIMutator.h"
     11 #include "mozilla/net/MozURL.h"
     12 
     13 namespace mozilla {
     14 namespace net {
     15 
     16 class DefaultURI : public nsIURI, public nsISerializable {
     17 public:
     18  NS_DECL_THREADSAFE_ISUPPORTS
     19  NS_DECL_NSIURI
     20  NS_DECL_NSISERIALIZABLE
     21 
     22  class Mutator final : public nsIURIMutator, public nsISerializable {
     23    NS_DECL_ISUPPORTS
     24    NS_DECL_NSIURISETSPEC
     25    NS_DECL_NSIURISETTERS
     26    NS_DECL_NSIURIMUTATOR
     27 
     28    NS_IMETHOD
     29    Write(nsIObjectOutputStream* aOutputStream) override {
     30      MOZ_ASSERT_UNREACHABLE("nsIURIMutator.write() should never be called");
     31      return NS_ERROR_NOT_IMPLEMENTED;
     32    }
     33 
     34    [[nodiscard]] NS_IMETHOD Read(nsIObjectInputStream* aStream) override;
     35 
     36    explicit Mutator() = default;
     37 
     38   private:
     39    virtual ~Mutator() = default;
     40    void Init(DefaultURI* aFrom) { mMutator = Some(aFrom->mURL->Mutate()); }
     41 
     42    Maybe<MozURL::Mutator> mMutator;
     43 
     44    friend class DefaultURI;
     45  };
     46 
     47 private:
     48  virtual ~DefaultURI() = default;
     49  RefPtr<MozURL> mURL;
     50 };
     51 
     52 }  // namespace net
     53 }  // namespace mozilla
     54 
     55 #endif  // DefaultURI_h__