Bug 1619953 - P2 - Asynchronous BlobURLDataRequest introduced r=baku

The content process should use this method to send blob url and triggering principal to the parent process and expect blobImpl in return, if the blob is found and the triggering principal subsumes the blob's principal.

Differential Revision: https://phabricator.services.mozilla.com/D75291
This commit is contained in:
ssengupta 2020-08-05 17:05:54 +00:00
Родитель b9048b8ca2
Коммит 562ceea795
3 изменённых файлов: 50 добавлений и 0 удалений

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

@ -6825,6 +6825,44 @@ PFileDescriptorSetParent* ContentParent::SendPFileDescriptorSetConstructor(
return PContentParent::SendPFileDescriptorSetConstructor(aFD); return PContentParent::SendPFileDescriptorSetConstructor(aFD);
} }
mozilla::ipc::IPCResult ContentParent::RecvBlobURLDataRequest(
const nsCString& aBlobURL, nsIPrincipal* pTriggeringPrincipal,
BlobURLDataRequestResolver&& aResolver) {
RefPtr<BlobImpl> blobImpl;
nsresult rv = NS_GetBlobForBlobURISpec(aBlobURL, getter_AddRefs(blobImpl));
if (NS_WARN_IF(NS_FAILED(rv))) {
aResolver(rv);
return IPC_OK();
}
if (NS_WARN_IF(!blobImpl)) {
aResolver(NS_ERROR_DOM_BAD_URI);
return IPC_OK();
}
nsIPrincipal* const dataEntryPrincipal =
BlobURLProtocolHandler::GetDataEntryPrincipal(aBlobURL);
MOZ_ASSERT(dataEntryPrincipal);
if (!pTriggeringPrincipal->Subsumes(dataEntryPrincipal)) {
aResolver(NS_ERROR_DOM_BAD_URI);
return IPC_OK();
}
IPCBlob ipcBlob;
rv = IPCBlobUtils::Serialize(blobImpl, this, ipcBlob);
if (NS_WARN_IF(NS_FAILED(rv))) {
aResolver(rv);
return IPC_OK();
}
aResolver(ipcBlob);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvReportServiceWorkerShutdownProgress( mozilla::ipc::IPCResult ContentParent::RecvReportServiceWorkerShutdownProgress(
uint32_t aShutdownStateId, ServiceWorkerShutdownState::Progress aProgress) { uint32_t aShutdownStateId, ServiceWorkerShutdownState::Progress aProgress) {
RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance(); RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();

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

@ -697,6 +697,10 @@ class ContentParent final
PFileDescriptorSetParent* SendPFileDescriptorSetConstructor( PFileDescriptorSetParent* SendPFileDescriptorSetConstructor(
const FileDescriptor& aFD) override; const FileDescriptor& aFD) override;
mozilla::ipc::IPCResult RecvBlobURLDataRequest(
const nsCString& aBlobURL, nsIPrincipal* pTriggeringPrincipal,
BlobURLDataRequestResolver&& aResolver);
protected: protected:
bool CheckBrowsingContextEmbedder(CanonicalBrowsingContext* aBC, bool CheckBrowsingContextEmbedder(CanonicalBrowsingContext* aBC,
const char* aOperation) const; const char* aOperation) const;

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

@ -381,6 +381,12 @@ union SyncedContextInitializer
WindowContextInitializer; WindowContextInitializer;
}; };
union BlobURLDataRequestResult
{
IPCBlob;
nsresult;
};
/** /**
* The PContent protocol is a top-level protocol between the UI process * The PContent protocol is a top-level protocol between the UI process
* and a content process. There is exactly one PContentParent/PContentChild pair * and a content process. There is exactly one PContentParent/PContentChild pair
@ -1658,6 +1664,8 @@ parent:
async HistoryGo(MaybeDiscardedBrowsingContext aContext, async HistoryGo(MaybeDiscardedBrowsingContext aContext,
int32_t aOffset) returns(int32_t requestedIndex); int32_t aOffset) returns(int32_t requestedIndex);
async BlobURLDataRequest(nsCString pBlobURL, nsIPrincipal pTriggeringPrincipal) returns (BlobURLDataRequestResult aResult);
both: both:
async ScriptError(nsString message, nsString sourceName, nsString sourceLine, async ScriptError(nsString message, nsString sourceName, nsString sourceLine,
uint32_t lineNumber, uint32_t colNumber, uint32_t flags, uint32_t lineNumber, uint32_t colNumber, uint32_t flags,