Backed out changeset 1de121cdb483 (bug 1671641) for build bustage in dom/file/ipc/RemoteLazyInputStreamThread.cpp. CLOSED TREE

This commit is contained in:
Dorel Luca 2020-10-22 07:46:54 +03:00
Родитель 83bf4bc5a3
Коммит bdc3f86e85
17 изменённых файлов: 81 добавлений и 119 удалений

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

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

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

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

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

@ -5,7 +5,6 @@
* 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,7 +26,6 @@
#include "nsDOMJSUtils.h"
#include "nsError.h"
#include "nsNetUtil.h"
#include "nsStreamUtils.h"
#include "xpcpublic.h"
#include "nsReadableUtils.h"

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

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

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

@ -9,7 +9,6 @@
#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,
net::SocketProcessParent* aManager) {
SocketProcessParent* aManager) {
RefPtr<RemoteLazyInputStreamParent> actor =
new RemoteLazyInputStreamParent(aID, aSize, aManager);
@ -87,13 +87,12 @@ RemoteLazyInputStreamParent::Create<mozilla::net::SocketProcessParent>(
mozilla::net::SocketProcessParent*);
template already_AddRefed<RemoteLazyInputStreamParent>
RemoteLazyInputStreamParent::Create<dom::ContentParent>(nsIInputStream*,
uint64_t, uint64_t,
nsresult*,
dom::ContentParent*);
RemoteLazyInputStreamParent::Create<ContentParent>(nsIInputStream*, uint64_t,
uint64_t, nsresult*,
ContentParent*);
RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
const nsID& aID, uint64_t aSize, dom::ContentParent* aManager)
const nsID& aID, uint64_t aSize, ContentParent* aManager)
: mID(aID),
mSize(aSize),
mContentManager(aManager),
@ -111,7 +110,7 @@ RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
mMigrating(false) {}
RemoteLazyInputStreamParent::RemoteLazyInputStreamParent(
const nsID& aID, uint64_t aSize, net::SocketProcessParent* aManager)
const nsID& aID, uint64_t aSize, SocketProcessParent* aManager)
: mID(aID),
mSize(aSize),
mContentManager(nullptr),

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

@ -10,7 +10,6 @@
#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);
ipc::PBackgroundChild* actorChild =
ipc::BackgroundChild::GetOrCreateForCurrentThread();
PBackgroundChild* actorChild =
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,
dom::ContentParent* aManager) {
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,
ipc::PBackgroundParent* aManager) {
PBackgroundParent* aManager) {
PRemoteLazyInputStreamParent* actor = nullptr;
nsresult rv = SerializeInputStreamParent(
aInputStream, aSize, ipc::BackgroundParent::GetChildID(aManager), actor,
aInputStream, aSize, 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,
dom::ContentChild* aManager) {
ipc::AutoIPCStream ipcStream(true /* delayed start */);
ContentChild* aManager) {
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,
ipc::PBackgroundChild* aManager) {
ipc::AutoIPCStream ipcStream(true /* delayed start */);
PBackgroundChild* aManager) {
AutoIPCStream ipcStream(true /* delayed start */);
if (!ipcStream.Serialize(aInputStream, aManager)) {
return NS_ERROR_FAILURE;
}

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

@ -7,17 +7,12 @@
#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,6 +15,8 @@
using namespace mozilla::dom;
static NS_DEFINE_CID(kHOSTOBJECTURICID, NS_HOSTOBJECTURI_CID);
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);

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

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

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

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