Bug 1671641 - Make `dom/file` buildable outside of `unified-build` environment. r=sg

Differential Revision: https://phabricator.services.mozilla.com/D94082
This commit is contained in:
Andi-Bogdan Postelnicu 2020-10-21 20:58:07 +00:00
Родитель 5b66b078c2
Коммит 83bf4bc5a3
17 изменённых файлов: 119 добавлений и 81 удалений

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

@ -18,6 +18,7 @@ dom/docs/
dom/encoding/
dom/events/
dom/fetch/
dom/file/
dom/indexedDB/
dom/localstorage/
dom/quota/

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

@ -9,6 +9,7 @@
#include "mozilla/dom/File.h"
#include "MemoryBlobImpl.h"
#include "MultipartBlobImpl.h"
#include "StringBlobImpl.h"
namespace mozilla {
namespace dom {

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

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "FileBlobImpl.h"
#include "BaseBlobImpl.h"
#include "mozilla/SlicedInputStream.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h"

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

@ -26,6 +26,7 @@
#include "nsDOMJSUtils.h"
#include "nsError.h"
#include "nsNetUtil.h"
#include "nsStreamUtils.h"
#include "xpcpublic.h"
#include "nsReadableUtils.h"

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

@ -7,7 +7,11 @@
#include "MemoryBlobImpl.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SHA1.h"
#include "nsMemory.h"
#include "nsPrintfCString.h"
#include "nsRFPService.h"
#include "nsStringStream.h"
#include "prtime.h"
namespace mozilla {
namespace dom {

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

@ -9,6 +9,7 @@
#include <utility>
#include "Blob.h"
#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/Maybe.h"

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

@ -9,6 +9,7 @@
#include "nsIStreamListener.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsTString.h"
#include "mozilla/dom/MutableBlobStorage.h"
class nsIEventTarget;

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

@ -67,7 +67,7 @@ RemoteLazyInputStreamParent::Create<mozilla::ipc::PBackgroundParent>(
/* static */
already_AddRefed<RemoteLazyInputStreamParent>
RemoteLazyInputStreamParent::Create(const nsID& aID, uint64_t aSize,
SocketProcessParent* aManager) {
net::SocketProcessParent* aManager) {
RefPtr<RemoteLazyInputStreamParent> actor =
new RemoteLazyInputStreamParent(aID, aSize, aManager);
@ -87,12 +87,13 @@ RemoteLazyInputStreamParent::Create<mozilla::net::SocketProcessParent>(
mozilla::net::SocketProcessParent*);
template already_AddRefed<RemoteLazyInputStreamParent>
RemoteLazyInputStreamParent::Create<ContentParent>(nsIInputStream*, uint64_t,
uint64_t, nsresult*,
ContentParent*);
RemoteLazyInputStreamParent::Create<dom::ContentParent>(nsIInputStream*,
uint64_t, uint64_t,
nsresult*,
dom::ContentParent*);
RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
const nsID& aID, uint64_t aSize, ContentParent* aManager)
const nsID& aID, uint64_t aSize, dom::ContentParent* aManager)
: mID(aID),
mSize(aSize),
mContentManager(aManager),
@ -110,7 +111,7 @@ RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
mMigrating(false) {}
RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
const nsID& aID, uint64_t aSize, SocketProcessParent* aManager)
const nsID& aID, uint64_t aSize, net::SocketProcessParent* aManager)
: mID(aID),
mSize(aSize),
mContentManager(nullptr),

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

@ -10,6 +10,7 @@
#include "mozilla/StaticPtr.h"
#include "nsIPropertyBag2.h"
#include "nsStreamUtils.h"
#include "RemoteLazyInputStreamParent.h"
#include "RemoteLazyInputStreamStorage.h"
namespace mozilla {

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

@ -46,8 +46,8 @@ class MigrateActorRunnable final : public Runnable {
MOZ_ASSERT(mActor->State() ==
RemoteLazyInputStreamChild::eInactiveMigrating);
PBackgroundChild* actorChild =
BackgroundChild::GetOrCreateForCurrentThread();
ipc::PBackgroundChild* actorChild =
ipc::BackgroundChild::GetOrCreateForCurrentThread();
if (!actorChild) {
return NS_OK;
}

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

@ -66,7 +66,7 @@ nsresult SerializeInputStreamParent(nsIInputStream* aInputStream,
// static
nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream,
ContentParent* aManager) {
dom::ContentParent* aManager) {
PRemoteLazyInputStreamParent* actor = nullptr;
nsresult rv = SerializeInputStreamParent(
aInputStream, aSize, aManager->ChildID(), actor, aManager);
@ -79,10 +79,10 @@ nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
// static
nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream,
PBackgroundParent* aManager) {
ipc::PBackgroundParent* aManager) {
PRemoteLazyInputStreamParent* actor = nullptr;
nsresult rv = SerializeInputStreamParent(
aInputStream, aSize, BackgroundParent::GetChildID(aManager), actor,
aInputStream, aSize, ipc::BackgroundParent::GetChildID(aManager), actor,
aManager);
NS_ENSURE_SUCCESS(rv, rv);
@ -93,8 +93,8 @@ nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
// static
nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream,
ContentChild* aManager) {
AutoIPCStream ipcStream(true /* delayed start */);
dom::ContentChild* aManager) {
ipc::AutoIPCStream ipcStream(true /* delayed start */);
if (!ipcStream.Serialize(aInputStream, aManager)) {
return NS_ERROR_FAILURE;
}
@ -106,8 +106,8 @@ nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
// static
nsresult RemoteLazyInputStreamUtils::SerializeInputStream(
nsIInputStream* aInputStream, uint64_t aSize, RemoteLazyStream& aOutStream,
PBackgroundChild* aManager) {
AutoIPCStream ipcStream(true /* delayed start */);
ipc::PBackgroundChild* aManager) {
ipc::AutoIPCStream ipcStream(true /* delayed start */);
if (!ipcStream.Serialize(aInputStream, aManager)) {
return NS_ERROR_FAILURE;
}

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

@ -7,12 +7,17 @@
#ifndef mozilla_RemoteLazyInputStreamUtils_h
#define mozilla_RemoteLazyInputStreamUtils_h
#include <cstdint>
/*
* RemoteLazyInputStream was previously part of the IPCBlob world.
* See IPCBlobUtils.h to know how to use it. As a follow up, the documentation
* will be partially moved here too.
*/
class nsIInputStream;
enum class nsresult : uint32_t;
namespace mozilla {
class RemoteLazyStream;

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

@ -15,8 +15,6 @@
using namespace mozilla::dom;
static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);

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

@ -12,6 +12,13 @@
#include "nsSimpleURI.h"
#include "prtime.h"
#define NS_HOSTOBJECTURI_CID \
{ \
0xf5475c51, 0x59a7, 0x4757, { \
0xb3, 0xd9, 0xe2, 0x11, 0xa9, 0x41, 0x08, 0x72 \
} \
}
#define NS_IBLOBURLMUTATOR_IID \
{ \
0xf91e646d, 0xe87b, 0x485e, { \
@ -25,6 +32,8 @@ class NS_NO_VTABLE nsIBlobURLMutator : public nsISupports {
NS_IMETHOD SetRevoked(bool aRevoked) = 0;
};
inline NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
NS_DEFINE_STATIC_IID_ACCESSOR(nsIBlobURLMutator, NS_IBLOBURLMUTATOR_IID)
namespace mozilla {
@ -105,13 +114,6 @@ class BlobURL final : public mozilla::net::nsSimpleURI {
friend BaseURIMutator<BlobURL>;
};
#define NS_HOSTOBJECTURI_CID \
{ \
0xf5475c51, 0x59a7, 0x4757, { \
0xb3, 0xd9, 0xe2, 0x11, 0xa9, 0x41, 0x08, 0x72 \
} \
}
#define NS_HOSTOBJECTURIMUTATOR_CID \
{ \
0xbbe50ef2, 0x80eb, 0x469d, { \

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

@ -5,6 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BlobURLInputStream.h"
#include "BlobURL.h"
#include "BlobURLChannel.h"
#include "BlobURLProtocolHandler.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/IPCBlobUtils.h"

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

@ -18,6 +18,7 @@
#include "mozilla/ipc/IPCStreamUtils.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/Maybe.h"
#include "mozilla/NullPrincipal.h"
#include "mozilla/OriginAttributes.h"
#include "mozilla/Preferences.h"
@ -46,7 +47,7 @@ namespace dom {
struct DataInfo {
enum ObjectType { eBlobImpl, eMediaSource };
DataInfo(BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
DataInfo(mozilla::dom::BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
const Maybe<nsID>& aAgentClusterId)
: mObjectType(eBlobImpl),
mBlobImpl(aBlobImpl),
@ -90,10 +91,10 @@ static StaticMutex sMutex;
// sMutex. Reading from gDataTable on the main thread may happen without
// locking, since no changes are possible. Reading it from another thread
// must also lock sMutex to prevent data races.
static nsClassHashtable<nsCStringHashKey, DataInfo>* gDataTable;
static nsClassHashtable<nsCStringHashKey, mozilla::dom::DataInfo>* gDataTable;
static DataInfo* GetDataInfo(const nsACString& aUri,
bool aAlsoIfRevoked = false) {
static mozilla::dom::DataInfo* GetDataInfo(const nsACString& aUri,
bool aAlsoIfRevoked = false) {
if (!gDataTable) {
return nullptr;
}
@ -101,7 +102,7 @@ static DataInfo* GetDataInfo(const nsACString& aUri,
// Let's remove any fragment from this URI.
int32_t fragmentPos = aUri.FindChar('#');
DataInfo* res;
mozilla::dom::DataInfo* res;
if (fragmentPos < 0) {
res = gDataTable->Get(aUri);
} else {
@ -115,7 +116,8 @@ static DataInfo* GetDataInfo(const nsACString& aUri,
return res;
}
static DataInfo* GetDataInfoFromURI(nsIURI* aURI, bool aAlsoIfRevoked = false) {
static mozilla::dom::DataInfo* GetDataInfoFromURI(nsIURI* aURI,
bool aAlsoIfRevoked = false) {
if (!aURI) {
return nullptr;
}
@ -130,7 +132,8 @@ static DataInfo* GetDataInfoFromURI(nsIURI* aURI, bool aAlsoIfRevoked = false) {
}
// Memory reporting for the hash table.
void BroadcastBlobURLRegistration(const nsACString& aURI, BlobImpl* aBlobImpl,
void BroadcastBlobURLRegistration(const nsACString& aURI,
mozilla::dom::BlobImpl* aBlobImpl,
nsIPrincipal* aPrincipal,
const Maybe<nsID>& aAgentClusterId) {
MOZ_ASSERT(NS_IsMainThread());
@ -181,15 +184,16 @@ class BlobURLsReporter final : public nsIMemoryReporter {
return NS_OK;
}
nsDataHashtable<nsPtrHashKey<BlobImpl>, uint32_t> refCounts;
nsDataHashtable<nsPtrHashKey<mozilla::dom::BlobImpl>, uint32_t> refCounts;
// Determine number of URLs per BlobImpl, to handle the case where it's > 1.
// Determine number of URLs per mozilla::dom::BlobImpl, to handle the case
// where it's > 1.
for (auto iter = gDataTable->Iter(); !iter.Done(); iter.Next()) {
if (iter.UserData()->mObjectType != DataInfo::eBlobImpl) {
if (iter.UserData()->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
continue;
}
BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
mozilla::dom::BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
MOZ_ASSERT(blobImpl);
refCounts.Put(blobImpl, refCounts.Get(blobImpl) + 1);
@ -197,10 +201,10 @@ class BlobURLsReporter final : public nsIMemoryReporter {
for (auto iter = gDataTable->Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
DataInfo* info = iter.UserData();
mozilla::dom::DataInfo* info = iter.UserData();
if (iter.UserData()->mObjectType == DataInfo::eBlobImpl) {
BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
if (iter.UserData()->mObjectType == mozilla::dom::DataInfo::eBlobImpl) {
mozilla::dom::BlobImpl* blobImpl = iter.UserData()->mBlobImpl;
MOZ_ASSERT(blobImpl);
constexpr auto desc =
@ -234,7 +238,7 @@ class BlobURLsReporter final : public nsIMemoryReporter {
nsAutoCString addrStr;
addrStr = "0x";
addrStr.AppendInt((uint64_t)(BlobImpl*)blobImpl, 16);
addrStr.AppendInt((uint64_t)(mozilla::dom::BlobImpl*)blobImpl, 16);
path += " ";
path.AppendInt(refCount);
@ -285,7 +289,7 @@ class BlobURLsReporter final : public nsIMemoryReporter {
// Initialize info->mStack to record JS stack info, if enabled.
// The string generated here is used in ReportCallback, below.
static void GetJSStackForBlob(DataInfo* aInfo) {
static void GetJSStackForBlob(mozilla::dom::DataInfo* aInfo) {
nsCString& stack = aInfo->mStack;
MOZ_ASSERT(stack.IsEmpty());
const uint32_t maxFrames =
@ -345,7 +349,7 @@ class BlobURLsReporter final : public nsIMemoryReporter {
~BlobURLsReporter() = default;
static void BuildPath(nsAutoCString& path, nsCStringHashKey::KeyType aKey,
DataInfo* aInfo, bool anonymize) {
mozilla::dom::DataInfo* aInfo, bool anonymize) {
nsAutoCString url, owner;
aInfo->mPrincipal->GetAsciiSpec(owner);
if (!owner.IsEmpty()) {
@ -471,7 +475,7 @@ class ReleasingTimerHolder final : public Runnable,
MOZ_ASSERT(NS_IsMainThread(),
"without locking gDataTable is main-thread only");
DataInfo* info =
mozilla::dom::DataInfo* info =
GetDataInfo(mURI, true /* We care about revoked dataInfo */);
if (!info) {
// Already gone!
@ -522,10 +526,11 @@ static void AddDataEntryInternal(const nsACString& aURI, T aObject,
MOZ_ASSERT(NS_IsMainThread(), "changing gDataTable is main-thread only");
StaticMutexAutoLock lock(sMutex);
if (!gDataTable) {
gDataTable = new nsClassHashtable<nsCStringHashKey, DataInfo>;
gDataTable = new nsClassHashtable<nsCStringHashKey, mozilla::dom::DataInfo>;
}
DataInfo* info = new DataInfo(aObject, aPrincipal, aAgentClusterId);
mozilla::dom::DataInfo* info =
new mozilla::dom::DataInfo(aObject, aPrincipal, aAgentClusterId);
BlobURLsReporter::GetJSStackForBlob(info);
gDataTable->Put(aURI, info);
@ -546,7 +551,7 @@ BlobURLProtocolHandler::~BlobURLProtocolHandler() = default;
/* static */
nsresult BlobURLProtocolHandler::AddDataEntry(
BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
mozilla::dom::BlobImpl* aBlobImpl, nsIPrincipal* aPrincipal,
const Maybe<nsID>& aAgentClusterId, nsACString& aUri) {
MOZ_ASSERT(aBlobImpl);
MOZ_ASSERT(aPrincipal);
@ -582,7 +587,7 @@ nsresult BlobURLProtocolHandler::AddDataEntry(
void BlobURLProtocolHandler::AddDataEntry(const nsACString& aURI,
nsIPrincipal* aPrincipal,
const Maybe<nsID>& aAgentClusterId,
BlobImpl* aBlobImpl) {
mozilla::dom::BlobImpl* aBlobImpl) {
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(aBlobImpl);
AddDataEntryInternal(aURI, aBlobImpl, aPrincipal, aAgentClusterId);
@ -590,8 +595,9 @@ void BlobURLProtocolHandler::AddDataEntry(const nsACString& aURI,
/* static */
bool BlobURLProtocolHandler::ForEachBlobURL(
std::function<bool(BlobImpl*, nsIPrincipal*, const Maybe<nsID>&,
const nsACString&, bool aRevoked)>&& aCb) {
std::function<bool(mozilla::dom::BlobImpl*, nsIPrincipal*,
const Maybe<nsID>&, const nsACString&, bool aRevoked)>&&
aCb) {
MOZ_ASSERT(NS_IsMainThread());
if (!gDataTable) {
@ -599,10 +605,10 @@ bool BlobURLProtocolHandler::ForEachBlobURL(
}
for (auto iter = gDataTable->ConstIter(); !iter.Done(); iter.Next()) {
DataInfo* info = iter.UserData();
mozilla::dom::DataInfo* info = iter.UserData();
MOZ_ASSERT(info);
if (info->mObjectType != DataInfo::eBlobImpl) {
if (info->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
continue;
}
@ -623,7 +629,7 @@ void BlobURLProtocolHandler::RemoveDataEntry(const nsACString& aUri,
if (!gDataTable) {
return;
}
DataInfo* info = GetDataInfo(aUri);
mozilla::dom::DataInfo* info = GetDataInfo(aUri);
if (!info) {
return;
}
@ -633,13 +639,14 @@ void BlobURLProtocolHandler::RemoveDataEntry(const nsACString& aUri,
info->mRevoked = true;
}
if (aBroadcastToOtherProcesses && info->mObjectType == DataInfo::eBlobImpl) {
if (aBroadcastToOtherProcesses &&
info->mObjectType == mozilla::dom::DataInfo::eBlobImpl) {
BroadcastBlobURLUnregistration(nsCString(aUri), info->mPrincipal);
}
// The timer will take care of removing the entry for real after
// RELEASING_TIMER milliseconds. In the meantime, the DataInfo, marked as
// revoked, will not be exposed.
// RELEASING_TIMER milliseconds. In the meantime, the mozilla::dom::DataInfo,
// marked as revoked, will not be exposed.
ReleasingTimerHolder::Create(aUri);
}
@ -652,7 +659,7 @@ bool BlobURLProtocolHandler::RemoveDataEntry(
return false;
}
DataInfo* info = GetDataInfo(aUri);
mozilla::dom::DataInfo* info = GetDataInfo(aUri);
if (!info) {
return false;
}
@ -727,7 +734,7 @@ nsresult BlobURLProtocolHandler::GenerateURIString(nsIPrincipal* aPrincipal,
/* static */
bool BlobURLProtocolHandler::GetDataEntry(
const nsACString& aUri, BlobImpl** aBlobImpl,
const nsACString& aUri, mozilla::dom::BlobImpl** aBlobImpl,
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
const OriginAttributes& aOriginAttributes,
const Maybe<nsID>& aAgentClusterId, bool aAlsoIfRevoked) {
@ -739,7 +746,7 @@ bool BlobURLProtocolHandler::GetDataEntry(
return false;
}
DataInfo* info = GetDataInfo(aUri, aAlsoIfRevoked);
mozilla::dom::DataInfo* info = GetDataInfo(aUri, aAlsoIfRevoked);
if (!info) {
return false;
}
@ -773,7 +780,7 @@ bool BlobURLProtocolHandler::GetDataEntry(
return false;
}
RefPtr<BlobImpl> blobImpl = info->mBlobImpl;
RefPtr<mozilla::dom::BlobImpl> blobImpl = info->mBlobImpl;
blobImpl.forget(aBlobImpl);
return true;
@ -788,18 +795,18 @@ void BlobURLProtocolHandler::Traverse(
return;
}
DataInfo* res;
mozilla::dom::DataInfo* res;
gDataTable->Get(aUri, &res);
if (!res) {
return;
}
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
aCallback, "BlobURLProtocolHandler DataInfo.mBlobImpl");
aCallback, "BlobURLProtocolHandler mozilla::dom::DataInfo.mBlobImpl");
aCallback.NoteXPCOMChild(res->mBlobImpl);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(
aCallback, "BlobURLProtocolHandler DataInfo.mMediaSource");
aCallback, "BlobURLProtocolHandler mozilla::dom::DataInfo.mMediaSource");
aCallback.NoteXPCOMChild(res->mMediaSource);
}
@ -839,8 +846,8 @@ BlobURLProtocolHandler::GetFlagsForURI(nsIURI* aURI, uint32_t* aResult) {
bool revoked = true;
{
StaticMutexAutoLock lock(sMutex);
DataInfo* info = GetDataInfo(aSpec);
if (info && info->mObjectType == DataInfo::eBlobImpl) {
mozilla::dom::DataInfo* info = GetDataInfo(aSpec);
if (info && info->mObjectType == mozilla::dom::DataInfo::eBlobImpl) {
revoked = info->mRevoked;
}
}
@ -891,8 +898,10 @@ bool BlobURLProtocolHandler::GetBlobURLPrincipal(nsIURI* aURI,
MOZ_ASSERT(NS_IsMainThread(),
"without locking gDataTable is main-thread only");
DataInfo* info = GetDataInfoFromURI(aURI, true /*aAlsoIfRevoked */);
if (!info || info->mObjectType != DataInfo::eBlobImpl || !info->mBlobImpl) {
mozilla::dom::DataInfo* info =
GetDataInfoFromURI(aURI, true /*aAlsoIfRevoked */);
if (!info || info->mObjectType != mozilla::dom::DataInfo::eBlobImpl ||
!info->mBlobImpl) {
return false;
}
@ -912,47 +921,52 @@ bool BlobURLProtocolHandler::GetBlobURLPrincipal(nsIURI* aURI,
} // namespace dom
} // namespace mozilla
nsresult NS_GetBlobForBlobURI(nsIURI* aURI, BlobImpl** aBlob) {
nsresult NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob) {
*aBlob = nullptr;
MOZ_ASSERT(NS_IsMainThread(),
"without locking gDataTable is main-thread only");
DataInfo* info = GetDataInfoFromURI(aURI, false /* aAlsoIfRevoked */);
if (!info || info->mObjectType != DataInfo::eBlobImpl) {
mozilla::dom::DataInfo* info =
mozilla::dom::GetDataInfoFromURI(aURI, false /* aAlsoIfRevoked */);
if (!info || info->mObjectType != mozilla::dom::DataInfo::eBlobImpl) {
return NS_ERROR_DOM_BAD_URI;
}
RefPtr<BlobImpl> blob = info->mBlobImpl;
RefPtr<mozilla::dom::BlobImpl> blob = info->mBlobImpl;
blob.forget(aBlob);
return NS_OK;
}
nsresult NS_GetBlobForBlobURISpec(const nsACString& aSpec, BlobImpl** aBlob,
nsresult NS_GetBlobForBlobURISpec(const nsACString& aSpec,
mozilla::dom::BlobImpl** aBlob,
bool aAlsoIfRevoked) {
*aBlob = nullptr;
MOZ_ASSERT(NS_IsMainThread(),
"without locking gDataTable is main-thread only");
DataInfo* info = GetDataInfo(aSpec, aAlsoIfRevoked);
if (!info || info->mObjectType != DataInfo::eBlobImpl || !info->mBlobImpl) {
mozilla::dom::DataInfo* info =
mozilla::dom::GetDataInfo(aSpec, aAlsoIfRevoked);
if (!info || info->mObjectType != mozilla::dom::DataInfo::eBlobImpl ||
!info->mBlobImpl) {
return NS_ERROR_DOM_BAD_URI;
}
RefPtr<BlobImpl> blob = info->mBlobImpl;
RefPtr<mozilla::dom::BlobImpl> blob = info->mBlobImpl;
blob.forget(aBlob);
return NS_OK;
}
nsresult NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** aSource) {
nsresult NS_GetSourceForMediaSourceURI(nsIURI* aURI,
mozilla::dom::MediaSource** aSource) {
*aSource = nullptr;
MOZ_ASSERT(NS_IsMainThread(),
"without locking gDataTable is main-thread only");
DataInfo* info = GetDataInfoFromURI(aURI);
if (!info || info->mObjectType != DataInfo::eMediaSource) {
mozilla::dom::DataInfo* info = mozilla::dom::GetDataInfoFromURI(aURI);
if (!info || info->mObjectType != mozilla::dom::DataInfo::eMediaSource) {
return NS_ERROR_DOM_BAD_URI;
}
RefPtr<MediaSource> mediaSource = info->mMediaSource;
RefPtr<mozilla::dom::MediaSource> mediaSource = info->mMediaSource;
mediaSource.forget(aSource);
return NS_OK;
}
@ -960,10 +974,10 @@ nsresult NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** aSource) {
namespace mozilla {
namespace dom {
bool IsType(nsIURI* aUri, DataInfo::ObjectType aType) {
bool IsType(nsIURI* aUri, mozilla::dom::DataInfo::ObjectType aType) {
// We lock because this may be called off-main-thread
StaticMutexAutoLock lock(sMutex);
DataInfo* info = GetDataInfoFromURI(aUri);
mozilla::dom::DataInfo* info = GetDataInfoFromURI(aUri);
if (!info) {
return false;
}
@ -971,7 +985,9 @@ bool IsType(nsIURI* aUri, DataInfo::ObjectType aType) {
return info->mObjectType == aType;
}
bool IsBlobURI(nsIURI* aUri) { return IsType(aUri, DataInfo::eBlobImpl); }
bool IsBlobURI(nsIURI* aUri) {
return IsType(aUri, mozilla::dom::DataInfo::eBlobImpl);
}
bool BlobURLSchemeIsHTTPOrHTTPS(const nsACString& aUri) {
return (StringBeginsWith(aUri, "blob:http://"_ns) ||
@ -979,7 +995,7 @@ bool BlobURLSchemeIsHTTPOrHTTPS(const nsACString& aUri) {
}
bool IsMediaSourceURI(nsIURI* aUri) {
return IsType(aUri, DataInfo::eMediaSource);
return IsType(aUri, mozilla::dom::DataInfo::eMediaSource);
}
} // namespace dom

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

@ -22,6 +22,8 @@ class nsIPrincipal;
namespace mozilla {
class BlobURLsReporter;
class OriginAttributes;
template <class T>
class Maybe;
namespace dom {