bug 1116382 auto revoke MediaSource object URLs r=bholley
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 05 Jun 2015 15:55:08 +1200
changeset 248222 7af729730a83ff2761cdfac063b346593bf82b37
parent 248221 3ecbb53da4e08c027a150e4e5a840a612411a5f4
child 248223 d71b2d0ce9940fcdd1f5a538f1954b957fdb7464
push id28893
push userkwierso@gmail.com
push dateFri, 12 Jun 2015 00:02:58 +0000
treeherdermozilla-central@8cf9d3e497f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1116382
milestone41.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 1116382 auto revoke MediaSource object URLs r=bholley
dom/base/URL.cpp
--- a/dom/base/URL.cpp
+++ b/dom/base/URL.cpp
@@ -134,19 +134,36 @@ URL::CreateObjectURL(const GlobalObject&
 }
 
 void
 URL::CreateObjectURL(const GlobalObject& aGlobal, MediaSource& aSource,
                      const objectURLOptions& aOptions,
                      nsAString& aResult,
                      ErrorResult& aError)
 {
-  CreateObjectURLInternal(aGlobal, &aSource,
-                          NS_LITERAL_CSTRING(MEDIASOURCEURI_SCHEME), aOptions,
-                          aResult, aError);
+  nsCOMPtr<nsIPrincipal> principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
+
+  nsCString url;
+  nsresult rv = nsHostObjectProtocolHandler::
+    AddDataEntry(NS_LITERAL_CSTRING(MEDIASOURCEURI_SCHEME),
+                 &aSource, principal, url);
+  if (NS_FAILED(rv)) {
+    aError.Throw(rv);
+    return;
+  }
+
+  nsCOMPtr<nsIRunnable> revocation = NS_NewRunnableFunction(
+    [url] {
+      nsHostObjectProtocolHandler::RemoveDataEntry(url);
+    });
+
+  rv = nsContentUtils::RunInStableState(revocation);
+  MOZ_ASSERT(NS_SUCCEEDED(rv), "RunInStableState() failure");
+
+  CopyASCIItoUTF16(url, aResult);
 }
 
 void
 URL::CreateObjectURLInternal(const GlobalObject& aGlobal, nsISupports* aObject,
                              const nsACString& aScheme,
                              const objectURLOptions& aOptions,
                              nsAString& aResult, ErrorResult& aRv)
 {