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.

--HG--
rename : dom/file/nsHostObjectProtocolHandler.cpp => dom/file/BlobURLProtocolHandler.cpp
rename : dom/file/nsHostObjectProtocolHandler.h => dom/file/BlobURLProtocolHandler.h
This commit is contained in:
Andrea Marchesini 2018-06-02 15:51:42 +02:00
Родитель 426e4b7015
Коммит 7ba8b77e07
26 изменённых файлов: 351 добавлений и 267 удалений

Просмотреть файл

@ -37,6 +37,7 @@
#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"
@ -49,6 +50,7 @@
#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"
@ -111,7 +113,6 @@
#include "nsGenericHTMLElement.h"
#include "nsGenericHTMLFrameElement.h"
#include "nsGkAtoms.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsHtml5Module.h"
#include "nsHtml5StringParser.h"
#include "nsHTMLDocument.h"

Просмотреть файл

@ -127,7 +127,7 @@
#include "nsBindingManager.h"
#include "nsHTMLDocument.h"
#include "nsIRequest.h"
#include "nsHostObjectProtocolHandler.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "nsCharsetSource.h"
#include "nsIParser.h"

Просмотреть файл

@ -6,11 +6,11 @@
#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;
@ -67,7 +67,7 @@ public:
MOZ_ASSERT(NS_IsMainThread());
for (uint32_t index = 0; index < mURIs.Length(); ++index) {
nsHostObjectProtocolHandler::RemoveDataEntry(mURIs[index]);
BlobURLProtocolHandler::RemoveDataEntry(mURIs[index]);
}
return NS_OK;
@ -90,14 +90,14 @@ nsIGlobalObject::UnlinkHostObjectURIs()
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);
@ -123,7 +123,7 @@ nsIGlobalObject::TraverseHostObjectURIs(nsCycleCollectionTraversalCallback &aCb)
}
for (uint32_t index = 0; index < mHostObjectURIs.Length(); ++index) {
nsHostObjectProtocolHandler::Traverse(mHostObjectURIs[index], aCb);
BlobURLProtocolHandler::Traverse(mHostObjectURIs[index], aCb);
}
}

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsContentPolicyUtils.h"
#include "nsDataHandler.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsNetUtil.h"
#include "nsPrintfCString.h"
#include "nsProxyRelease.h"
@ -30,6 +29,7 @@
#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"

Просмотреть файл

@ -4,7 +4,7 @@
* 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"
@ -31,9 +31,11 @@
#define RELEASING_TIMER 5000
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::ipc;
namespace mozilla {
using namespace ipc;
namespace dom {
// -----------------------------------------------------------------------
// Hash table
@ -126,8 +128,6 @@ GetDataInfoFromURI(nsIURI* aURI, bool aAlsoIfRevoked = false)
}
// Memory reporting for the hash table.
namespace mozilla {
void
BroadcastBlobURLRegistration(const nsACString& aURI,
BlobImpl* aBlobImpl,
@ -168,28 +168,6 @@ BroadcastBlobURLUnregistration(const nsCString& aURI)
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:
@ -434,7 +412,7 @@ public:
RefPtr<ReleasingTimerHolder> holder =
new ReleasingTimerHolder(aURI, aBroadcastToOtherProcesses);
auto raii = mozilla::MakeScopeExit([holder] {
auto raii = MakeScopeExit([holder] {
holder->CancelTimerAndRevokeURI();
});
@ -451,7 +429,7 @@ public:
Run() override
{
RefPtr<ReleasingTimerHolder> self = this;
auto raii = mozilla::MakeScopeExit([self] {
auto raii = MakeScopeExit([self] {
self->CancelTimerAndRevokeURI();
});
@ -580,8 +558,6 @@ private:
NS_IMPL_ISUPPORTS_INHERITED(ReleasingTimerHolder, Runnable, nsITimerCallback,
nsIAsyncShutdownBlocker)
} // namespace mozilla
template<typename T>
static nsresult
AddDataEntryInternal(const nsACString& aURI, T aObject,
@ -592,33 +568,34 @@ AddDataEntryInternal(const nsACString& aURI, T aObject,
}
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();
@ -633,9 +610,9 @@ nsHostObjectProtocolHandler::AddDataEntry(BlobImpl* aBlobImpl,
}
/* static */ nsresult
nsHostObjectProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
nsIPrincipal* aPrincipal,
nsACString& aUri)
BlobURLProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
nsIPrincipal* aPrincipal,
nsACString& aUri)
{
Init();
@ -649,17 +626,16 @@ nsHostObjectProtocolHandler::AddDataEntry(MediaSource* aMediaSource,
}
/* 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);
@ -692,8 +668,8 @@ nsHostObjectProtocolHandler::GetAllBlobURLEntries(
}
/*static */ void
nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri,
bool aBroadcastToOtherProcesses)
BlobURLProtocolHandler::RemoveDataEntry(const nsACString& aUri,
bool aBroadcastToOtherProcesses)
{
if (!gDataTable) {
return;
@ -715,7 +691,7 @@ nsHostObjectProtocolHandler::RemoveDataEntry(const nsACString& aUri,
}
/* static */ void
nsHostObjectProtocolHandler::RemoveDataEntries()
BlobURLProtocolHandler::RemoveDataEntries()
{
if (!gDataTable) {
return;
@ -727,15 +703,15 @@ nsHostObjectProtocolHandler::RemoveDataEntries()
}
/* 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 =
@ -769,15 +745,15 @@ nsHostObjectProtocolHandler::GenerateURIString(const nsACString &aScheme,
}
/* 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;
@ -793,8 +769,8 @@ nsHostObjectProtocolHandler::GetDataEntryPrincipal(const nsACString& aUri)
}
/* static */ void
nsHostObjectProtocolHandler::Traverse(const nsACString& aUri,
nsCycleCollectionTraversalCallback& aCallback)
BlobURLProtocolHandler::Traverse(const nsACString& aUri,
nsCycleCollectionTraversalCallback& aCallback)
{
if (!gDataTable) {
return;
@ -806,39 +782,36 @@ nsHostObjectProtocolHandler::Traverse(const nsACString& aUri,
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;
}
@ -846,18 +819,10 @@ nsHostObjectProtocolHandler::GetFlagsForURI(nsIURI *aURI, uint32_t *aResult)
}
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;
@ -865,7 +830,7 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec,
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;
@ -885,9 +850,9 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec,
}
NS_IMETHODIMP
nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
BlobURLProtocolHandler::NewChannel2(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
{
*result = nullptr;
@ -970,14 +935,14 @@ nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
}
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;
@ -985,26 +950,14 @@ nsHostObjectProtocolHandler::AllowPort(int32_t port, const char *scheme,
}
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)
@ -1036,42 +989,6 @@ NS_GetBlobForBlobURISpec(const nsACString& aSpec, BlobImpl** 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)
{
@ -1087,39 +1004,34 @@ NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** 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)
{
@ -1140,3 +1052,6 @@ bool IsMediaSourceURI(nsIURI* aUri)
{
return IsType(aUri, DataInfo::eMediaSource);
}
} // dom namespace
} // mozilla namespace

Просмотреть файл

@ -4,8 +4,8 @@
* 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"
@ -16,7 +16,6 @@
#include "nsWeakReference.h"
#define BLOBURI_SCHEME "blob"
#define FONTTABLEURI_SCHEME "moz-fonttable"
#define RTSPURI_SCHEME "rtsp"
class nsIPrincipal;
@ -25,32 +24,22 @@ 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,
@ -86,31 +75,12 @@ public:
GetAllBlobURLEntries(nsTArray<mozilla::dom::BlobURLRegistrationData>& aRegistrations,
mozilla::dom::ContentParent* aCP);
protected:
virtual ~nsHostObjectProtocolHandler() {}
private:
~BlobURLProtocolHandler();
static void Init();
};
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;
};
bool IsBlobURI(nsIURI* aUri);
bool IsMediaSourceURI(nsIURI* aUri);
@ -120,11 +90,8 @@ inline bool IsRtspURI(nsIURI* aUri)
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);
@ -135,4 +102,4 @@ 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 */

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 */

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/RefPtr.h"
#include "mozilla/Mutex.h"
#include "nsCOMPtr.h"
#include "prio.h"
class nsIEventTarget;

Просмотреть файл

@ -6,6 +6,8 @@
#include "MutableBlobStreamListener.h"
#include "MutableBlobStorage.h"
#include "nsIInputStream.h"
#include "nsThreadUtils.h"
namespace mozilla {
namespace dom {

Просмотреть файл

@ -4,7 +4,10 @@
* 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"

Просмотреть файл

@ -10,7 +10,6 @@ with Files("**"):
DIRS += ['ipc']
EXPORTS += [
'nsHostObjectProtocolHandler.h',
'nsHostObjectURI.h',
]
@ -19,12 +18,14 @@ EXPORTS.mozilla.dom += [
'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',
@ -37,6 +38,7 @@ UNIFIED_SOURCES += [
'Blob.cpp',
'BlobImpl.cpp',
'BlobSet.cpp',
'BlobURLProtocolHandler.cpp',
'EmptyBlobImpl.cpp',
'File.cpp',
'FileBlobImpl.cpp',
@ -44,11 +46,11 @@ UNIFIED_SOURCES += [
'FileList.cpp',
'FileReader.cpp',
'FileReaderSync.cpp',
'FontTableURIProtocolHandler.cpp',
'MemoryBlobImpl.cpp',
'MultipartBlobImpl.cpp',
'MutableBlobStorage.cpp',
'MutableBlobStreamListener.cpp',
'nsHostObjectProtocolHandler.cpp',
'nsHostObjectURI.cpp',
'StreamBlobImpl.cpp',
'StringBlobImpl.cpp',

Просмотреть файл

@ -8,8 +8,8 @@
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsHostObjectProtocolHandler.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/URIUtils.h"

Просмотреть файл

@ -58,6 +58,7 @@
#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"
@ -84,7 +85,6 @@
#include "nsError.h"
#include "nsGenericHTMLElement.h"
#include "nsGkAtoms.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsICachingChannel.h"
#include "nsICategoryManager.h"

Просмотреть файл

@ -15,8 +15,7 @@
#include "nsGkAtoms.h"
#include "nsHostObjectProtocolHandler.h"
#include "mozilla/dom/BlobURLProtocolHandler.h"
#include "mozilla/Preferences.h"
NS_IMPL_NS_NEW_HTML_ELEMENT(Source)

Просмотреть файл

@ -162,7 +162,7 @@
#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"
@ -2367,7 +2367,7 @@ ContentChild::ActorDestroy(ActorDestroyReason why)
gFirstIdleTask = nullptr;
}
nsHostObjectProtocolHandler::RemoveDataEntries();
BlobURLProtocolHandler::RemoveDataEntries();
mAlertObservers.Clear();
@ -2765,15 +2765,14 @@ ContentChild::RecvInitBlobURLs(nsTArray<BlobURLRegistrationData>&& aRegistration
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);
}
}
@ -3364,15 +3363,15 @@ ContentChild::RecvBlobURLRegistration(const nsCString& aURI,
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();
}

Просмотреть файл

@ -184,6 +184,7 @@
#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"
@ -192,7 +193,6 @@
#include "nsIBlocklistService.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsICaptivePortalService.h"
#include "nsIObjectLoadingContent.h"
#include "nsIBidiKeyboard.h"
@ -1802,7 +1802,7 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
// 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();
@ -2468,8 +2468,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority)
{
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));
@ -5192,8 +5191,8 @@ ContentParent::RecvStoreAndBroadcastBlobURLRegistration(const nsCString& aURI,
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
@ -5208,8 +5207,7 @@ ContentParent::RecvStoreAndBroadcastBlobURLRegistration(const nsCString& aURI,
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);

Просмотреть файл

@ -5,10 +5,10 @@
#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"
@ -50,7 +50,7 @@ BaseMediaResource::Create(MediaResourceCallback* aCallback,
}
RefPtr<mozilla::dom::BlobImpl> blobImpl;
if (IsBlobURI(uri) &&
if (dom::IsBlobURI(uri) &&
NS_SUCCEEDED(NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl))) &&
blobImpl) {
IgnoredErrorResult rv;

Просмотреть файл

@ -7,8 +7,8 @@
#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"
@ -77,7 +77,7 @@ FileMediaResource::Open(nsIStreamListener** aStreamListener)
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);

Просмотреть файл

@ -8,9 +8,9 @@
#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"
@ -83,7 +83,7 @@ URLMainThread::CreateObjectURL(const GlobalObject& aGlobal, Blob& aBlob,
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;
}
@ -103,14 +103,14 @@ URLMainThread::CreateObjectURL(const GlobalObject& aGlobal,
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());
@ -134,11 +134,11 @@ URLMainThread::RevokeObjectURL(const GlobalObject& aGlobal,
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);
}
}
@ -159,7 +159,7 @@ URLMainThread::IsValidURL(const GlobalObject& aGlobal, const nsAString& aURL,
{
MOZ_ASSERT(NS_IsMainThread());
NS_LossyConvertUTF16toASCII asciiurl(aURL);
return nsHostObjectProtocolHandler::HasDataEntry(asciiurl);
return BlobURLProtocolHandler::HasDataEntry(asciiurl);
}
void

Просмотреть файл

@ -7,11 +7,11 @@
#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"
@ -59,7 +59,7 @@ public:
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!");
@ -112,7 +112,7 @@ public:
NS_ConvertUTF16toUTF8 url(mURL);
nsIPrincipal* urlPrincipal =
nsHostObjectProtocolHandler::GetDataEntryPrincipal(url);
BlobURLProtocolHandler::GetDataEntryPrincipal(url);
nsCOMPtr<nsIPrincipal> principal = mWorkerPrivate->GetPrincipal();
@ -120,7 +120,7 @@ public:
if (urlPrincipal &&
NS_SUCCEEDED(principal->Subsumes(urlPrincipal, &subsumes)) &&
subsumes) {
nsHostObjectProtocolHandler::RemoveDataEntry(url);
BlobURLProtocolHandler::RemoveDataEntry(url);
}
if (!mWorkerPrivate->IsSharedWorker() &&
@ -167,7 +167,7 @@ public:
AssertIsOnMainThread();
NS_ConvertUTF16toUTF8 url(mURL);
mValid = nsHostObjectProtocolHandler::HasDataEntry(url);
mValid = BlobURLProtocolHandler::HasDataEntry(url);
return true;
}

Просмотреть файл

@ -29,7 +29,6 @@
#include "nsContentPolicyUtils.h"
#include "nsContentUtils.h"
#include "nsDocShellCID.h"
#include "nsHostObjectProtocolHandler.h"
#include "nsISupportsPrimitives.h"
#include "nsNetUtil.h"
#include "nsIPipe.h"
@ -46,6 +45,7 @@
#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"

Просмотреть файл

@ -22,10 +22,10 @@
#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"
@ -351,9 +351,7 @@ gfxSVGGlyphsDocument::ParseDocument(const uint8_t *aBuffer, uint32_t aBufLen)
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);

Просмотреть файл

@ -7,9 +7,9 @@
#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"

Просмотреть файл

@ -31,7 +31,7 @@
#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"
@ -1347,7 +1347,7 @@ nsRefreshDriver::EnsureTimerStarted(EnsureTimerStartedFlags aFlags)
// 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;

Просмотреть файл

@ -109,7 +109,7 @@
#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;
@ -392,5 +392,5 @@ nsLayoutStatics::Shutdown()
PromiseDebugging::Shutdown();
nsHostObjectProtocolHandler::RemoveDataEntries();
BlobURLProtocolHandler::RemoveDataEntries();
}