Commit 2134cac5 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert BlobRequest to new Mojo types

This CL converts BlobRequest to new Mojo types.
It updates Clone from blob.mojom and Register
and GetBlobFromUUID from blob_registry.mojom and
methods and members to implement them.

It cleans up unnecessary BlobRequest declarations,
as well.

Bug: 955171, 978694
Change-Id: I4d2599341445a50af92e7c09245981b6939003ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757605
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarDaniel Murphy <dmurph@chromium.org>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690264}
parent 26bef937
...@@ -238,10 +238,11 @@ blink::mojom::BlobPtr ChromeBlobStorageContext::GetBlobPtr( ...@@ -238,10 +238,11 @@ blink::mojom::BlobPtr ChromeBlobStorageContext::GetBlobPtr(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::BindOnce( base::BindOnce(
[](scoped_refptr<ChromeBlobStorageContext> context, [](scoped_refptr<ChromeBlobStorageContext> context,
blink::mojom::BlobRequest request, const std::string& uuid) { mojo::PendingReceiver<blink::mojom::Blob> receiver,
const std::string& uuid) {
auto handle = context->context()->GetBlobDataFromUUID(uuid); auto handle = context->context()->GetBlobDataFromUUID(uuid);
if (handle) if (handle)
storage::BlobImpl::Create(std::move(handle), std::move(request)); storage::BlobImpl::Create(std::move(handle), std::move(receiver));
}, },
base::WrapRefCounted(GetFor(browser_context)), MakeRequest(&blob_ptr), base::WrapRefCounted(GetFor(browser_context)), MakeRequest(&blob_ptr),
uuid)); uuid));
......
...@@ -95,7 +95,7 @@ void FinalizeBlobOnIOThread( ...@@ -95,7 +95,7 @@ void FinalizeBlobOnIOThread(
CacheStorageCache::EntryIndex disk_cache_index, CacheStorageCache::EntryIndex disk_cache_index,
CacheStorageCache::EntryIndex side_data_disk_cache_index, CacheStorageCache::EntryIndex side_data_disk_cache_index,
std::string uuid, std::string uuid,
blink::mojom::BlobRequest request) { mojo::PendingReceiver<blink::mojom::Blob> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
// Just allow the blob mojo message pipe to automatically close if we're // Just allow the blob mojo message pipe to automatically close if we're
...@@ -109,7 +109,7 @@ void FinalizeBlobOnIOThread( ...@@ -109,7 +109,7 @@ void FinalizeBlobOnIOThread(
blob_data->AppendReadableDataHandle(std::move(inner_handle)); blob_data->AppendReadableDataHandle(std::move(inner_handle));
auto blob_handle = blob_context->AddFinishedBlob(std::move(blob_data)); auto blob_handle = blob_context->AddFinishedBlob(std::move(blob_data));
storage::BlobImpl::Create(std::move(blob_handle), std::move(request)); storage::BlobImpl::Create(std::move(blob_handle), std::move(receiver));
} }
} // namespace } // namespace
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache.h"
#include "services/network/public/mojom/fetch_api.mojom.h" #include "services/network/public/mojom/fetch_api.mojom.h"
...@@ -91,11 +91,11 @@ using ResponseHeaderMap = base::flat_map<std::string, std::string>; ...@@ -91,11 +91,11 @@ using ResponseHeaderMap = base::flat_map<std::string, std::string>;
class DelayedBlob : public storage::FakeBlob { class DelayedBlob : public storage::FakeBlob {
public: public:
DelayedBlob(blink::mojom::BlobRequest request, DelayedBlob(mojo::PendingReceiver<blink::mojom::Blob> receiver,
std::string data, std::string data,
base::OnceClosure read_closure) base::OnceClosure read_closure)
: FakeBlob("foo"), : FakeBlob("foo"),
binding_(this, std::move(request)), receiver_(this, std::move(receiver)),
data_(std::move(data)), data_(std::move(data)),
read_closure_(std::move(read_closure)) {} read_closure_(std::move(read_closure)) {}
...@@ -134,7 +134,7 @@ class DelayedBlob : public storage::FakeBlob { ...@@ -134,7 +134,7 @@ class DelayedBlob : public storage::FakeBlob {
producer_handle_.reset(); producer_handle_.reset();
} }
mojo::Binding<blink::mojom::Blob> binding_; mojo::Receiver<blink::mojom::Blob> receiver_;
std::string data_; std::string data_;
base::OnceClosure read_closure_; base::OnceClosure read_closure_;
mojo::Remote<blink::mojom::BlobReaderClient> client_; mojo::Remote<blink::mojom::BlobReaderClient> client_;
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "content/browser/indexed_db/indexed_db_value.h" #include "content/browser/indexed_db/indexed_db_value.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/common/content_features.h" #include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h"
#include "storage/browser/blob/blob_data_builder.h" #include "storage/browser/blob/blob_data_builder.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"
...@@ -131,7 +130,7 @@ IndexedDBCallbacks::IndexedDBValueBlob::IndexedDBValueBlob( ...@@ -131,7 +130,7 @@ IndexedDBCallbacks::IndexedDBValueBlob::IndexedDBValueBlob(
uuid_ = base::GenerateGUID(); uuid_ = base::GenerateGUID();
} }
(*blob_or_file_info)->uuid = uuid_; (*blob_or_file_info)->uuid = uuid_;
request_ = mojo::MakeRequest(&(*blob_or_file_info)->blob); receiver_ = mojo::MakeRequest(&(*blob_or_file_info)->blob);
} }
IndexedDBCallbacks::IndexedDBValueBlob::IndexedDBValueBlob( IndexedDBCallbacks::IndexedDBValueBlob::IndexedDBValueBlob(
IndexedDBValueBlob&& other) = default; IndexedDBValueBlob&& other) = default;
...@@ -201,7 +200,7 @@ bool IndexedDBCallbacks::CreateAllBlobs( ...@@ -201,7 +200,7 @@ bool IndexedDBCallbacks::CreateAllBlobs(
inner_idb_runner.get(), inner_value_blobs[i].blob_info_); inner_idb_runner.get(), inner_value_blobs[i].blob_info_);
storage::BlobImpl::Create( storage::BlobImpl::Create(
std::move(blob_data), std::move(blob_data),
std::move(inner_value_blobs[i].request_)); std::move(inner_value_blobs[i].receiver_));
} }
*inner_result = true; *inner_result = true;
}, },
......
...@@ -76,7 +76,7 @@ class CONTENT_EXPORT IndexedDBCallbacks ...@@ -76,7 +76,7 @@ class CONTENT_EXPORT IndexedDBCallbacks
const IndexedDBBlobInfo& blob_info_; const IndexedDBBlobInfo& blob_info_;
std::string uuid_; std::string uuid_;
blink::mojom::BlobRequest request_; mojo::PendingReceiver<blink::mojom::Blob> receiver_;
}; };
static bool CreateAllBlobs( static bool CreateAllBlobs(
......
...@@ -564,8 +564,9 @@ TEST_F(ServiceWorkerNavigationLoaderTest, BlobResponse) { ...@@ -564,8 +564,9 @@ TEST_F(ServiceWorkerNavigationLoaderTest, BlobResponse) {
auto blob = blink::mojom::SerializedBlob::New(); auto blob = blink::mojom::SerializedBlob::New();
blob->uuid = blob_handle->uuid(); blob->uuid = blob_handle->uuid();
blob->size = blob_handle->size(); blob->size = blob_handle->size();
blink::mojom::BlobRequest request = mojo::MakeRequest(&blob->blob); mojo::PendingReceiver<blink::mojom::Blob> receiver =
storage::BlobImpl::Create(std::move(blob_handle), std::move(request)); mojo::MakeRequest(&blob->blob);
storage::BlobImpl::Create(std::move(blob_handle), std::move(receiver));
service_worker_->RespondWithBlob(std::move(blob)); service_worker_->RespondWithBlob(std::move(blob));
// Perform the request. // Perform the request.
...@@ -604,8 +605,9 @@ TEST_F(ServiceWorkerNavigationLoaderTest, BrokenBlobResponse) { ...@@ -604,8 +605,9 @@ TEST_F(ServiceWorkerNavigationLoaderTest, BrokenBlobResponse) {
storage::BlobStatus::ERR_OUT_OF_MEMORY); storage::BlobStatus::ERR_OUT_OF_MEMORY);
auto blob = blink::mojom::SerializedBlob::New(); auto blob = blink::mojom::SerializedBlob::New();
blob->uuid = kBrokenUUID; blob->uuid = kBrokenUUID;
blink::mojom::BlobRequest request = mojo::MakeRequest(&blob->blob); mojo::PendingReceiver<blink::mojom::Blob> receiver =
storage::BlobImpl::Create(std::move(blob_handle), std::move(request)); mojo::MakeRequest(&blob->blob);
storage::BlobImpl::Create(std::move(blob_handle), std::move(receiver));
service_worker_->RespondWithBlob(std::move(blob)); service_worker_->RespondWithBlob(std::move(blob));
// Perform the request. // Perform the request.
......
...@@ -51,7 +51,9 @@ class FakeBlob final : public blink::mojom::Blob { ...@@ -51,7 +51,9 @@ class FakeBlob final : public blink::mojom::Blob {
private: private:
// Implements blink::mojom::Blob. // Implements blink::mojom::Blob.
void Clone(blink::mojom::BlobRequest) override { NOTREACHED(); } void Clone(mojo::PendingReceiver<blink::mojom::Blob>) override {
NOTREACHED();
}
void AsDataPipeGetter(network::mojom::DataPipeGetterRequest) override { void AsDataPipeGetter(network::mojom::DataPipeGetterRequest) override {
NOTREACHED(); NOTREACHED();
} }
......
...@@ -81,14 +81,15 @@ class DataPipeGetterReaderDelegate : public MojoBlobReader::Delegate { ...@@ -81,14 +81,15 @@ class DataPipeGetterReaderDelegate : public MojoBlobReader::Delegate {
} // namespace } // namespace
// static // static
base::WeakPtr<BlobImpl> BlobImpl::Create(std::unique_ptr<BlobDataHandle> handle, base::WeakPtr<BlobImpl> BlobImpl::Create(
blink::mojom::BlobRequest request) { std::unique_ptr<BlobDataHandle> handle,
return (new BlobImpl(std::move(handle), std::move(request))) mojo::PendingReceiver<blink::mojom::Blob> receiver) {
return (new BlobImpl(std::move(handle), std::move(receiver)))
->weak_ptr_factory_.GetWeakPtr(); ->weak_ptr_factory_.GetWeakPtr();
} }
void BlobImpl::Clone(blink::mojom::BlobRequest request) { void BlobImpl::Clone(mojo::PendingReceiver<blink::mojom::Blob> receiver) {
bindings_.AddBinding(this, std::move(request)); receivers_.Add(this, std::move(receiver));
} }
void BlobImpl::AsDataPipeGetter(network::mojom::DataPipeGetterRequest request) { void BlobImpl::AsDataPipeGetter(network::mojom::DataPipeGetterRequest request) {
...@@ -187,27 +188,32 @@ void BlobImpl::Read(mojo::ScopedDataPipeProducerHandle handle, ...@@ -187,27 +188,32 @@ void BlobImpl::Read(mojo::ScopedDataPipeProducerHandle handle,
} }
void BlobImpl::FlushForTesting() { void BlobImpl::FlushForTesting() {
bindings_.FlushForTesting(); auto weak_self = weak_ptr_factory_.GetWeakPtr();
receivers_.FlushForTesting();
if (!weak_self)
return;
data_pipe_getter_bindings_.FlushForTesting(); data_pipe_getter_bindings_.FlushForTesting();
if (bindings_.empty() && data_pipe_getter_bindings_.empty()) if (!weak_self)
return;
if (receivers_.empty() && data_pipe_getter_bindings_.empty())
delete this; delete this;
} }
BlobImpl::BlobImpl(std::unique_ptr<BlobDataHandle> handle, BlobImpl::BlobImpl(std::unique_ptr<BlobDataHandle> handle,
blink::mojom::BlobRequest request) mojo::PendingReceiver<blink::mojom::Blob> receiver)
: handle_(std::move(handle)) { : handle_(std::move(handle)) {
DCHECK(handle_); DCHECK(handle_);
bindings_.AddBinding(this, std::move(request)); receivers_.Add(this, std::move(receiver));
bindings_.set_connection_error_handler(base::BindRepeating( receivers_.set_disconnect_handler(
&BlobImpl::OnConnectionError, base::Unretained(this))); base::BindRepeating(&BlobImpl::OnMojoDisconnect, base::Unretained(this)));
data_pipe_getter_bindings_.set_connection_error_handler(base::BindRepeating( data_pipe_getter_bindings_.set_connection_error_handler(
&BlobImpl::OnConnectionError, base::Unretained(this))); base::BindRepeating(&BlobImpl::OnMojoDisconnect, base::Unretained(this)));
} }
BlobImpl::~BlobImpl() = default; BlobImpl::~BlobImpl() = default;
void BlobImpl::OnConnectionError() { void BlobImpl::OnMojoDisconnect() {
if (!bindings_.empty()) if (!receivers_.empty())
return; return;
if (!data_pipe_getter_bindings_.empty()) if (!data_pipe_getter_bindings_.empty())
return; return;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/component_export.h" #include "base/component_export.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/network/public/mojom/data_pipe_getter.mojom.h" #include "services/network/public/mojom/data_pipe_getter.mojom.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h" #include "third_party/blink/public/mojom/blob/blob.mojom.h"
...@@ -19,11 +20,12 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobImpl ...@@ -19,11 +20,12 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobImpl
: public blink::mojom::Blob, : public blink::mojom::Blob,
public network::mojom::DataPipeGetter { public network::mojom::DataPipeGetter {
public: public:
static base::WeakPtr<BlobImpl> Create(std::unique_ptr<BlobDataHandle> handle, static base::WeakPtr<BlobImpl> Create(
blink::mojom::BlobRequest request); std::unique_ptr<BlobDataHandle> handle,
mojo::PendingReceiver<blink::mojom::Blob> receiver);
// blink::mojom::Blob: // blink::mojom::Blob:
void Clone(blink::mojom::BlobRequest request) override; void Clone(mojo::PendingReceiver<blink::mojom::Blob> receiver) override;
void AsDataPipeGetter(network::mojom::DataPipeGetterRequest request) override; void AsDataPipeGetter(network::mojom::DataPipeGetterRequest request) override;
void ReadRange( void ReadRange(
uint64_t offset, uint64_t offset,
...@@ -45,13 +47,13 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobImpl ...@@ -45,13 +47,13 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobImpl
private: private:
BlobImpl(std::unique_ptr<BlobDataHandle> handle, BlobImpl(std::unique_ptr<BlobDataHandle> handle,
blink::mojom::BlobRequest request); mojo::PendingReceiver<blink::mojom::Blob> receiver);
~BlobImpl() override; ~BlobImpl() override;
void OnConnectionError(); void OnMojoDisconnect();
std::unique_ptr<BlobDataHandle> handle_; std::unique_ptr<BlobDataHandle> handle_;
mojo::BindingSet<blink::mojom::Blob> bindings_; mojo::ReceiverSet<blink::mojom::Blob> receivers_;
mojo::BindingSet<network::mojom::DataPipeGetter> data_pipe_getter_bindings_; mojo::BindingSet<network::mojom::DataPipeGetter> data_pipe_getter_bindings_;
base::WeakPtrFactory<BlobImpl> weak_ptr_factory_{this}; base::WeakPtrFactory<BlobImpl> weak_ptr_factory_{this};
......
...@@ -545,7 +545,7 @@ BlobReader::Status BlobReader::ReadFileItem(FileStreamReader* reader, ...@@ -545,7 +545,7 @@ BlobReader::Status BlobReader::ReadFileItem(FileStreamReader* reader,
return Status::DONE; return Status::DONE;
} }
if (result == net::ERR_IO_PENDING) { if (result == net::ERR_IO_PENDING) {
TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobRequest::ReadFileItem", this, "uuid", TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobReader::ReadFileItem", this, "uuid",
blob_data_->uuid()); blob_data_->uuid());
io_pending_ = true; io_pending_ = true;
return Status::IO_PENDING; return Status::IO_PENDING;
...@@ -555,7 +555,7 @@ BlobReader::Status BlobReader::ReadFileItem(FileStreamReader* reader, ...@@ -555,7 +555,7 @@ BlobReader::Status BlobReader::ReadFileItem(FileStreamReader* reader,
void BlobReader::DidReadFile(int result) { void BlobReader::DidReadFile(int result) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
TRACE_EVENT_ASYNC_END1("Blob", "BlobRequest::ReadFileItem", this, "uuid", TRACE_EVENT_ASYNC_END1("Blob", "BlobReader::ReadFileItem", this, "uuid",
blob_data_->uuid()); blob_data_->uuid());
DidReadItem(result); DidReadItem(result);
} }
...@@ -600,8 +600,8 @@ BlobReader::Status BlobReader::ReadReadableDataHandle(const BlobDataItem& item, ...@@ -600,8 +600,8 @@ BlobReader::Status BlobReader::ReadReadableDataHandle(const BlobDataItem& item,
return Status::DONE; return Status::DONE;
} }
if (result == net::ERR_IO_PENDING) { if (result == net::ERR_IO_PENDING) {
TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobRequest::ReadReadableDataHandle", TRACE_EVENT_ASYNC_BEGIN1("Blob", "BlobReader::ReadReadableDataHandle", this,
this, "uuid", blob_data_->uuid()); "uuid", blob_data_->uuid());
io_pending_ = true; io_pending_ = true;
return Status::IO_PENDING; return Status::IO_PENDING;
} }
...@@ -610,7 +610,7 @@ BlobReader::Status BlobReader::ReadReadableDataHandle(const BlobDataItem& item, ...@@ -610,7 +610,7 @@ BlobReader::Status BlobReader::ReadReadableDataHandle(const BlobDataItem& item,
void BlobReader::DidReadReadableDataHandle(int result) { void BlobReader::DidReadReadableDataHandle(int result) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
TRACE_EVENT_ASYNC_END1("Blob", "BlobRequest::ReadReadableDataHandle", this, TRACE_EVENT_ASYNC_END1("Blob", "BlobReader::ReadReadableDataHandle", this,
"uuid", blob_data_->uuid()); "uuid", blob_data_->uuid());
RecordBytesReadFromDataHandle(current_item_index_, result); RecordBytesReadFromDataHandle(current_item_index_, result);
DidReadItem(result); DidReadItem(result);
......
...@@ -493,7 +493,7 @@ void BlobRegistryImpl::Bind(blink::mojom::BlobRegistryRequest request, ...@@ -493,7 +493,7 @@ void BlobRegistryImpl::Bind(blink::mojom::BlobRegistryRequest request,
} }
void BlobRegistryImpl::Register( void BlobRegistryImpl::Register(
blink::mojom::BlobRequest blob, mojo::PendingReceiver<blink::mojom::Blob> blob,
const std::string& uuid, const std::string& uuid,
const std::string& content_type, const std::string& content_type,
const std::string& content_disposition, const std::string& content_disposition,
...@@ -576,9 +576,10 @@ void BlobRegistryImpl::RegisterFromStream( ...@@ -576,9 +576,10 @@ void BlobRegistryImpl::RegisterFromStream(
std::move(progress_client)); std::move(progress_client));
} }
void BlobRegistryImpl::GetBlobFromUUID(blink::mojom::BlobRequest blob, void BlobRegistryImpl::GetBlobFromUUID(
const std::string& uuid, mojo::PendingReceiver<blink::mojom::Blob> blob,
GetBlobFromUUIDCallback callback) { const std::string& uuid,
GetBlobFromUUIDCallback callback) {
if (!context_) { if (!context_) {
std::move(callback).Run(); std::move(callback).Run();
return; return;
......
...@@ -42,7 +42,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl ...@@ -42,7 +42,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl
void Bind(blink::mojom::BlobRegistryRequest request, void Bind(blink::mojom::BlobRegistryRequest request,
std::unique_ptr<Delegate> delegate); std::unique_ptr<Delegate> delegate);
void Register(blink::mojom::BlobRequest blob, void Register(mojo::PendingReceiver<blink::mojom::Blob> blob,
const std::string& uuid, const std::string& uuid,
const std::string& content_type, const std::string& content_type,
const std::string& content_disposition, const std::string& content_disposition,
...@@ -55,7 +55,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl ...@@ -55,7 +55,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl
mojo::ScopedDataPipeConsumerHandle data, mojo::ScopedDataPipeConsumerHandle data,
blink::mojom::ProgressClientAssociatedPtrInfo progress_client, blink::mojom::ProgressClientAssociatedPtrInfo progress_client,
RegisterFromStreamCallback callback) override; RegisterFromStreamCallback callback) override;
void GetBlobFromUUID(blink::mojom::BlobRequest blob, void GetBlobFromUUID(mojo::PendingReceiver<blink::mojom::Blob> blob,
const std::string& uuid, const std::string& uuid,
GetBlobFromUUIDCallback callback) override; GetBlobFromUUIDCallback callback) override;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "storage/browser/test/fake_blob.h" #include "storage/browser/test/fake_blob.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace storage { namespace storage {
...@@ -16,9 +16,9 @@ blink::mojom::BlobPtr FakeBlob::Clone() { ...@@ -16,9 +16,9 @@ blink::mojom::BlobPtr FakeBlob::Clone() {
return result; return result;
} }
void FakeBlob::Clone(blink::mojom::BlobRequest request) { void FakeBlob::Clone(mojo::PendingReceiver<blink::mojom::Blob> receiver) {
mojo::MakeStrongBinding(std::make_unique<FakeBlob>(uuid_), mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid_),
std::move(request)); std::move(receiver));
} }
void FakeBlob::AsDataPipeGetter(network::mojom::DataPipeGetterRequest) { void FakeBlob::AsDataPipeGetter(network::mojom::DataPipeGetterRequest) {
......
...@@ -16,7 +16,7 @@ class FakeBlob : public blink::mojom::Blob { ...@@ -16,7 +16,7 @@ class FakeBlob : public blink::mojom::Blob {
explicit FakeBlob(const std::string& uuid); explicit FakeBlob(const std::string& uuid);
blink::mojom::BlobPtr Clone(); blink::mojom::BlobPtr Clone();
void Clone(blink::mojom::BlobRequest request) override; void Clone(mojo::PendingReceiver<blink::mojom::Blob> receiver) override;
void AsDataPipeGetter(network::mojom::DataPipeGetterRequest) override; void AsDataPipeGetter(network::mojom::DataPipeGetterRequest) override;
void ReadRange(uint64_t offset, void ReadRange(uint64_t offset,
uint64_t size, uint64_t size,
......
...@@ -30,7 +30,7 @@ interface BlobReaderClient { ...@@ -30,7 +30,7 @@ interface BlobReaderClient {
// This interface provides access to a blob in the blob system. // This interface provides access to a blob in the blob system.
interface Blob { interface Blob {
// Creates a copy of this Blob reference. // Creates a copy of this Blob reference.
Clone(Blob& blob); Clone(pending_receiver<Blob> blob);
// Creates a reference to this Blob as a DataPipeGetter. // Creates a reference to this Blob as a DataPipeGetter.
AsDataPipeGetter(network.mojom.DataPipeGetter& data_pipe_getter); AsDataPipeGetter(network.mojom.DataPipeGetter& data_pipe_getter);
......
...@@ -27,7 +27,7 @@ interface BlobRegistry { ...@@ -27,7 +27,7 @@ interface BlobRegistry {
// Registers a new blob with the blob registry. // Registers a new blob with the blob registry.
// TODO(mek): Make this method non-sync and get rid of the UUID parameter once // TODO(mek): Make this method non-sync and get rid of the UUID parameter once
// enough of the rest of the system doesn't rely on the UUID anymore. // enough of the rest of the system doesn't rely on the UUID anymore.
[Sync] Register(blink.mojom.Blob& blob, string uuid, [Sync] Register(pending_receiver<blink.mojom.Blob> blob, string uuid,
string content_type, string content_disposition, string content_type, string content_disposition,
array<DataElement> elements) => (); array<DataElement> elements) => ();
...@@ -49,7 +49,7 @@ interface BlobRegistry { ...@@ -49,7 +49,7 @@ interface BlobRegistry {
// Returns a reference to an existing blob. Should not be used by new code, // Returns a reference to an existing blob. Should not be used by new code,
// is only exposed to make converting existing blob using code easier. // is only exposed to make converting existing blob using code easier.
// TODO(mek): Remove when crbug.com/740744 is resolved. // TODO(mek): Remove when crbug.com/740744 is resolved.
[Sync] GetBlobFromUUID(Blob& blob, string uuid) => (); [Sync] GetBlobFromUUID(pending_receiver<Blob> blob, string uuid) => ();
// Returns a BlobURLStore for a specific origin. // Returns a BlobURLStore for a specific origin.
URLStoreForOrigin(url.mojom.Origin origin, URLStoreForOrigin(url.mojom.Origin origin,
......
...@@ -22,7 +22,6 @@ namespace { ...@@ -22,7 +22,6 @@ namespace {
using mojom::blink::Blob; using mojom::blink::Blob;
using mojom::blink::BlobPtr; using mojom::blink::BlobPtr;
using mojom::blink::BlobRequest;
using mojom::blink::BlobURLStore; using mojom::blink::BlobURLStore;
using mojom::blink::BlobURLStoreAssociatedPtr; using mojom::blink::BlobURLStoreAssociatedPtr;
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/blob/blob_registry.mojom-blink.h" #include "third_party/blink/public/mojom/blob/blob_registry.mojom-blink.h"
...@@ -28,7 +27,6 @@ using mojom::blink::BlobPtr; ...@@ -28,7 +27,6 @@ using mojom::blink::BlobPtr;
using mojom::blink::BlobRegistry; using mojom::blink::BlobRegistry;
using mojom::blink::BlobRegistryPtr; using mojom::blink::BlobRegistryPtr;
using mojom::blink::BlobRegistryRequest; using mojom::blink::BlobRegistryRequest;
using mojom::blink::BlobRequest;
using mojom::blink::DataElement; using mojom::blink::DataElement;
using mojom::blink::DataElementBlob; using mojom::blink::DataElementBlob;
using mojom::blink::DataElementBytes; using mojom::blink::DataElementBytes;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "third_party/blink/renderer/platform/blob/testing/fake_blob.h" #include "third_party/blink/renderer/platform/blob/testing/fake_blob.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/data_pipe_utils.h" #include "mojo/public/cpp/system/data_pipe_utils.h"
#include "services/network/public/mojom/data_pipe_getter.mojom-blink.h" #include "services/network/public/mojom/data_pipe_getter.mojom-blink.h"
...@@ -41,9 +41,9 @@ class SimpleDataPipeGetter : public network::mojom::blink::DataPipeGetter { ...@@ -41,9 +41,9 @@ class SimpleDataPipeGetter : public network::mojom::blink::DataPipeGetter {
FakeBlob::FakeBlob(const String& uuid, const String& body, State* state) FakeBlob::FakeBlob(const String& uuid, const String& body, State* state)
: uuid_(uuid), body_(body), state_(state) {} : uuid_(uuid), body_(body), state_(state) {}
void FakeBlob::Clone(mojom::blink::BlobRequest request) { void FakeBlob::Clone(mojo::PendingReceiver<mojom::blink::Blob> receiver) {
mojo::MakeStrongBinding(std::make_unique<FakeBlob>(uuid_, body_, state_), mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid_, body_, state_),
std::move(request)); std::move(receiver));
} }
void FakeBlob::AsDataPipeGetter( void FakeBlob::AsDataPipeGetter(
......
...@@ -21,7 +21,7 @@ class FakeBlob : public mojom::blink::Blob { ...@@ -21,7 +21,7 @@ class FakeBlob : public mojom::blink::Blob {
const String& body = String(), const String& body = String(),
State* state = nullptr); State* state = nullptr);
void Clone(mojom::blink::BlobRequest) override; void Clone(mojo::PendingReceiver<mojom::blink::Blob>) override;
void AsDataPipeGetter(network::mojom::blink::DataPipeGetterRequest) override; void AsDataPipeGetter(network::mojom::blink::DataPipeGetterRequest) override;
void ReadRange(uint64_t offset, void ReadRange(uint64_t offset,
uint64_t length, uint64_t length,
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#include "third_party/blink/renderer/platform/blob/testing/fake_blob_registry.h" #include "third_party/blink/renderer/platform/blob/testing/fake_blob_registry.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/public/mojom/blob/data_element.mojom-blink.h" #include "third_party/blink/public/mojom/blob/data_element.mojom-blink.h"
#include "third_party/blink/renderer/platform/blob/testing/fake_blob.h" #include "third_party/blink/renderer/platform/blob/testing/fake_blob.h"
namespace blink { namespace blink {
void FakeBlobRegistry::Register(mojom::blink::BlobRequest blob, void FakeBlobRegistry::Register(mojo::PendingReceiver<mojom::blink::Blob> blob,
const String& uuid, const String& uuid,
const String& content_type, const String& content_type,
const String& content_disposition, const String& content_disposition,
...@@ -18,7 +18,8 @@ void FakeBlobRegistry::Register(mojom::blink::BlobRequest blob, ...@@ -18,7 +18,8 @@ void FakeBlobRegistry::Register(mojom::blink::BlobRequest blob,
RegisterCallback callback) { RegisterCallback callback) {
registrations.push_back(Registration{uuid, content_type, content_disposition, registrations.push_back(Registration{uuid, content_type, content_disposition,
std::move(elements)}); std::move(elements)});
mojo::MakeStrongBinding(std::make_unique<FakeBlob>(uuid), std::move(blob)); mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid),
std::move(blob));
std::move(callback).Run(); std::move(callback).Run();
} }
...@@ -32,11 +33,13 @@ void FakeBlobRegistry::RegisterFromStream( ...@@ -32,11 +33,13 @@ void FakeBlobRegistry::RegisterFromStream(
NOTREACHED(); NOTREACHED();
} }
void FakeBlobRegistry::GetBlobFromUUID(mojom::blink::BlobRequest blob, void FakeBlobRegistry::GetBlobFromUUID(
const String& uuid, mojo::PendingReceiver<mojom::blink::Blob> blob,
GetBlobFromUUIDCallback callback) { const String& uuid,
GetBlobFromUUIDCallback callback) {
binding_requests.push_back(BindingRequest{uuid}); binding_requests.push_back(BindingRequest{uuid});
mojo::MakeStrongBinding(std::make_unique<FakeBlob>(uuid), std::move(blob)); mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid),
std::move(blob));
std::move(callback).Run(); std::move(callback).Run();
} }
......
...@@ -14,7 +14,7 @@ namespace blink { ...@@ -14,7 +14,7 @@ namespace blink {
// FakeBlob instance with the correct uuid. // FakeBlob instance with the correct uuid.
class FakeBlobRegistry : public mojom::blink::BlobRegistry { class FakeBlobRegistry : public mojom::blink::BlobRegistry {
public: public:
void Register(mojom::blink::BlobRequest, void Register(mojo::PendingReceiver<mojom::blink::Blob>,
const String& uuid, const String& uuid,
const String& content_type, const String& content_type,
const String& content_disposition, const String& content_disposition,
...@@ -28,7 +28,7 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry { ...@@ -28,7 +28,7 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry {
mojom::blink::ProgressClientAssociatedPtrInfo, mojom::blink::ProgressClientAssociatedPtrInfo,
RegisterFromStreamCallback) override; RegisterFromStreamCallback) override;
void GetBlobFromUUID(mojom::blink::BlobRequest, void GetBlobFromUUID(mojo::PendingReceiver<mojom::blink::Blob>,
const String& uuid, const String& uuid,
GetBlobFromUUIDCallback) override; GetBlobFromUUIDCallback) override;
......
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