Commit df939f0b authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert BlobURLTokenRequest to new Mojo types

This CL converts BlobURLTokenRequest to new Mojo types.
It updates ResolveForNavigation and Clone from
blob_url_store.mojom and methods and members with new
Mojo types.

Bug: 955171, 978694
Change-Id: Ib18e1c3834e6b0c6129cd2c9b1f13930a06a909d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772791Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#691595}
parent 910657f8
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "storage/browser/blob/blob_url_store_impl.h" #include "storage/browser/blob/blob_url_store_impl.h"
#include "base/bind.h" #include "base/bind.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/receiver_set.h"
#include "storage/browser/blob/blob_impl.h" #include "storage/browser/blob/blob_impl.h"
#include "storage/browser/blob/blob_storage_context.h" #include "storage/browser/blob/blob_storage_context.h"
#include "storage/browser/blob/blob_url_loader_factory.h" #include "storage/browser/blob/blob_url_loader_factory.h"
...@@ -19,13 +19,13 @@ class BlobURLTokenImpl : public blink::mojom::BlobURLToken { ...@@ -19,13 +19,13 @@ class BlobURLTokenImpl : public blink::mojom::BlobURLToken {
BlobURLTokenImpl(base::WeakPtr<BlobStorageContext> context, BlobURLTokenImpl(base::WeakPtr<BlobStorageContext> context,
const GURL& url, const GURL& url,
std::unique_ptr<BlobDataHandle> blob, std::unique_ptr<BlobDataHandle> blob,
blink::mojom::BlobURLTokenRequest request) mojo::PendingReceiver<blink::mojom::BlobURLToken> receiver)
: context_(std::move(context)), : context_(std::move(context)),
url_(url), url_(url),
blob_(std::move(blob)), blob_(std::move(blob)),
token_(base::UnguessableToken::Create()) { token_(base::UnguessableToken::Create()) {
bindings_.AddBinding(this, std::move(request)); receivers_.Add(this, std::move(receiver));
bindings_.set_connection_error_handler(base::BindRepeating( receivers_.set_disconnect_handler(base::BindRepeating(
&BlobURLTokenImpl::OnConnectionError, base::Unretained(this))); &BlobURLTokenImpl::OnConnectionError, base::Unretained(this)));
if (context_) { if (context_) {
context_->mutable_registry()->AddTokenMapping(token_, url_, context_->mutable_registry()->AddTokenMapping(token_, url_,
...@@ -42,19 +42,20 @@ class BlobURLTokenImpl : public blink::mojom::BlobURLToken { ...@@ -42,19 +42,20 @@ class BlobURLTokenImpl : public blink::mojom::BlobURLToken {
std::move(callback).Run(token_); std::move(callback).Run(token_);
} }
void Clone(blink::mojom::BlobURLTokenRequest request) override { void Clone(
bindings_.AddBinding(this, std::move(request)); mojo::PendingReceiver<blink::mojom::BlobURLToken> receiver) override {
receivers_.Add(this, std::move(receiver));
} }
private: private:
void OnConnectionError() { void OnConnectionError() {
if (!bindings_.empty()) if (!receivers_.empty())
return; return;
delete this; delete this;
} }
base::WeakPtr<BlobStorageContext> context_; base::WeakPtr<BlobStorageContext> context_;
mojo::BindingSet<blink::mojom::BlobURLToken> bindings_; mojo::ReceiverSet<blink::mojom::BlobURLToken> receivers_;
const GURL url_; const GURL url_;
const std::unique_ptr<BlobDataHandle> blob_; const std::unique_ptr<BlobDataHandle> blob_;
const base::UnguessableToken token_; const base::UnguessableToken token_;
...@@ -151,7 +152,7 @@ void BlobURLStoreImpl::ResolveAsURLLoaderFactory( ...@@ -151,7 +152,7 @@ void BlobURLStoreImpl::ResolveAsURLLoaderFactory(
void BlobURLStoreImpl::ResolveForNavigation( void BlobURLStoreImpl::ResolveForNavigation(
const GURL& url, const GURL& url,
blink::mojom::BlobURLTokenRequest token) { mojo::PendingReceiver<blink::mojom::BlobURLToken> token) {
if (!context_) if (!context_)
return; return;
std::unique_ptr<BlobDataHandle> blob_handle = std::unique_ptr<BlobDataHandle> blob_handle =
......
...@@ -30,8 +30,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobURLStoreImpl ...@@ -30,8 +30,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobURLStoreImpl
void ResolveAsURLLoaderFactory( void ResolveAsURLLoaderFactory(
const GURL& url, const GURL& url,
network::mojom::URLLoaderFactoryRequest request) override; network::mojom::URLLoaderFactoryRequest request) override;
void ResolveForNavigation(const GURL& url, void ResolveForNavigation(
blink::mojom::BlobURLTokenRequest token) override; const GURL& url,
mojo::PendingReceiver<blink::mojom::BlobURLToken> token) override;
private: private:
void RegisterWithUUID(blink::mojom::BlobPtr blob, void RegisterWithUUID(blink::mojom::BlobPtr blob,
......
...@@ -38,13 +38,13 @@ interface BlobURLStore { ...@@ -38,13 +38,13 @@ interface BlobURLStore {
// used by the browser process to securely look up the blob a URL used to // used by the browser process to securely look up the blob a URL used to
// refer to, even after the URL is revoked. // refer to, even after the URL is revoked.
// As long as the token is alive, the resolved blob will also be kept alive. // As long as the token is alive, the resolved blob will also be kept alive.
ResolveForNavigation(url.mojom.Url url, BlobURLToken& token); ResolveForNavigation(url.mojom.Url url, pending_receiver<BlobURLToken> token);
}; };
// A token representing a Blob URL. The browser process can use this to look up // A token representing a Blob URL. The browser process can use this to look up
// the blob URL and blob it referred to, even after the blob URL itself is // the blob URL and blob it referred to, even after the blob URL itself is
// revoked. For the renderer this is just an opaque token without any meaning. // revoked. For the renderer this is just an opaque token without any meaning.
interface BlobURLToken { interface BlobURLToken {
Clone(BlobURLToken& token); Clone(pending_receiver<BlobURLToken> token);
GetToken() => (mojo_base.mojom.UnguessableToken token); GetToken() => (mojo_base.mojom.UnguessableToken token);
}; };
...@@ -175,7 +175,7 @@ void PublicURLManager::Resolve( ...@@ -175,7 +175,7 @@ void PublicURLManager::Resolve(
void PublicURLManager::Resolve( void PublicURLManager::Resolve(
const KURL& url, const KURL& url,
mojom::blink::BlobURLTokenRequest token_request) { mojo::PendingReceiver<mojom::blink::BlobURLToken> token_receiver) {
if (is_stopped_) if (is_stopped_)
return; return;
...@@ -185,7 +185,7 @@ void PublicURLManager::Resolve( ...@@ -185,7 +185,7 @@ void PublicURLManager::Resolve(
GetExecutionContext()->GetSecurityOrigin(), GetExecutionContext()->GetSecurityOrigin(),
url_store_.BindNewEndpointAndPassReceiver()); url_store_.BindNewEndpointAndPassReceiver());
} }
url_store_->ResolveForNavigation(url, std::move(token_request)); url_store_->ResolveForNavigation(url, std::move(token_receiver));
} }
void PublicURLManager::ContextDestroyed(ExecutionContext*) { void PublicURLManager::ContextDestroyed(ExecutionContext*) {
......
...@@ -64,7 +64,7 @@ class CORE_EXPORT PublicURLManager final ...@@ -64,7 +64,7 @@ class CORE_EXPORT PublicURLManager final
// BlobURLToken. This token can be used by the browser process to securely // BlobURLToken. This token can be used by the browser process to securely
// lookup what blob a URL used to refer to, even after the URL is revoked. // lookup what blob a URL used to refer to, even after the URL is revoked.
// If the URL fails to resolve the request will simply be disconnected. // If the URL fails to resolve the request will simply be disconnected.
void Resolve(const KURL&, mojom::blink::BlobURLTokenRequest); void Resolve(const KURL&, mojo::PendingReceiver<mojom::blink::BlobURLToken>);
// ContextLifecycleObserver interface. // ContextLifecycleObserver interface.
void ContextDestroyed(ExecutionContext*) override; void ContextDestroyed(ExecutionContext*) override;
......
...@@ -37,8 +37,9 @@ void FakeBlobURLStore::ResolveAsURLLoaderFactory( ...@@ -37,8 +37,9 @@ void FakeBlobURLStore::ResolveAsURLLoaderFactory(
NOTREACHED(); NOTREACHED();
} }
void FakeBlobURLStore::ResolveForNavigation(const KURL&, void FakeBlobURLStore::ResolveForNavigation(
mojom::blink::BlobURLTokenRequest) { const KURL&,
mojo::PendingReceiver<mojom::blink::BlobURLToken>) {
NOTREACHED(); NOTREACHED();
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "third_party/blink/public/mojom/blob/blob_url_store.mojom-blink.h" #include "third_party/blink/public/mojom/blob/blob_url_store.mojom-blink.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "third_party/blink/renderer/platform/weborigin/kurl_hash.h" #include "third_party/blink/renderer/platform/weborigin/kurl_hash.h"
#include "third_party/blink/renderer/platform/wtf/hash_map.h" #include "third_party/blink/renderer/platform/wtf/hash_map.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
...@@ -23,8 +22,9 @@ class FakeBlobURLStore : public mojom::blink::BlobURLStore { ...@@ -23,8 +22,9 @@ class FakeBlobURLStore : public mojom::blink::BlobURLStore {
void ResolveAsURLLoaderFactory( void ResolveAsURLLoaderFactory(
const KURL&, const KURL&,
network::mojom::blink::URLLoaderFactoryRequest) override; network::mojom::blink::URLLoaderFactoryRequest) override;
void ResolveForNavigation(const KURL&, void ResolveForNavigation(
mojom::blink::BlobURLTokenRequest) override; const KURL&,
mojo::PendingReceiver<mojom::blink::BlobURLToken>) override;
HashMap<KURL, mojom::blink::BlobPtr> registrations; HashMap<KURL, mojom::blink::BlobPtr> registrations;
Vector<KURL> revocations; Vector<KURL> revocations;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment