Bug 1466023 - Get rid of GenerateURIStringForBlobURL, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 02 Jun 2018 15:51:42 +0200
changeset 420985 6fae037fabaec69c10777b3b2c5c470f3ff34ef3
parent 420984 4a8ed669dab3b9d001e1563b68c2cd6bd6ce5b1a
child 420986 703b0fc17e49383be3a3151e48599f5ed147beb1
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1466023
milestone62.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 1466023 - Get rid of GenerateURIStringForBlobURL, r=qdot
dom/file/BlobURLProtocolHandler.cpp
dom/file/BlobURLProtocolHandler.h
--- a/dom/file/BlobURLProtocolHandler.cpp
+++ b/dom/file/BlobURLProtocolHandler.cpp
@@ -594,34 +594,34 @@ BlobURLProtocolHandler::~BlobURLProtocol
 
 /* static */ nsresult
 BlobURLProtocolHandler::AddDataEntry(BlobImpl* aBlobImpl,
                                      nsIPrincipal* aPrincipal,
                                      nsACString& aUri)
 {
   Init();
 
-  nsresult rv = GenerateURIStringForBlobURL(aPrincipal, aUri);
+  nsresult rv = GenerateURIString(aPrincipal, aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddDataEntryInternal(aUri, aBlobImpl, aPrincipal);
   NS_ENSURE_SUCCESS(rv, rv);
 
   BroadcastBlobURLRegistration(aUri, aBlobImpl, aPrincipal);
   return NS_OK;
 }
 
 /* static */ nsresult
 BlobURLProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
                                      nsIPrincipal* aPrincipal,
                                      nsACString& aUri)
 {
   Init();
 
-  nsresult rv = GenerateURIStringForBlobURL(aPrincipal, aUri);
+  nsresult rv = GenerateURIString(aPrincipal, aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddDataEntryInternal(aUri, aMediaSource, aPrincipal);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
@@ -704,33 +704,32 @@ BlobURLProtocolHandler::RemoveDataEntrie
 
 /* static */ bool
 BlobURLProtocolHandler::HasDataEntry(const nsACString& aUri)
 {
   return !!GetDataInfo(aUri);
 }
 
 /* static */ nsresult
-BlobURLProtocolHandler::GenerateURIString(const nsACString &aScheme,
-                                          nsIPrincipal* aPrincipal,
+BlobURLProtocolHandler::GenerateURIString(nsIPrincipal* aPrincipal,
                                           nsACString& aUri)
 {
   nsresult rv;
   nsCOMPtr<nsIUUIDGenerator> uuidgen =
     do_GetService("@mozilla.org/uuid-generator;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsID id;
   rv = uuidgen->GenerateUUIDInPlace(&id);
   NS_ENSURE_SUCCESS(rv, rv);
 
   char chars[NSID_LENGTH];
   id.ToProvidedString(chars);
 
-  aUri = aScheme;
+  aUri.AssignLiteral(BLOBURI_SCHEME);
   aUri.Append(':');
 
   if (aPrincipal) {
     nsAutoCString origin;
     rv = nsContentUtils::GetASCIIOrigin(aPrincipal, origin);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
@@ -739,24 +738,16 @@ BlobURLProtocolHandler::GenerateURIStrin
     aUri.Append('/');
   }
 
   aUri += Substring(chars + 1, chars + NSID_LENGTH - 2);
 
   return NS_OK;
 }
 
-/* static */ nsresult
-BlobURLProtocolHandler::GenerateURIStringForBlobURL(nsIPrincipal* aPrincipal,
-                                                    nsACString& aUri)
-{
-  return
-    GenerateURIString(NS_LITERAL_CSTRING(BLOBURI_SCHEME), aPrincipal, aUri);
-}
-
 /* static */ nsIPrincipal*
 BlobURLProtocolHandler::GetDataEntryPrincipal(const nsACString& aUri)
 {
   if (!gDataTable) {
     return nullptr;
   }
 
   DataInfo* res = GetDataInfo(aUri);
--- a/dom/file/BlobURLProtocolHandler.h
+++ b/dom/file/BlobURLProtocolHandler.h
@@ -35,23 +35,16 @@ class BlobURLProtocolHandler final : pub
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPROTOCOLHANDLER
   NS_DECL_NSIPROTOCOLHANDLERWITHDYNAMICFLAGS
 
   BlobURLProtocolHandler();
 
-  // If principal is not null, its origin will be used to generate the URI.
-  static nsresult GenerateURIString(const nsACString &aScheme,
-                                    nsIPrincipal* aPrincipal,
-                                    nsACString &aUri);
-  static nsresult GenerateURIStringForBlobURL(nsIPrincipal* aPrincipal,
-                                              nsACString &aUri);
-
   // Methods for managing uri->object mapping
   // AddDataEntry creates the URI with the given scheme and returns it in aUri
   static nsresult AddDataEntry(mozilla::dom::BlobImpl* aBlobImpl,
                                nsIPrincipal* aPrincipal,
                                nsACString& aUri);
   static nsresult AddDataEntry(mozilla::dom::MediaSource* aMediaSource,
                                nsIPrincipal* aPrincipal,
                                nsACString& aUri);
@@ -73,16 +66,20 @@ public:
   static bool
   GetAllBlobURLEntries(nsTArray<mozilla::dom::BlobURLRegistrationData>& aRegistrations,
                        mozilla::dom::ContentParent* aCP);
 
 private:
   ~BlobURLProtocolHandler();
 
   static void Init();
+
+  // If principal is not null, its origin will be used to generate the URI.
+  static nsresult GenerateURIString(nsIPrincipal* aPrincipal,
+                                    nsACString &aUri);
 };
 
 bool IsBlobURI(nsIURI* aUri);
 bool IsMediaSourceURI(nsIURI* aUri);
 
 } // namespace dom
 } // namespace mozilla