Bug 1814798 - pt 2. Add a PHCManager component to control PHC r=glandium,emilio
[gecko.git] / netwerk / protocol / res / SubstitutingURL.h
blobb9012f16655043d63f812c429e217c8b98f19fb0
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/. */
7 #ifndef SubstitutingURL_h
8 #define SubstitutingURL_h
10 #include "nsStandardURL.h"
12 class nsIIOService;
14 namespace mozilla {
15 namespace net {
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;
25 private:
26 explicit SubstitutingURL() : nsStandardURL(true) {}
27 explicit SubstitutingURL(bool aSupportsFileURL) : nsStandardURL(true) {
28 MOZ_ASSERT(aSupportsFileURL);
30 virtual nsresult Clone(nsIURI** aURI) override {
31 return nsStandardURL::Clone(aURI);
33 virtual ~SubstitutingURL() = default;
35 public:
36 class Mutator : public TemplatedMutator<SubstitutingURL> {
37 NS_DECL_ISUPPORTS
38 public:
39 explicit Mutator() = default;
41 private:
42 virtual ~Mutator() = default;
44 SubstitutingURL* Create() override { return new SubstitutingURL(); }
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;
53 mutator.forget(aMutator);
54 return NS_OK;
57 NS_IMETHOD_(void) Serialize(ipc::URIParams& aParams) override;
59 friend BaseURIMutator<SubstitutingURL>;
60 friend TemplatedMutator<SubstitutingURL>;
63 } // namespace net
64 } // namespace mozilla
66 #endif /* SubstitutingURL_h */