Bug 1466023 - Separate FontTableURI and BlobURL, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 02 Jun 2018 15:51:42 +0200
changeset 475200 3ad2d9f4b20372c952f5525f0440769bdc5ccc1a
parent 475199 29fbb29690f925bb99c2ddea6b1a43a063dea317
child 475201 dfeb1b271403c093be29da3296dbf128eb332876
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [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 - Separate FontTableURI and BlobURL, r=qdot This patch splits FontTableURI and BlobURL in 2 classes: FontTableURIProtocolHandler and BlobURLProtocolHandler both under mozilla::dom. It also removes a memory reporter because that report is already covered by the BlobURL one.
dom/base/nsContentUtils.cpp
dom/base/nsDocument.cpp
dom/base/nsIGlobalObject.cpp
dom/fetch/FetchDriver.cpp
dom/file/BlobURLProtocolHandler.cpp
dom/file/BlobURLProtocolHandler.h
dom/file/FontTableURIProtocolHandler.cpp
dom/file/FontTableURIProtocolHandler.h
dom/file/MutableBlobStorage.h
dom/file/MutableBlobStreamListener.cpp
dom/file/StreamBlobImpl.cpp
dom/file/moz.build
dom/file/nsHostObjectProtocolHandler.cpp
dom/file/nsHostObjectProtocolHandler.h
dom/file/nsHostObjectURI.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLSourceElement.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/media/BaseMediaResource.cpp
dom/media/FileMediaResource.cpp
dom/url/URLMainThread.cpp
dom/url/URLWorker.cpp
dom/workers/ScriptLoader.cpp
gfx/thebes/gfxSVGGlyphs.cpp
image/ImageCacheKey.cpp
layout/base/nsRefreshDriver.cpp
layout/build/nsLayoutStatics.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -32,28 +32,30 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/Base64.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LoadInfo.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/CustomElementRegistry.h"
 #include "mozilla/dom/MessageBroadcaster.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/DOMExceptionBinding.h"
 #include "mozilla/dom/DOMTypes.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FileSystemSecurity.h"
 #include "mozilla/dom/FileBlobImpl.h"
+#include "mozilla/dom/FontTableURIProtocolHandler.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/dom/HTMLSlotElement.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/IDTracker.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/KeyboardEventBinding.h"
 #include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/NodeBinding.h"
@@ -106,17 +108,16 @@
 #include "mozilla/dom/DataTransfer.h"
 #include "nsDOMJSUtils.h"
 #include "nsDOMMutationObserver.h"
 #include "nsError.h"
 #include "nsFocusManager.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGenericHTMLFrameElement.h"
 #include "nsGkAtoms.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsHtml5Module.h"
 #include "nsHtml5StringParser.h"
 #include "nsHTMLDocument.h"
 #include "nsHTMLTags.h"
 #include "nsIAddonPolicyService.h"
 #include "nsIAnonymousContentCreator.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsICategoryManager.h"
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -122,17 +122,17 @@
 #include "nsBidiUtils.h"
 
 #include "nsContentCreatorFunctions.h"
 
 #include "nsIScriptContext.h"
 #include "nsBindingManager.h"
 #include "nsHTMLDocument.h"
 #include "nsIRequest.h"
-#include "nsHostObjectProtocolHandler.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 
 #include "nsCharsetSource.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/InternalMutationEvent.h"
--- a/dom/base/nsIGlobalObject.cpp
+++ b/dom/base/nsIGlobalObject.cpp
@@ -1,21 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIGlobalObject.h"
 
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ServiceWorker.h"
 #include "mozilla/dom/ServiceWorkerRegistration.h"
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
-#include "nsHostObjectProtocolHandler.h"
 
 using mozilla::MallocSizeOf;
 using mozilla::Maybe;
 using mozilla::DOMEventTargetHelper;
 using mozilla::dom::ClientInfo;
 using mozilla::dom::ServiceWorker;
 using mozilla::dom::ServiceWorkerDescriptor;
 using mozilla::dom::ServiceWorkerRegistration;
@@ -62,17 +62,17 @@ public:
     mURIs.SwapElements(aURIs);
   }
 
   NS_IMETHOD Run() override
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     for (uint32_t index = 0; index < mURIs.Length(); ++index) {
-      nsHostObjectProtocolHandler::RemoveDataEntry(mURIs[index]);
+      BlobURLProtocolHandler::RemoveDataEntry(mURIs[index]);
     }
 
     return NS_OK;
   }
 
 private:
   ~UnlinkHostObjectURIsRunnable() {}
 
@@ -85,24 +85,24 @@ void
 nsIGlobalObject::UnlinkHostObjectURIs()
 {
   if (mHostObjectURIs.IsEmpty()) {
     return;
   }
 
   if (NS_IsMainThread()) {
     for (uint32_t index = 0; index < mHostObjectURIs.Length(); ++index) {
-      nsHostObjectProtocolHandler::RemoveDataEntry(mHostObjectURIs[index]);
+      BlobURLProtocolHandler::RemoveDataEntry(mHostObjectURIs[index]);
     }
 
     mHostObjectURIs.Clear();
     return;
   }
 
-  // nsHostObjectProtocolHandler is main-thread only.
+  // BlobURLProtocolHandler is main-thread only.
 
   RefPtr<UnlinkHostObjectURIsRunnable> runnable =
     new UnlinkHostObjectURIsRunnable(mHostObjectURIs);
   MOZ_ASSERT(mHostObjectURIs.IsEmpty());
 
   nsresult rv = NS_DispatchToMainThread(runnable);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch a runnable to the main-thread.");
@@ -118,17 +118,17 @@ nsIGlobalObject::TraverseHostObjectURIs(
 
   // Currently we only store BlobImpl objects off the the main-thread and they
   // are not CCed.
   if (!NS_IsMainThread()) {
     return;
   }
 
   for (uint32_t index = 0; index < mHostObjectURIs.Length(); ++index) {
-    nsHostObjectProtocolHandler::Traverse(mHostObjectURIs[index], aCb);
+    BlobURLProtocolHandler::Traverse(mHostObjectURIs[index], aCb);
   }
 }
 
 void
 nsIGlobalObject::AddEventTargetObject(DOMEventTargetHelper* aObject)
 {
   MOZ_DIAGNOSTIC_ASSERT(aObject);
   MOZ_ASSERT(!aObject->isInList());
--- a/dom/fetch/FetchDriver.cpp
+++ b/dom/fetch/FetchDriver.cpp
@@ -17,24 +17,24 @@
 #include "nsISupportsPriority.h"
 #include "nsIThreadRetargetableRequest.h"
 #include "nsIUploadChannel2.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPipe.h"
 
 #include "nsContentPolicyUtils.h"
 #include "nsDataHandler.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsHttpChannel.h"
 
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/PerformanceStorage.h"
 #include "mozilla/dom/WorkerCommon.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "mozilla/Unused.h"
 
 #include "Fetch.h"
rename from dom/file/nsHostObjectProtocolHandler.cpp
rename to dom/file/BlobURLProtocolHandler.cpp
--- a/dom/file/nsHostObjectProtocolHandler.cpp
+++ b/dom/file/BlobURLProtocolHandler.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsHostObjectProtocolHandler.h"
+#include "BlobURLProtocolHandler.h"
 
 #include "mozilla/dom/ChromeUtils.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/BlobImpl.h"
 #include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/MediaSource.h"
@@ -26,19 +26,21 @@
 #include "nsIException.h" // for nsIStackFrame
 #include "nsIMemoryReporter.h"
 #include "nsIPrincipal.h"
 #include "nsIUUIDGenerator.h"
 #include "nsNetUtil.h"
 
 #define RELEASING_TIMER 5000
 
-using namespace mozilla;
-using namespace mozilla::dom;
-using namespace mozilla::ipc;
+namespace mozilla {
+
+using namespace ipc;
+
+namespace dom {
 
 // -----------------------------------------------------------------------
 // Hash table
 struct DataInfo
 {
   enum ObjectType {
     eBlobImpl,
     eMediaSource
@@ -121,18 +123,16 @@ GetDataInfoFromURI(nsIURI* aURI, bool aA
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return nullptr;
   }
 
   return GetDataInfo(spec, aAlsoIfRevoked);
 }
 
 // Memory reporting for the hash table.
-namespace mozilla {
-
 void
 BroadcastBlobURLRegistration(const nsACString& aURI,
                              BlobImpl* aBlobImpl,
                              nsIPrincipal* aPrincipal)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aBlobImpl);
 
@@ -163,38 +163,16 @@ BroadcastBlobURLUnregistration(const nsC
     dom::ContentParent::BroadcastBlobURLUnregistration(aURI);
     return;
   }
 
   dom::ContentChild* cc = dom::ContentChild::GetSingleton();
   Unused << NS_WARN_IF(!cc->SendUnstoreAndBroadcastBlobURLUnregistration(aURI));
 }
 
-class HostObjectURLsReporter final : public nsIMemoryReporter
-{
-  ~HostObjectURLsReporter() {}
-
- public:
-  NS_DECL_ISUPPORTS
-
-  NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
-                            nsISupports* aData, bool aAnonymize) override
-  {
-    MOZ_COLLECT_REPORT(
-      "host-object-urls", KIND_OTHER, UNITS_COUNT,
-      gDataTable ? gDataTable->Count() : 0,
-      "The number of host objects stored for access via URLs "
-      "(e.g. blobs passed to URL.createObjectURL).");
-
-    return NS_OK;
-  }
-};
-
-NS_IMPL_ISUPPORTS(HostObjectURLsReporter, nsIMemoryReporter)
-
 class BlobURLsReporter final : public nsIMemoryReporter
 {
  public:
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD CollectReports(nsIHandleReportCallback* aCallback,
                             nsISupports* aData, bool aAnonymize) override
   {
@@ -429,34 +407,34 @@ public:
   static void
   Create(const nsACString& aURI, bool aBroadcastToOtherProcesses)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     RefPtr<ReleasingTimerHolder> holder =
       new ReleasingTimerHolder(aURI, aBroadcastToOtherProcesses);
 
-    auto raii = mozilla::MakeScopeExit([holder] {
+    auto raii = MakeScopeExit([holder] {
       holder->CancelTimerAndRevokeURI();
     });
 
     nsresult rv =
       SystemGroup::EventTargetFor(TaskCategory::Other)->Dispatch(holder.forget());
     NS_ENSURE_SUCCESS_VOID(rv);
  
     raii.release();
   }
 
   // Runnable interface
 
   NS_IMETHOD
   Run() override
   {
     RefPtr<ReleasingTimerHolder> self = this;
-    auto raii = mozilla::MakeScopeExit([self] {
+    auto raii = MakeScopeExit([self] {
       self->CancelTimerAndRevokeURI();
     });
 
     nsresult rv = NS_NewTimerWithCallback(getter_AddRefs(mTimer),
                                           this, RELEASING_TIMER,
                                           nsITimer::TYPE_ONE_SHOT,
                                           SystemGroup::EventTargetFor(TaskCategory::Other));
     NS_ENSURE_SUCCESS(rv, NS_OK);
@@ -575,96 +553,94 @@ private:
   bool mBroadcastToOtherProcesses;
 
   nsCOMPtr<nsITimer> mTimer;
 };
 
 NS_IMPL_ISUPPORTS_INHERITED(ReleasingTimerHolder, Runnable, nsITimerCallback,
                             nsIAsyncShutdownBlocker)
 
-} // namespace mozilla
-
 template<typename T>
 static nsresult
 AddDataEntryInternal(const nsACString& aURI, T aObject,
                      nsIPrincipal* aPrincipal)
 {
   if (!gDataTable) {
     gDataTable = new nsClassHashtable<nsCStringHashKey, DataInfo>;
   }
 
   DataInfo* info = new DataInfo(aObject, aPrincipal);
-  mozilla::BlobURLsReporter::GetJSStackForBlob(info);
+  BlobURLsReporter::GetJSStackForBlob(info);
 
   gDataTable->Put(aURI, info);
   return NS_OK;
 }
 
 void
-nsHostObjectProtocolHandler::Init(void)
+BlobURLProtocolHandler::Init(void)
 {
   static bool initialized = false;
 
   if (!initialized) {
     initialized = true;
-    RegisterStrongMemoryReporter(new mozilla::HostObjectURLsReporter());
-    RegisterStrongMemoryReporter(new mozilla::BlobURLsReporter());
+    RegisterStrongMemoryReporter(new BlobURLsReporter());
   }
 }
 
-nsHostObjectProtocolHandler::nsHostObjectProtocolHandler()
+BlobURLProtocolHandler::BlobURLProtocolHandler()
 {
   Init();
 }
 
+BlobURLProtocolHandler::~BlobURLProtocolHandler() = default;
+
 /* static */ nsresult
-nsHostObjectProtocolHandler::AddDataEntry(BlobImpl* aBlobImpl,
-                                          nsIPrincipal* aPrincipal,
-                                          nsACString& aUri)
+BlobURLProtocolHandler::AddDataEntry(BlobImpl* aBlobImpl,
+                                     nsIPrincipal* aPrincipal,
+                                     nsACString& aUri)
 {
   Init();
 
   nsresult rv = GenerateURIStringForBlobURL(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
-nsHostObjectProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
-                                          nsIPrincipal* aPrincipal,
-                                          nsACString& aUri)
+BlobURLProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
+                                     nsIPrincipal* aPrincipal,
+                                     nsACString& aUri)
 {
   Init();
 
   nsresult rv = GenerateURIStringForBlobURL(aPrincipal, aUri);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = AddDataEntryInternal(aUri, aMediaSource, aPrincipal);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 /* static */ nsresult
-nsHostObjectProtocolHandler::AddDataEntry(const nsACString& aURI,
-                                          nsIPrincipal* aPrincipal,
-                                          BlobImpl* aBlobImpl)
+BlobURLProtocolHandler::AddDataEntry(const nsACString& aURI,
+                                     nsIPrincipal* aPrincipal,
+                                     BlobImpl* aBlobImpl)
 {
   return AddDataEntryInternal(aURI, aBlobImpl, aPrincipal);
 }
 
 /* static */ bool
-nsHostObjectProtocolHandler::GetAllBlobURLEntries(
-  nsTArray<BlobURLRegistrationData>& aRegistrations,
-  ContentParent* aCP)
+BlobURLProtocolHandler::GetAllBlobURLEntries(nsTArray<BlobURLRegistrationData>& aRegistrations,
+                                             ContentParent* aCP)
 {
   MOZ_ASSERT(aCP);
 
   if (!gDataTable) {
     return true;
   }
 
   for (auto iter = gDataTable->ConstIter(); !iter.Done(); iter.Next()) {
@@ -687,18 +663,18 @@ nsHostObjectProtocolHandler::GetAllBlobU
       nsCString(iter.Key()), ipcBlob, IPC::Principal(info->mPrincipal),
                 info->mRevoked));
   }
 
   return true;
 }
 
 /*static */ void
-nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri,
-                                             bool aBroadcastToOtherProcesses)
+BlobURLProtocolHandler::RemoveDataEntry(const nsACString& aUri,
+                                        bool aBroadcastToOtherProcesses)
 {
   if (!gDataTable) {
     return;
   }
 
   DataInfo* info = GetDataInfo(aUri);
   if (!info) {
     return;
@@ -710,37 +686,37 @@ nsHostObjectProtocolHandler::RemoveDataE
   // RELEASING_TIMER milliseconds. In the meantime, the DataInfo, marked as
   // revoked, will not be exposed.
   ReleasingTimerHolder::Create(aUri,
                                aBroadcastToOtherProcesses &&
                                  info->mObjectType == DataInfo::eBlobImpl);
 }
 
 /* static */ void
-nsHostObjectProtocolHandler::RemoveDataEntries()
+BlobURLProtocolHandler::RemoveDataEntries()
 {
   if (!gDataTable) {
     return;
   }
 
   gDataTable->Clear();
   delete gDataTable;
   gDataTable = nullptr;
 }
 
 /* static */ bool
-nsHostObjectProtocolHandler::HasDataEntry(const nsACString& aUri)
+BlobURLProtocolHandler::HasDataEntry(const nsACString& aUri)
 {
   return !!GetDataInfo(aUri);
 }
 
 /* static */ nsresult
-nsHostObjectProtocolHandler::GenerateURIString(const nsACString &aScheme,
-                                               nsIPrincipal* aPrincipal,
-                                               nsACString& aUri)
+BlobURLProtocolHandler::GenerateURIString(const nsACString &aScheme,
+                                          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);
@@ -764,113 +740,102 @@ nsHostObjectProtocolHandler::GenerateURI
   }
 
   aUri += Substring(chars + 1, chars + NSID_LENGTH - 2);
 
   return NS_OK;
 }
 
 /* static */ nsresult
-nsHostObjectProtocolHandler::GenerateURIStringForBlobURL(nsIPrincipal* aPrincipal,
-                                                         nsACString& aUri)
+BlobURLProtocolHandler::GenerateURIStringForBlobURL(nsIPrincipal* aPrincipal,
+                                                    nsACString& aUri)
 {
   return
     GenerateURIString(NS_LITERAL_CSTRING(BLOBURI_SCHEME), aPrincipal, aUri);
 }
 
 /* static */ nsIPrincipal*
-nsHostObjectProtocolHandler::GetDataEntryPrincipal(const nsACString& aUri)
+BlobURLProtocolHandler::GetDataEntryPrincipal(const nsACString& aUri)
 {
   if (!gDataTable) {
     return nullptr;
   }
 
   DataInfo* res = GetDataInfo(aUri);
 
   if (!res) {
     return nullptr;
   }
 
   return res->mPrincipal;
 }
 
 /* static */ void
-nsHostObjectProtocolHandler::Traverse(const nsACString& aUri,
-                                      nsCycleCollectionTraversalCallback& aCallback)
+BlobURLProtocolHandler::Traverse(const nsACString& aUri,
+                                 nsCycleCollectionTraversalCallback& aCallback)
 {
   if (!gDataTable) {
     return;
   }
 
   DataInfo* res;
   gDataTable->Get(aUri, &res);
   if (!res) {
     return;
   }
 
-  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "HostObjectProtocolHandler DataInfo.mBlobImpl");
+  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "BlobURLProtocolHandler DataInfo.mBlobImpl");
   aCallback.NoteXPCOMChild(res->mBlobImpl);
 
-  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "HostObjectProtocolHandler DataInfo.mMediaSource");
+  NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCallback, "BlobURLProtocolHandler DataInfo.mMediaSource");
   aCallback.NoteXPCOMChild(res->mMediaSource);
 }
 
-// -----------------------------------------------------------------------
-// Protocol handler
-
-NS_IMPL_ISUPPORTS(nsHostObjectProtocolHandler, nsIProtocolHandler,
-    nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS(BlobURLProtocolHandler, nsIProtocolHandler,
+                  nsISupportsWeakReference)
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::GetDefaultPort(int32_t *result)
+BlobURLProtocolHandler::GetDefaultPort(int32_t *result)
 {
   *result = -1;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::GetProtocolFlags(uint32_t *result)
+BlobURLProtocolHandler::GetProtocolFlags(uint32_t *result)
 {
   *result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_SUBSUMERS |
-            URI_NON_PERSISTABLE;
+            URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::GetFlagsForURI(nsIURI *aURI, uint32_t *aResult)
+BlobURLProtocolHandler::GetFlagsForURI(nsIURI *aURI, uint32_t *aResult)
 {
-  Unused << nsHostObjectProtocolHandler::GetProtocolFlags(aResult);
-  if (IsFontTableURI(aURI) || IsBlobURI(aURI)) {
+  Unused << BlobURLProtocolHandler::GetProtocolFlags(aResult);
+  if (IsBlobURI(aURI)) {
     *aResult |= URI_IS_LOCAL_RESOURCE;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsBlobProtocolHandler::GetProtocolFlags(uint32_t *result)
-{
-  Unused << nsHostObjectProtocolHandler::GetProtocolFlags(result);
-  *result |= URI_IS_LOCAL_RESOURCE;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec,
-                                    const char *aCharset,
-                                    nsIURI *aBaseURI,
-                                    nsIURI **aResult)
+BlobURLProtocolHandler::NewURI(const nsACString& aSpec,
+                               const char *aCharset,
+                               nsIURI *aBaseURI,
+                               nsIURI **aResult)
 {
   *aResult = nullptr;
   nsresult rv;
 
   DataInfo* info = GetDataInfo(aSpec);
 
   nsCOMPtr<nsIPrincipal> principal;
-  RefPtr<mozilla::dom::BlobImpl> blob;
+  RefPtr<BlobImpl> blob;
   if (info && info->mObjectType == DataInfo::eBlobImpl) {
     MOZ_ASSERT(info->mBlobImpl);
     principal = info->mPrincipal;
     blob = info->mBlobImpl;
   }
 
   nsCOMPtr<nsIURI> uri;
   rv = NS_MutateURI(new nsHostObjectURI::Mutator())
@@ -880,19 +845,19 @@ nsHostObjectProtocolHandler::NewURI(cons
   NS_ENSURE_SUCCESS(rv, rv);
 
   uri.forget(aResult);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
-                                         nsILoadInfo* aLoadInfo,
-                                         nsIChannel** result)
+BlobURLProtocolHandler::NewChannel2(nsIURI* uri,
+                                    nsILoadInfo* aLoadInfo,
+                                    nsIChannel** result)
 {
   *result = nullptr;
 
   DataInfo* info = GetDataInfoFromURI(uri, true /*aAlsoIfRevoked */);
   if (!info || info->mObjectType != DataInfo::eBlobImpl || !info->mBlobImpl) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
@@ -965,51 +930,39 @@ nsHostObjectProtocolHandler::NewChannel2
   channel->SetContentLength(size);
 
   channel.forget(result);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
+BlobURLProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
 {
   return NewChannel2(uri, nullptr, result);
 }
 
 NS_IMETHODIMP
-nsHostObjectProtocolHandler::AllowPort(int32_t port, const char *scheme,
-                                       bool *_retval)
+BlobURLProtocolHandler::AllowPort(int32_t port, const char *scheme,
+                                  bool *_retval)
 {
   // don't override anything.
   *_retval = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsBlobProtocolHandler::GetScheme(nsACString &result)
+BlobURLProtocolHandler::GetScheme(nsACString &result)
 {
   result.AssignLiteral(BLOBURI_SCHEME);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsFontTableProtocolHandler::GetProtocolFlags(uint32_t *result)
-{
-  Unused << nsHostObjectProtocolHandler::GetProtocolFlags(result);
-  *result |= URI_IS_LOCAL_RESOURCE;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsFontTableProtocolHandler::GetScheme(nsACString &result)
-{
-  result.AssignLiteral(FONTTABLEURI_SCHEME);
-  return NS_OK;
-}
+} // dom namespace
+} // mozilla namespace
 
 nsresult
 NS_GetBlobForBlobURI(nsIURI* aURI, BlobImpl** aBlob)
 {
   *aBlob = nullptr;
 
   DataInfo* info = GetDataInfoFromURI(aURI, false /* aAlsoIfRevoked */);
   if (!info || info->mObjectType != DataInfo::eBlobImpl) {
@@ -1031,100 +984,59 @@ NS_GetBlobForBlobURISpec(const nsACStrin
     return NS_ERROR_DOM_BAD_URI;
   }
 
   RefPtr<BlobImpl> blob = info->mBlobImpl;
   blob.forget(aBlob);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsFontTableProtocolHandler::NewURI(const nsACString& aSpec,
-                                   const char *aCharset,
-                                   nsIURI *aBaseURI,
-                                   nsIURI **aResult)
-{
-  nsresult rv;
-  nsCOMPtr<nsIURI> uri;
-
-  // Either you got here via a ref or a fonttable: uri
-  if (aSpec.Length() && aSpec.CharAt(0) == '#') {
-    rv = NS_MutateURI(aBaseURI)
-           .SetRef(aSpec)
-           .Finalize(uri);
-    NS_ENSURE_SUCCESS(rv, rv);
-  } else {
-    // Relative URIs (other than #ref) are not meaningful within the
-    // fonttable: scheme.
-    // If aSpec is a relative URI -other- than a bare #ref,
-    // this will leave uri empty, and we'll return a failure code below.
-    rv = NS_MutateURI(new mozilla::net::nsSimpleURI::Mutator())
-           .SetSpec(aSpec)
-           .Finalize(uri);
-    NS_ENSURE_SUCCESS(rv, rv);
-  }
-
-  bool schemeIs;
-  if (NS_FAILED(uri->SchemeIs(FONTTABLEURI_SCHEME, &schemeIs)) || !schemeIs) {
-    NS_WARNING("Non-fonttable spec in nsFontTableProtocolHander");
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  uri.forget(aResult);
-  return NS_OK;
-}
-
 nsresult
 NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** aSource)
 {
   *aSource = nullptr;
 
   DataInfo* info = GetDataInfoFromURI(aURI);
   if (!info || info->mObjectType != DataInfo::eMediaSource) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
   RefPtr<MediaSource> mediaSource = info->mMediaSource;
   mediaSource.forget(aSource);
   return NS_OK;
 }
 
+namespace mozilla {
+namespace dom {
+
 #define NS_BLOBPROTOCOLHANDLER_CID \
 { 0xb43964aa, 0xa078, 0x44b2, \
   { 0xb0, 0x6b, 0xfd, 0x4d, 0x1b, 0x17, 0x2e, 0x66 } }
 
-#define NS_FONTTABLEPROTOCOLHANDLER_CID \
-{ 0x3fc8f04e, 0xd719, 0x43ca, \
-  { 0x9a, 0xd0, 0x18, 0xee, 0x32, 0x02, 0x11, 0xf2 } }
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlobProtocolHandler)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontTableProtocolHandler)
+NS_GENERIC_FACTORY_CONSTRUCTOR(BlobURLProtocolHandler)
 
 NS_DEFINE_NAMED_CID(NS_BLOBPROTOCOLHANDLER_CID);
-NS_DEFINE_NAMED_CID(NS_FONTTABLEPROTOCOLHANDLER_CID);
 
-static const mozilla::Module::CIDEntry kHostObjectProtocolHandlerCIDs[] = {
-  { &kNS_BLOBPROTOCOLHANDLER_CID, false, nullptr, nsBlobProtocolHandlerConstructor },
-  { &kNS_FONTTABLEPROTOCOLHANDLER_CID, false, nullptr, nsFontTableProtocolHandlerConstructor },
+static const Module::CIDEntry kBlobURLProtocolHandlerCIDs[] = {
+  { &kNS_BLOBPROTOCOLHANDLER_CID, false, nullptr, BlobURLProtocolHandlerConstructor },
   { nullptr }
 };
 
-static const mozilla::Module::ContractIDEntry kHostObjectProtocolHandlerContracts[] = {
+static const Module::ContractIDEntry kBlobURLProtocolHandlerContracts[] = {
   { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX BLOBURI_SCHEME, &kNS_BLOBPROTOCOLHANDLER_CID },
-  { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX FONTTABLEURI_SCHEME, &kNS_FONTTABLEPROTOCOLHANDLER_CID },
   { nullptr }
 };
 
-static const mozilla::Module kHostObjectProtocolHandlerModule = {
-  mozilla::Module::kVersion,
-  kHostObjectProtocolHandlerCIDs,
-  kHostObjectProtocolHandlerContracts
+static const Module kBlobURLProtocolHandlerModule = {
+  Module::kVersion,
+  kBlobURLProtocolHandlerCIDs,
+  kBlobURLProtocolHandlerContracts
 };
 
-NSMODULE_DEFN(HostObjectProtocolHandler) = &kHostObjectProtocolHandlerModule;
+NSMODULE_DEFN(BlobURLProtocolHandler) = &kBlobURLProtocolHandlerModule;
 
 bool IsType(nsIURI* aUri, DataInfo::ObjectType aType)
 {
   DataInfo* info = GetDataInfoFromURI(aUri);
   if (!info) {
     return false;
   }
 
@@ -1135,8 +1047,11 @@ bool IsBlobURI(nsIURI* aUri)
 {
   return IsType(aUri, DataInfo::eBlobImpl);
 }
 
 bool IsMediaSourceURI(nsIURI* aUri)
 {
   return IsType(aUri, DataInfo::eMediaSource);
 }
+
+} // dom namespace
+} // mozilla namespace
rename from dom/file/nsHostObjectProtocolHandler.h
rename to dom/file/BlobURLProtocolHandler.h
--- a/dom/file/nsHostObjectProtocolHandler.h
+++ b/dom/file/BlobURLProtocolHandler.h
@@ -1,61 +1,50 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsHostObjectProtocolHandler_h
-#define nsHostObjectProtocolHandler_h
+#ifndef mozilla_dom_BlobURLProtocolHandler_h
+#define mozilla_dom_BlobURLProtocolHandler_h
 
 #include "mozilla/Attributes.h"
 #include "nsIProtocolHandler.h"
 #include "nsIURI.h"
 #include "nsCOMPtr.h"
 #include "nsIInputStream.h"
 #include "nsTArray.h"
 #include "nsWeakReference.h"
 
 #define BLOBURI_SCHEME "blob"
-#define FONTTABLEURI_SCHEME "moz-fonttable"
 #define RTSPURI_SCHEME "rtsp"
 
 class nsIPrincipal;
 
 namespace mozilla {
 class BlobURLsReporter;
 
 namespace dom {
+
 class BlobImpl;
 class BlobURLRegistrationData;
 class ContentParent;
 class MediaSource;
-} // namespace dom
-} // namespace mozilla
 
-class nsHostObjectProtocolHandler : public nsIProtocolHandler
-                                  , public nsIProtocolHandlerWithDynamicFlags
-                                  , public nsSupportsWeakReference
+class BlobURLProtocolHandler final : public nsIProtocolHandler
+                                   , public nsIProtocolHandlerWithDynamicFlags
+                                   , public nsSupportsWeakReference
 {
 public:
-  nsHostObjectProtocolHandler();
   NS_DECL_ISUPPORTS
+  NS_DECL_NSIPROTOCOLHANDLER
+  NS_DECL_NSIPROTOCOLHANDLERWITHDYNAMICFLAGS
 
-  // nsIProtocolHandler methods, except for GetScheme which is only defined
-  // in subclasses.
-  NS_IMETHOD GetDefaultPort(int32_t *aDefaultPort) override;
-  NS_IMETHOD GetProtocolFlags(uint32_t *aProtocolFlags) override;
-  NS_IMETHOD NewURI(const nsACString & aSpec, const char * aOriginCharset, nsIURI *aBaseURI, nsIURI * *_retval) override;
-  NS_IMETHOD NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadinfo, nsIChannel * *_retval) override;
-  NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel * *_retval) override;
-  NS_IMETHOD AllowPort(int32_t port, const char * scheme, bool *_retval) override;
-
-  // nsIProtocolHandlerWithDynamicFlags methods
-  NS_IMETHOD GetFlagsForURI(nsIURI *aURI, uint32_t *aResult) override;
+  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);
 
@@ -81,58 +70,36 @@ public:
 
   static nsIPrincipal* GetDataEntryPrincipal(const nsACString& aUri);
   static void Traverse(const nsACString& aUri, nsCycleCollectionTraversalCallback& aCallback);
 
   static bool
   GetAllBlobURLEntries(nsTArray<mozilla::dom::BlobURLRegistrationData>& aRegistrations,
                        mozilla::dom::ContentParent* aCP);
 
-protected:
-  virtual ~nsHostObjectProtocolHandler() {}
-
 private:
-  static void Init();
-};
+  ~BlobURLProtocolHandler();
 
-class nsBlobProtocolHandler : public nsHostObjectProtocolHandler
-{
-public:
-  NS_IMETHOD GetProtocolFlags(uint32_t *aProtocolFlags) override;
-  NS_IMETHOD GetScheme(nsACString &result) override;
-};
-
-class nsFontTableProtocolHandler : public nsHostObjectProtocolHandler
-{
-public:
-  NS_IMETHOD GetProtocolFlags(uint32_t *aProtocolFlags) override;
-  NS_IMETHOD GetScheme(nsACString &result) override;
-  NS_IMETHOD NewURI(const nsACString & aSpec,
-                    const char *aOriginCharset,
-                    nsIURI *aBaseURI,
-                    nsIURI **_retval) override;
+  static void Init();
 };
 
 bool IsBlobURI(nsIURI* aUri);
 bool IsMediaSourceURI(nsIURI* aUri);
 
 inline bool IsRtspURI(nsIURI* aUri)
 {
   bool isRtsp;
   return NS_SUCCEEDED(aUri->SchemeIs(RTSPURI_SCHEME, &isRtsp)) && isRtsp;
 }
 
-inline bool IsFontTableURI(nsIURI* aUri)
-{
-  bool isFont;
-  return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont;
-}
+} // namespace dom
+} // namespace mozilla
 
 extern nsresult
 NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob);
 
 extern nsresult
 NS_GetBlobForBlobURISpec(const nsACString& aSpec, mozilla::dom::BlobImpl** aBlob);
 
 extern nsresult
 NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource);
 
-#endif /* nsHostObjectProtocolHandler_h */
+#endif /* mozilla_dom_BlobURLProtocolHandler_h */
new file mode 100644
--- /dev/null
+++ b/dom/file/FontTableURIProtocolHandler.cpp
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "FontTableURIProtocolHandler.h"
+#include "mozilla/ModuleUtils.h"
+#include "nsNetUtil.h"
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+/* static */ nsresult
+FontTableURIProtocolHandler::GenerateURIString(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 = FONTTABLEURI_SCHEME;
+  aUri.Append(':');
+
+  aUri += Substring(chars + 1, chars + NSID_LENGTH - 2);
+
+  return NS_OK;
+}
+
+FontTableURIProtocolHandler::FontTableURIProtocolHandler() = default;
+FontTableURIProtocolHandler::~FontTableURIProtocolHandler() = default;
+
+NS_IMPL_ISUPPORTS(FontTableURIProtocolHandler, nsIProtocolHandler,
+                  nsISupportsWeakReference)
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::GetDefaultPort(int32_t *result)
+{
+  *result = -1;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::GetProtocolFlags(uint32_t *result)
+{
+  *result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_SUBSUMERS |
+            URI_NON_PERSISTABLE | URI_IS_LOCAL_RESOURCE;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::GetFlagsForURI(nsIURI *aURI, uint32_t *aResult)
+{
+  return FontTableURIProtocolHandler::GetProtocolFlags(aResult);
+}
+
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::NewChannel2(nsIURI* uri,
+                                         nsILoadInfo* aLoadInfo,
+                                         nsIChannel** result)
+{
+  return NS_ERROR_DOM_BAD_URI;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
+{
+  return NS_ERROR_DOM_BAD_URI;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::AllowPort(int32_t port, const char *scheme,
+                                       bool *_retval)
+{
+  *_retval = false;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::GetScheme(nsACString &result)
+{
+  result.AssignLiteral(FONTTABLEURI_SCHEME);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+FontTableURIProtocolHandler::NewURI(const nsACString& aSpec,
+                                    const char *aCharset,
+                                    nsIURI *aBaseURI,
+                                    nsIURI **aResult)
+{
+  nsresult rv;
+  nsCOMPtr<nsIURI> uri;
+
+  // Either you got here via a ref or a fonttable: uri
+  if (aSpec.Length() && aSpec.CharAt(0) == '#') {
+    rv = NS_MutateURI(aBaseURI)
+           .SetRef(aSpec)
+           .Finalize(uri);
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else {
+    // Relative URIs (other than #ref) are not meaningful within the
+    // fonttable: scheme.
+    // If aSpec is a relative URI -other- than a bare #ref,
+    // this will leave uri empty, and we'll return a failure code below.
+    rv = NS_MutateURI(new mozilla::net::nsSimpleURI::Mutator())
+           .SetSpec(aSpec)
+           .Finalize(uri);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  bool schemeIs;
+  if (NS_FAILED(uri->SchemeIs(FONTTABLEURI_SCHEME, &schemeIs)) || !schemeIs) {
+    NS_WARNING("Non-fonttable spec in FontTableURIProtocolHandler");
+    return NS_ERROR_NOT_AVAILABLE;
+  }
+
+  uri.forget(aResult);
+  return NS_OK;
+}
+
+#define NS_FONTTABLEPROTOCOLHANDLER_CID \
+{ 0x3fc8f04e, 0xd719, 0x43ca, \
+  { 0x9a, 0xd0, 0x18, 0xee, 0x32, 0x02, 0x11, 0xf2 } }
+
+NS_GENERIC_FACTORY_CONSTRUCTOR(FontTableURIProtocolHandler)
+
+NS_DEFINE_NAMED_CID(NS_FONTTABLEPROTOCOLHANDLER_CID);
+
+static const mozilla::Module::CIDEntry FontTableURIProtocolHandlerCIDs[] = {
+  { &kNS_FONTTABLEPROTOCOLHANDLER_CID, false, nullptr, FontTableURIProtocolHandlerConstructor },
+  { nullptr }
+};
+
+static const mozilla::Module::ContractIDEntry FontTableURIProtocolHandlerContracts[] = {
+  { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX FONTTABLEURI_SCHEME, &kNS_FONTTABLEPROTOCOLHANDLER_CID },
+  { nullptr }
+};
+
+static const mozilla::Module FontTableURIProtocolHandlerModule = {
+  mozilla::Module::kVersion,
+  FontTableURIProtocolHandlerCIDs,
+  FontTableURIProtocolHandlerContracts
+};
+
+NSMODULE_DEFN(FontTableURIProtocolHandler) = &FontTableURIProtocolHandlerModule;
new file mode 100644
--- /dev/null
+++ b/dom/file/FontTableURIProtocolHandler.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef FontTableURIProtocolHandler_h
+#define FontTableURIProtocolHandler_h
+
+#include "nsIProtocolHandler.h"
+#include "nsIURI.h"
+#include "nsWeakReference.h"
+
+#define FONTTABLEURI_SCHEME "moz-fonttable"
+
+namespace mozilla {
+namespace dom {
+
+class FontTableURIProtocolHandler final : public nsIProtocolHandler
+                                        , public nsIProtocolHandlerWithDynamicFlags
+                                        , public nsSupportsWeakReference
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIPROTOCOLHANDLER
+  NS_DECL_NSIPROTOCOLHANDLERWITHDYNAMICFLAGS
+
+  FontTableURIProtocolHandler();
+
+  static nsresult GenerateURIString(nsACString &aUri);
+
+protected:
+  virtual ~FontTableURIProtocolHandler();
+};
+
+inline bool IsFontTableURI(nsIURI* aUri)
+{
+  bool isFont;
+  return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont;
+}
+
+} // namespace dom
+} // namespace mozilla
+
+#endif /* FontTableURIProtocolHandler_h */
--- a/dom/file/MutableBlobStorage.h
+++ b/dom/file/MutableBlobStorage.h
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_MutableBlobStorage_h
 #define mozilla_dom_MutableBlobStorage_h
 
 #include "mozilla/RefPtr.h"
 #include "mozilla/Mutex.h"
+#include "nsCOMPtr.h"
 #include "prio.h"
 
 class nsIEventTarget;
 class nsIRunnable;
 
 namespace mozilla {
 
 class TaskQueue;
--- a/dom/file/MutableBlobStreamListener.cpp
+++ b/dom/file/MutableBlobStreamListener.cpp
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MutableBlobStreamListener.h"
 #include "MutableBlobStorage.h"
+#include "nsIInputStream.h"
+#include "nsThreadUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 MutableBlobStreamListener::MutableBlobStreamListener(MutableBlobStorage::MutableBlobStorageType aStorageType,
                                                      nsISupports* aParent,
                                                      const nsACString& aContentType,
                                                      MutableBlobStorageCallback* aCallback,
--- a/dom/file/StreamBlobImpl.cpp
+++ b/dom/file/StreamBlobImpl.cpp
@@ -1,15 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "EmptyBlobImpl.h"
+#include "mozilla/SlicedInputStream.h"
 #include "StreamBlobImpl.h"
+#include "nsStreamUtils.h"
 #include "nsStringStream.h"
 #include "nsICloneableInputStream.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ISUPPORTS_INHERITED(StreamBlobImpl, BlobImpl, nsIMemoryReporter)
 
--- a/dom/file/moz.build
+++ b/dom/file/moz.build
@@ -5,55 +5,57 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "DOM: File")
 
 DIRS += ['ipc']
 
 EXPORTS += [
-    'nsHostObjectProtocolHandler.h',
     'nsHostObjectURI.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'BaseBlobImpl.h',
     'Blob.h',
     'BlobImpl.h',
     'BlobSet.h',
+    'BlobURLProtocolHandler.h',
     'File.h',
     'FileBlobImpl.h',
     'FileCreatorHelper.h',
     'FileList.h',
     'FileReader.h',
     'FileReaderSync.h',
+    'FontTableURIProtocolHandler.h',
     'MemoryBlobImpl.h',
     'MultipartBlobImpl.h',
     'MutableBlobStorage.h',
     'MutableBlobStreamListener.h',
     'StreamBlobImpl.h',
 ]
 
 UNIFIED_SOURCES += [
     'BaseBlobImpl.cpp',
     'Blob.cpp',
     'BlobImpl.cpp',
     'BlobSet.cpp',
+    'BlobURLProtocolHandler.cpp',
     'EmptyBlobImpl.cpp',
     'File.cpp',
     'FileBlobImpl.cpp',
     'FileCreatorHelper.cpp',
     'FileList.cpp',
     'FileReader.cpp',
     'FileReaderSync.cpp',
+    'FontTableURIProtocolHandler.cpp',
     'MemoryBlobImpl.cpp',
     'MultipartBlobImpl.cpp',
     'MutableBlobStorage.cpp',
     'MutableBlobStreamListener.cpp',
-    'nsHostObjectProtocolHandler.cpp',
     'nsHostObjectURI.cpp',
     'StreamBlobImpl.cpp',
     'StringBlobImpl.cpp',
     'TemporaryFileBlobImpl.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/file/ipc',
--- a/dom/file/nsHostObjectURI.cpp
+++ b/dom/file/nsHostObjectURI.cpp
@@ -3,18 +3,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHostObjectURI.h"
 
 #include "nsIObjectInputStream.h"
 #include "nsIObjectOutputStream.h"
-#include "nsHostObjectProtocolHandler.h"
 
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 
 static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
 
 static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
                      NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);
 
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -53,16 +53,17 @@
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/AudioTrack.h"
 #include "mozilla/dom/AudioTrackList.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/HTMLAudioElement.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/dom/HTMLMediaElementBinding.h"
 #include "mozilla/dom/HTMLSourceElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "mozilla/dom/MediaEncryptedEvent.h"
 #include "mozilla/dom/MediaErrorBinding.h"
@@ -79,17 +80,16 @@
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsDisplayList.h"
 #include "nsDocShell.h"
 #include "nsError.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsICachingChannel.h"
 #include "nsICategoryManager.h"
 #include "nsIClassOfService.h"
 #include "nsIContentPolicy.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
--- a/dom/html/HTMLSourceElement.cpp
+++ b/dom/html/HTMLSourceElement.cpp
@@ -10,18 +10,17 @@
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/dom/ResponsiveImageSelector.h"
 #include "mozilla/dom/MediaList.h"
 #include "mozilla/dom/MediaSource.h"
 
 #include "nsGkAtoms.h"
 
-#include "nsHostObjectProtocolHandler.h"
-
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/Preferences.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Source)
 
 namespace mozilla {
 namespace dom {
 
 HTMLSourceElement::HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -157,17 +157,17 @@
 
 #include "nsChromeRegistryContent.h"
 #include "nsFrameMessageManager.h"
 
 #include "nsIGeolocationProvider.h"
 #include "mozilla/dom/PCycleCollectWithLogsChild.h"
 
 #include "nsIScriptSecurityManager.h"
-#include "nsHostObjectProtocolHandler.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 
 #ifdef MOZ_WEBRTC
 #include "signaling/src/peerconnection/WebrtcGlobalChild.h"
 #endif
 
 #include "nsPermission.h"
 #include "nsPermissionManager.h"
 
@@ -2362,17 +2362,17 @@ ContentChild::ActorDestroy(ActorDestroyR
   // keep persistent state.
   ProcessChild::QuickExit();
 #else
   if (gFirstIdleTask) {
     gFirstIdleTask->Cancel();
     gFirstIdleTask = nullptr;
   }
 
-  nsHostObjectProtocolHandler::RemoveDataEntries();
+  BlobURLProtocolHandler::RemoveDataEntries();
 
   mAlertObservers.Clear();
 
   mIdleObservers.Clear();
 
   nsCOMPtr<nsIConsoleService> svc(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
   if (svc) {
     svc->UnregisterListener(mConsoleListener);
@@ -2760,25 +2760,24 @@ ContentChild::RecvInitServiceWorkers(con
 mozilla::ipc::IPCResult
 ContentChild::RecvInitBlobURLs(nsTArray<BlobURLRegistrationData>&& aRegistrations)
 {
   for (uint32_t i = 0; i < aRegistrations.Length(); ++i) {
     BlobURLRegistrationData& registration = aRegistrations[i];
     RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(registration.blob());
     MOZ_ASSERT(blobImpl);
 
-    nsHostObjectProtocolHandler::AddDataEntry(registration.url(),
-                                              registration.principal(),
-                                              blobImpl);
+    BlobURLProtocolHandler::AddDataEntry(registration.url(),
+                                         registration.principal(),
+                                         blobImpl);
     // If we have received an already-revoked blobURL, we have to keep it alive
-    // for a while (see nsHostObjectProtocolHandler) in order to support pending
+    // for a while (see BlobURLProtocolHandler) in order to support pending
     // operations such as navigation, download and so on.
     if (registration.revoked()) {
-      nsHostObjectProtocolHandler::RemoveDataEntry(registration.url(),
-                                                   false);
+      BlobURLProtocolHandler::RemoveDataEntry(registration.url(), false);
     }
   }
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvLastPrivateDocShellDestroyed()
@@ -3359,25 +3358,25 @@ ContentChild::RecvNotifyPushSubscription
 mozilla::ipc::IPCResult
 ContentChild::RecvBlobURLRegistration(const nsCString& aURI,
                                       const IPCBlob& aBlob,
                                       const IPC::Principal& aPrincipal)
 {
   RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(aBlob);
   MOZ_ASSERT(blobImpl);
 
-  nsHostObjectProtocolHandler::AddDataEntry(aURI, aPrincipal, blobImpl);
+  BlobURLProtocolHandler::AddDataEntry(aURI, aPrincipal, blobImpl);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvBlobURLUnregistration(const nsCString& aURI)
 {
-  nsHostObjectProtocolHandler::RemoveDataEntry(aURI,
-                                               /* aBroadcastToOtherProcesses = */ false);
+  BlobURLProtocolHandler::RemoveDataEntry(aURI,
+                                          /* aBroadcastToOtherProcesses = */ false);
   return IPC_OK();
 }
 
 #if defined(XP_WIN) && defined(ACCESSIBILITY)
 bool
 ContentChild::SendGetA11yContentId()
 {
   return PContentChild::SendGetA11yContentId(&mMsaaID);
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -179,25 +179,25 @@
 #include "nsDocShell.h"
 #include "nsOpenURIInFrameParams.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "gfxPlatform.h"
 #include "gfxPrefs.h"
 #include "prio.h"
 #include "private/pprio.h"
 #include "ContentProcessManager.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
 #include "mozilla/PerformanceUtils.h"
 #include "mozilla/psm/PSMContentListener.h"
 #include "nsPluginHost.h"
 #include "nsPluginTags.h"
 #include "nsIBlocklistService.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsICaptivePortalService.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsIBidiKeyboard.h"
 #include "nsLayoutStylesheetCache.h"
 
 #include "mozilla/Sprintf.h"
 
 #ifdef MOZ_WEBRTC
@@ -1797,17 +1797,17 @@ ContentParent::ActorDestroy(ActorDestroy
   cpm->RemoveContentProcess(this->ChildID());
 
   if (mDriverCrashGuard) {
     mDriverCrashGuard->NotifyCrashed();
   }
 
   // Unregister all the BlobURLs registered by the ContentChild.
   for (uint32_t i = 0; i < mBlobURLs.Length(); ++i) {
-    nsHostObjectProtocolHandler::RemoveDataEntry(mBlobURLs[i]);
+    BlobURLProtocolHandler::RemoveDataEntry(mBlobURLs[i]);
   }
 
   mBlobURLs.Clear();
 
 #if defined(XP_WIN32) && defined(ACCESSIBILITY)
   a11y::AccessibleWrap::ReleaseContentProcessIdFor(ChildID());
 #endif
 }
@@ -2463,18 +2463,17 @@ ContentParent::InitInternal(ProcessPrior
       }
     }
 
     Unused << SendInitServiceWorkers(ServiceWorkerConfiguration(registrations));
   }
 
   {
     nsTArray<BlobURLRegistrationData> registrations;
-    if (nsHostObjectProtocolHandler::GetAllBlobURLEntries(registrations,
-                                                          this)) {
+    if (BlobURLProtocolHandler::GetAllBlobURLEntries(registrations, this)) {
       for (const BlobURLRegistrationData& registration : registrations) {
         nsresult rv = TransmitPermissionsForPrincipal(registration.principal());
         Unused << NS_WARN_IF(NS_FAILED(rv));
       }
 
       Unused << SendInitBlobURLs(registrations);
     }
   }
@@ -5187,34 +5186,33 @@ ContentParent::RecvStoreAndBroadcastBlob
                                                         const IPCBlob& aBlob,
                                                         const Principal& aPrincipal)
 {
   RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(aBlob);
   if (NS_WARN_IF(!blobImpl)) {
     return IPC_FAIL_NO_REASON(this);
   }
 
-  if (NS_SUCCEEDED(nsHostObjectProtocolHandler::AddDataEntry(aURI, aPrincipal,
-                                                             blobImpl))) {
+  if (NS_SUCCEEDED(BlobURLProtocolHandler::AddDataEntry(aURI, aPrincipal,
+                                                        blobImpl))) {
     BroadcastBlobURLRegistration(aURI, blobImpl, aPrincipal, this);
 
     // We want to store this blobURL, so we can unregister it if the child
     // crashes.
     mBlobURLs.AppendElement(aURI);
   }
 
   BroadcastBlobURLRegistration(aURI, blobImpl, aPrincipal, this);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvUnstoreAndBroadcastBlobURLUnregistration(const nsCString& aURI)
 {
-  nsHostObjectProtocolHandler::RemoveDataEntry(aURI,
-                                               false /* Don't broadcast */);
+  BlobURLProtocolHandler::RemoveDataEntry(aURI, false /* Don't broadcast */);
   BroadcastBlobURLUnregistration(aURI, this);
   mBlobURLs.RemoveElement(aURI);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentParent::RecvGetA11yContentId(uint32_t* aContentId)
--- a/dom/media/BaseMediaResource.cpp
+++ b/dom/media/BaseMediaResource.cpp
@@ -1,19 +1,19 @@
 #include "BaseMediaResource.h"
 
 #include "ChannelMediaResource.h"
 #include "CloneableWithRangeMediaResource.h"
 #include "FileMediaResource.h"
 #include "MediaContainerType.h"
 #include "mozilla/dom/BlobImpl.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "nsDebug.h"
 #include "nsError.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsICloneableInputStream.h"
 #include "nsIFile.h"
 #include "nsIFileChannel.h"
 #include "nsIInputStream.h"
 #include "nsISeekableStream.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
@@ -45,17 +45,17 @@ BaseMediaResource::Create(MediaResourceC
   nsCOMPtr<nsIFileChannel> fc = do_QueryInterface(aChannel);
   if (fc) {
     RefPtr<BaseMediaResource> resource =
       new FileMediaResource(aCallback, aChannel, uri);
     return resource.forget();
   }
 
   RefPtr<mozilla::dom::BlobImpl> blobImpl;
-  if (IsBlobURI(uri) &&
+  if (dom::IsBlobURI(uri) &&
       NS_SUCCEEDED(NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl))) &&
       blobImpl) {
     IgnoredErrorResult rv;
 
     nsCOMPtr<nsIInputStream> stream;
     blobImpl->CreateInputStream(getter_AddRefs(stream), rv);
     if (NS_WARN_IF(rv.Failed())) {
       return nullptr;
--- a/dom/media/FileMediaResource.cpp
+++ b/dom/media/FileMediaResource.cpp
@@ -2,18 +2,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "FileMediaResource.h"
 
 #include "mozilla/AbstractThread.h"
 #include "mozilla/dom/BlobImpl.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "nsContentUtils.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsIFileChannel.h"
 #include "nsIFileStreams.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 
 void
 FileMediaResource::EnsureSizeInitialized()
@@ -72,17 +72,17 @@ FileMediaResource::Open(nsIStreamListene
   if (fc) {
     nsCOMPtr<nsIFile> file;
     rv = fc->GetFile(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = NS_NewLocalFileInputStream(
       getter_AddRefs(mInput), file, -1, -1, nsIFileInputStream::SHARE_DELETE);
     NS_ENSURE_SUCCESS(rv, rv);
-  } else if (IsBlobURI(mURI)) {
+  } else if (dom::IsBlobURI(mURI)) {
     RefPtr<dom::BlobImpl> blobImpl;
     rv = NS_GetBlobForBlobURI(mURI, getter_AddRefs(blobImpl));
     NS_ENSURE_SUCCESS(rv, rv);
     MOZ_ASSERT(blobImpl);
 
     ErrorResult err;
     blobImpl->CreateInputStream(getter_AddRefs(mInput), err);
     if (NS_WARN_IF(err.Failed())) {
--- a/dom/url/URLMainThread.cpp
+++ b/dom/url/URLMainThread.cpp
@@ -3,19 +3,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "URLMainThread.h"
 
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Blob.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/Unused.h"
 #include "nsContentUtils.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsIURL.h"
 #include "nsIURIMutator.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 namespace dom {
 
 /* static */ already_AddRefed<URLMainThread>
@@ -78,17 +78,17 @@ URLMainThread::CreateObjectURL(const Glo
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   nsCOMPtr<nsIPrincipal> principal =
     nsContentUtils::ObjectPrincipal(aGlobal.Get());
 
   nsAutoCString url;
-  aRv = nsHostObjectProtocolHandler::AddDataEntry(aBlob.Impl(), principal, url);
+  aRv = BlobURLProtocolHandler::AddDataEntry(aBlob.Impl(), principal, url);
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   global->RegisterHostObjectURI(url);
   CopyASCIItoUTF16(url, aResult);
 }
 
@@ -98,24 +98,24 @@ URLMainThread::CreateObjectURL(const Glo
                                nsAString& aResult, ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsCOMPtr<nsIPrincipal> principal =
     nsContentUtils::ObjectPrincipal(aGlobal.Get());
 
   nsAutoCString url;
-  aRv = nsHostObjectProtocolHandler::AddDataEntry(&aSource, principal, url);
+  aRv = BlobURLProtocolHandler::AddDataEntry(&aSource, principal, url);
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   nsCOMPtr<nsIRunnable> revocation =
     NS_NewRunnableFunction("dom::URLMainThread::CreateObjectURL", [url] {
-      nsHostObjectProtocolHandler::RemoveDataEntry(url);
+      BlobURLProtocolHandler::RemoveDataEntry(url);
     });
 
   nsContentUtils::RunInStableState(revocation.forget());
 
   CopyASCIItoUTF16(url, aResult);
 }
 
 /* static */ void
@@ -129,21 +129,21 @@ URLMainThread::RevokeObjectURL(const Glo
     return;
   }
 
   nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal.Get());
 
   NS_LossyConvertUTF16toASCII asciiurl(aURL);
 
   nsIPrincipal* urlPrincipal =
-    nsHostObjectProtocolHandler::GetDataEntryPrincipal(asciiurl);
+    BlobURLProtocolHandler::GetDataEntryPrincipal(asciiurl);
 
   if (urlPrincipal && principal->Subsumes(urlPrincipal)) {
     global->UnregisterHostObjectURI(asciiurl);
-    nsHostObjectProtocolHandler::RemoveDataEntry(asciiurl);
+    BlobURLProtocolHandler::RemoveDataEntry(asciiurl);
   }
 }
 
 URLMainThread::URLMainThread(nsISupports* aParent)
   : URL(aParent)
 {
   MOZ_ASSERT(NS_IsMainThread());
 }
@@ -154,17 +154,17 @@ URLMainThread::~URLMainThread()
 }
 
 /* static */ bool
 URLMainThread::IsValidURL(const GlobalObject& aGlobal, const nsAString& aURL,
                           ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_LossyConvertUTF16toASCII asciiurl(aURL);
-  return nsHostObjectProtocolHandler::HasDataEntry(asciiurl);
+  return BlobURLProtocolHandler::HasDataEntry(asciiurl);
 }
 
 void
 URLMainThread::SetHref(const nsAString& aHref, ErrorResult& aRv)
 {
   NS_ConvertUTF16toUTF8 href(aHref);
 
   nsresult rv;
--- a/dom/url/URLWorker.cpp
+++ b/dom/url/URLWorker.cpp
@@ -2,21 +2,21 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "URLWorker.h"
 
 #include "mozilla/dom/Blob.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/WorkerPrivate.h"
 #include "mozilla/dom/WorkerRunnable.h"
 #include "mozilla/dom/WorkerScope.h"
 #include "mozilla/Unused.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsProxyRelease.h"
 #include "nsStandardURL.h"
 #include "nsURLHelper.h"
 
 namespace mozilla {
 
 using net::nsStandardURL;
 
@@ -54,17 +54,17 @@ public:
     DebugOnly<bool> isMutable;
     MOZ_ASSERT(NS_SUCCEEDED(mBlobImpl->GetMutable(&isMutable)));
     MOZ_ASSERT(!isMutable);
 
     nsCOMPtr<nsIPrincipal> principal = mWorkerPrivate->GetPrincipal();
 
     nsAutoCString url;
     nsresult rv =
-      nsHostObjectProtocolHandler::AddDataEntry(mBlobImpl, principal, url);
+      BlobURLProtocolHandler::AddDataEntry(mBlobImpl, principal, url);
 
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to add data entry for the blob!");
       SetDOMStringToNull(mURL);
       return false;
     }
 
     if (!mWorkerPrivate->IsSharedWorker() &&
@@ -107,25 +107,25 @@ public:
   bool
   MainThreadRun() override
   {
     AssertIsOnMainThread();
 
     NS_ConvertUTF16toUTF8 url(mURL);
 
     nsIPrincipal* urlPrincipal =
-      nsHostObjectProtocolHandler::GetDataEntryPrincipal(url);
+      BlobURLProtocolHandler::GetDataEntryPrincipal(url);
 
     nsCOMPtr<nsIPrincipal> principal = mWorkerPrivate->GetPrincipal();
 
     bool subsumes;
     if (urlPrincipal &&
         NS_SUCCEEDED(principal->Subsumes(urlPrincipal, &subsumes)) &&
         subsumes) {
-      nsHostObjectProtocolHandler::RemoveDataEntry(url);
+      BlobURLProtocolHandler::RemoveDataEntry(url);
     }
 
     if (!mWorkerPrivate->IsSharedWorker() &&
         !mWorkerPrivate->IsServiceWorker()) {
       // Walk up to top worker object.
       WorkerPrivate* wp = mWorkerPrivate;
       while (WorkerPrivate* parent = wp->GetParent()) {
         wp = parent;
@@ -162,17 +162,17 @@ public:
   {}
 
   bool
   MainThreadRun() override
   {
     AssertIsOnMainThread();
 
     NS_ConvertUTF16toUTF8 url(mURL);
-    mValid = nsHostObjectProtocolHandler::HasDataEntry(url);
+    mValid = BlobURLProtocolHandler::HasDataEntry(url);
 
     return true;
   }
 
   bool
   IsValidURL() const
   {
     return mValid;
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -24,33 +24,33 @@
 #include "nsIURI.h"
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "nsError.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentUtils.h"
 #include "nsDocShellCID.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsISupportsPrimitives.h"
 #include "nsNetUtil.h"
 #include "nsIPipe.h"
 #include "nsIOutputStream.h"
 #include "nsPrintfCString.h"
 #include "nsString.h"
 #include "nsStreamUtils.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "xpcpublic.h"
 
 #include "mozilla/Assertions.h"
 #include "mozilla/LoadContext.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/ipc/BackgroundUtils.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/CacheBinding.h"
 #include "mozilla/dom/cache/CacheTypes.h"
 #include "mozilla/dom/cache/Cache.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/ChannelInfo.h"
 #include "mozilla/dom/ClientChannelHelper.h"
 #include "mozilla/dom/ClientInfo.h"
 #include "mozilla/dom/Exceptions.h"
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -17,20 +17,20 @@
 #include "nsNetUtil.h"
 #include "NullPrincipal.h"
 #include "nsIInputStream.h"
 #include "nsStringStream.h"
 #include "nsStreamUtils.h"
 #include "nsIPrincipal.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/FontTableURIProtocolHandler.h"
 #include "mozilla/dom/SVGDocument.h"
 #include "mozilla/LoadInfo.h"
 #include "nsSVGUtils.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsContentUtils.h"
 #include "gfxFont.h"
 #include "nsSMILAnimationController.h"
 #include "gfxContext.h"
 #include "harfbuzz/hb.h"
 #include "mozilla/dom/ImageTracker.h"
 
 #define SVG_CONTENT_TYPE NS_LITERAL_CSTRING("image/svg+xml")
@@ -346,19 +346,17 @@ gfxSVGGlyphsDocument::ParseDocument(cons
 {
     // Mostly pulled from nsDOMParser::ParseFromStream
 
     nsCOMPtr<nsIInputStream> stream;
     nsresult rv = CreateBufferedStream(aBuffer, aBufLen, stream);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIURI> uri;
-    nsHostObjectProtocolHandler::GenerateURIString(NS_LITERAL_CSTRING(FONTTABLEURI_SCHEME),
-                                                   nullptr,
-                                                   mSVGGlyphsDocumentURI);
+    mozilla::dom::FontTableURIProtocolHandler::GenerateURIString(mSVGGlyphsDocumentURI);
 
     rv = NS_NewURI(getter_AddRefs(uri), mSVGGlyphsDocumentURI);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsIPrincipal> principal = NullPrincipal::CreateWithoutOriginAttributes();
 
     nsCOMPtr<nsIDocument> document;
     rv = NS_NewDOMDocument(getter_AddRefs(document),
--- a/image/ImageCacheKey.cpp
+++ b/image/ImageCacheKey.cpp
@@ -2,19 +2,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ImageCacheKey.h"
 
 #include "mozilla/Move.h"
 #include "ImageURL.h"
-#include "nsHostObjectProtocolHandler.h"
 #include "nsLayoutUtils.h"
 #include "nsString.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ServiceWorkerManager.h"
 #include "nsIDocument.h"
 #include "nsPrintfCString.h"
 
 namespace mozilla {
 
 using namespace dom;
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -26,17 +26,17 @@
 #include <mmsystem.h>
 #include "WinUtils.h"
 #endif
 
 #include "mozilla/AnimationEventDispatcher.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/IntegerRange.h"
-#include "nsHostObjectProtocolHandler.h"
+#include "mozilla/dom/FontTableURIProtocolHandler.h"
 #include "nsITimer.h"
 #include "nsLayoutUtils.h"
 #include "nsPresContext.h"
 #include "nsComponentManagerUtils.h"
 #include "mozilla/Logging.h"
 #include "nsAutoPtr.h"
 #include "nsIDocument.h"
 #include "nsIXULRuntime.h"
@@ -1342,17 +1342,17 @@ nsRefreshDriver::EnsureTimerStarted(Ensu
     return;
   }
 
   if (mPresContext->Document()->IsBeingUsedAsImage()) {
     // Image documents receive ticks from clients' refresh drivers.
     // XXXdholbert Exclude SVG-in-opentype fonts from this optimization, until
     // they receive refresh-driver ticks from their client docs (bug 1107252).
     nsIURI* uri = mPresContext->Document()->GetDocumentURI();
-    if (!uri || !IsFontTableURI(uri)) {
+    if (!uri || !mozilla::dom::IsFontTableURI(uri)) {
       MOZ_ASSERT(!mActiveTimer,
                  "image doc refresh driver should never have its own timer");
       return;
     }
   }
 
   // We got here because we're either adjusting the time *or* we're
   // starting it for the first time.  Add to the right timer,
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -104,17 +104,17 @@
 #include "DecoderDoctorLogger.h"
 #include "MediaDecoder.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StaticPresData.h"
 #include "mozilla/dom/WebIDLGlobalNameHash.h"
 #include "mozilla/dom/ipc/IPCBlobInputStreamStorage.h"
 #include "mozilla/dom/U2FTokenManager.h"
 #include "mozilla/dom/PointerEventHandler.h"
-#include "nsHostObjectProtocolHandler.h"
+#include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "nsThreadManager.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 using namespace mozilla::dom;
 using namespace mozilla::dom::ipc;
 
 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
@@ -387,10 +387,10 @@ nsLayoutStatics::Shutdown()
   ContentParent::ShutDown();
 
   DisplayItemClip::Shutdown();
 
   CacheObserver::Shutdown();
 
   PromiseDebugging::Shutdown();
 
-  nsHostObjectProtocolHandler::RemoveDataEntries();
+  BlobURLProtocolHandler::RemoveDataEntries();
 }