Bug 1532253 - make BlobURL.mMutable be private r=baku
☠☠ backed out by 949fbfb190a2 ☠ ☠
authorValentin Gosu <valentin.gosu@gmail.com>
Tue, 05 Mar 2019 17:15:30 +0100
changeset 521353 0491d225285c
parent 521352 5384779a3b1f
child 521354 8e10880ff30b
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1532253
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532253 - make BlobURL.mMutable be private r=baku Differential Revision: https://phabricator.services.mozilla.com/D22136
dom/file/uri/BlobURL.cpp
dom/file/uri/BlobURL.h
dom/file/uri/BlobURLProtocolHandler.cpp
--- a/dom/file/uri/BlobURL.cpp
+++ b/dom/file/uri/BlobURL.cpp
@@ -147,17 +147,17 @@ nsresult BlobURL::EqualsInternal(
       mozilla::net::nsSimpleURI::EqualsInternal(otherUri, aRefHandlingMode);
 
   // We don't want to compare the revoked flag.
   return NS_OK;
 }
 
 // Queries this list of interfaces. If none match, it queries mURI.
 NS_IMPL_NSIURIMUTATOR_ISUPPORTS(BlobURL::Mutator, nsIURISetters, nsIURIMutator,
-                                nsISerializable)
+                                nsISerializable, nsIBlobURLMutator)
 
 NS_IMETHODIMP
 BlobURL::Mutate(nsIURIMutator** aMutator) {
   RefPtr<BlobURL::Mutator> mutator = new BlobURL::Mutator();
   nsresult rv = mutator->InitFromURI(this);
   if (NS_FAILED(rv)) {
     return rv;
   }
--- a/dom/file/uri/BlobURL.h
+++ b/dom/file/uri/BlobURL.h
@@ -8,16 +8,31 @@
 #define mozilla_dom_BlobURL_h
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsISerializable.h"
 #include "nsSimpleURI.h"
 #include "prtime.h"
 
+#define NS_IBLOBURLMUTATOR_IID                       \
+  {                                                  \
+    0xf91e646d, 0xe87b, 0x485e, {                    \
+      0xbb, 0xc8, 0x0e, 0x8a, 0x2e, 0xe9, 0x87, 0xa9 \
+    }                                                \
+  }
+
+class NS_NO_VTABLE nsIBlobURLMutator : public nsISupports {
+ public:
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IBLOBURLMUTATOR_IID)
+  NS_IMETHOD SetRevoked(bool aRevoked) = 0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsIBlobURLMutator, NS_IBLOBURLMUTATOR_IID)
+
 namespace mozilla {
 namespace dom {
 
 /**
  * These URIs refer to host objects with "blob" scheme.
  */
 class BlobURL final : public mozilla::net::nsSimpleURI {
  private:
@@ -51,44 +66,50 @@ class BlobURL final : public mozilla::ne
 
  private:
   virtual ~BlobURL() = default;
 
   nsresult SetScheme(const nsACString& aProtocol) override;
   bool Deserialize(const mozilla::ipc::URIParams&);
   nsresult ReadPrivate(nsIObjectInputStream* stream);
 
+  bool mRevoked;
+
  public:
   class Mutator final : public nsIURIMutator,
                         public BaseURIMutator<BlobURL>,
+                        public nsIBlobURLMutator,
                         public nsISerializable {
     NS_DECL_ISUPPORTS
     NS_FORWARD_SAFE_NSIURISETTERS_RET(mURI)
     NS_DEFINE_NSIMUTATOR_COMMON
 
     NS_IMETHOD
     Write(nsIObjectOutputStream* aOutputStream) override {
       return NS_ERROR_NOT_IMPLEMENTED;
     }
 
     MOZ_MUST_USE NS_IMETHOD Read(nsIObjectInputStream* aStream) override {
       return InitFromInputStream(aStream);
     }
 
+    NS_IMETHOD SetRevoked(bool aRevoked) override {
+      mURI->mRevoked = aRevoked;
+      return NS_OK;
+    }
+
     Mutator() = default;
 
    private:
     ~Mutator() = default;
 
     friend class BlobURL;
   };
 
   friend BaseURIMutator<BlobURL>;
-
-  bool mRevoked;
 };
 
 #define NS_HOSTOBJECTURI_CID                         \
   {                                                  \
     0xf5475c51, 0x59a7, 0x4757, {                    \
       0xb3, 0xd9, 0xe2, 0x11, 0xa9, 0x41, 0x08, 0x72 \
     }                                                \
   }
--- a/dom/file/uri/BlobURLProtocolHandler.cpp
+++ b/dom/file/uri/BlobURLProtocolHandler.cpp
@@ -749,36 +749,26 @@ BlobURLProtocolHandler::GetFlagsForURI(n
   return NS_OK;
 }
 
 NS_IMETHODIMP
 BlobURLProtocolHandler::NewURI(const nsACString& aSpec, const char* aCharset,
                                nsIURI* aBaseURI, nsIURI** aResult) {
   *aResult = nullptr;
 
-  nsCOMPtr<nsIURI> uri;
-  nsresult rv =
-      NS_MutateURI(new BlobURL::Mutator()).SetSpec(aSpec).Finalize(uri);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   bool revoked = true;
   DataInfo* info = GetDataInfo(aSpec);
   if (info && info->mObjectType == DataInfo::eBlobImpl) {
     revoked = info->mRevoked;
   }
 
-  RefPtr<BlobURL> blobURL;
-  rv = uri->QueryInterface(kHOSTOBJECTURICID, getter_AddRefs(blobURL));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  MOZ_ASSERT(blobURL);
-  blobURL->mRevoked = revoked;
-
-  uri.forget(aResult);
-  return NS_OK;
+  return NS_MutateURI(new BlobURL::Mutator())
+      .SetSpec(aSpec)
+      .Apply(NS_MutatorMethod(&nsIBlobURLMutator::SetRevoked, revoked))
+      .Finalize(aResult);
 }
 
 NS_IMETHODIMP
 BlobURLProtocolHandler::NewChannel(nsIURI* aURI, nsILoadInfo* aLoadInfo,
                                    nsIChannel** aResult) {
   RefPtr<BlobURLChannel> channel = new BlobURLChannel(aURI, aLoadInfo);
 
   auto raii = MakeScopeExit([&] {