SubstitutingURL.h (1834B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef SubstitutingURL_h 8 #define SubstitutingURL_h 9 10 #include "nsStandardURL.h" 11 12 class nsIIOService; 13 14 namespace mozilla { 15 namespace net { 16 17 // SubstitutingURL : overrides nsStandardURL::GetFile to provide nsIFile 18 // resolution 19 class SubstitutingURL : public nsStandardURL { 20 public: 21 NS_DECL_ISUPPORTS_INHERITED 22 virtual nsStandardURL* StartClone() override; 23 [[nodiscard]] virtual nsresult EnsureFile() override; 24 25 private: 26 explicit SubstitutingURL() : nsStandardURL(true) {} 27 explicit SubstitutingURL(bool aSupportsFileURL) : nsStandardURL(true) { 28 MOZ_ASSERT(aSupportsFileURL); 29 } 30 virtual nsresult Clone(nsIURI** aURI) override { 31 return nsStandardURL::Clone(aURI); 32 } 33 virtual ~SubstitutingURL() = default; 34 35 public: 36 class Mutator : public TemplatedMutator<SubstitutingURL> { 37 NS_DECL_ISUPPORTS 38 public: 39 explicit Mutator() = default; 40 41 private: 42 virtual ~Mutator() = default; 43 44 SubstitutingURL* Create() override { return new SubstitutingURL(); } 45 }; 46 47 NS_IMETHOD Mutate(nsIURIMutator** aMutator) override { 48 RefPtr<SubstitutingURL::Mutator> mutator = new SubstitutingURL::Mutator(); 49 nsresult rv = mutator->InitFromURI(this); 50 if (NS_FAILED(rv)) { 51 return rv; 52 } 53 mutator.forget(aMutator); 54 return NS_OK; 55 } 56 57 NS_IMETHOD_(void) Serialize(ipc::URIParams& aParams) override; 58 59 friend BaseURIMutator<SubstitutingURL>; 60 friend TemplatedMutator<SubstitutingURL>; 61 }; 62 63 } // namespace net 64 } // namespace mozilla 65 66 #endif /* SubstitutingURL_h */