Commit 7ba89a98 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert BytesProvider to new Mojo types

This CL converts BytesProviderRequest and BytesProviderPtr
to new Mojo types.
It updates struct DataElementBytes from data_element.mojom
and methods and members to new Mojo types.

Bug: 955171, 978694
Change-Id: I4a1f7a2cb73581ec23596178154fc9282c25e6f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1774424
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#691982}
parent 55730c21
......@@ -58,8 +58,8 @@ class BlobRegistryImpl::BlobUnderConstruction {
private:
// Holds onto a blink::mojom::DataElement struct and optionally a bound
// blink::mojom::BytesProviderPtr or blink::mojom::BlobPtr, if the element
// encapsulates a large byte array or a blob.
// mojo::Remote<blink::mojom::BytesProvider> or blink::mojom::BlobPtr, if the
// element encapsulates a large byte array or a blob.
struct ElementEntry {
explicit ElementEntry(blink::mojom::DataElementPtr e)
: element(std::move(e)) {
......@@ -75,7 +75,7 @@ class BlobRegistryImpl::BlobUnderConstruction {
ElementEntry& operator=(ElementEntry&& other) = default;
blink::mojom::DataElementPtr element;
blink::mojom::BytesProviderPtr bytes_provider;
mojo::Remote<blink::mojom::BytesProvider> bytes_provider;
blink::mojom::BlobPtr blob;
};
......@@ -228,7 +228,7 @@ void BlobRegistryImpl::BlobUnderConstruction::StartTransportation() {
base::BindOnce(&BlobUnderConstruction::ReceivedBlobUUID,
weak_ptr_factory_.GetWeakPtr(), blob_count++));
} else if (element->is_bytes()) {
entry.bytes_provider.set_connection_error_handler(base::BindOnce(
entry.bytes_provider.set_disconnect_handler(base::BindOnce(
&BlobUnderConstruction::MarkAsBroken, weak_ptr_factory_.GetWeakPtr(),
BlobStatus::ERR_SOURCE_DIED_IN_TRANSIT, ""));
}
......
......@@ -20,6 +20,7 @@
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "storage/browser/blob/blob_data_builder.h"
......@@ -47,9 +48,10 @@ const uint64_t kTestBlobStorageMaxDiskSpace = 4000;
const uint64_t kTestBlobStorageMinFileSizeBytes = 10;
const uint64_t kTestBlobStorageMaxFileSizeBytes = 100;
void BindBytesProvider(std::unique_ptr<MockBytesProvider> impl,
blink::mojom::BytesProviderRequest request) {
mojo::MakeStrongBinding(std::move(impl), std::move(request));
void BindBytesProvider(
std::unique_ptr<MockBytesProvider> impl,
mojo::PendingReceiver<blink::mojom::BytesProvider> receiver) {
mojo::MakeSelfOwnedReceiver(std::move(impl), std::move(receiver));
}
} // namespace
......@@ -140,24 +142,25 @@ class BlobRegistryImplTest : public testing::Test {
loop.Run();
}
blink::mojom::BytesProviderPtrInfo CreateBytesProvider(
mojo::PendingRemote<blink::mojom::BytesProvider> CreateBytesProvider(
const std::string& bytes) {
if (!bytes_provider_runner_) {
bytes_provider_runner_ = base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock()});
}
blink::mojom::BytesProviderPtrInfo result;
mojo::PendingRemote<blink::mojom::BytesProvider> result;
auto provider = std::make_unique<MockBytesProvider>(
std::vector<uint8_t>(bytes.begin(), bytes.end()), &reply_request_count_,
&stream_request_count_, &file_request_count_);
bytes_provider_runner_->PostTask(
FROM_HERE, base::BindOnce(&BindBytesProvider, std::move(provider),
MakeRequest(&result)));
result.InitWithNewPipeAndPassReceiver()));
return result;
}
void CreateBytesProvider(const std::string& bytes,
blink::mojom::BytesProviderRequest request) {
void CreateBytesProvider(
const std::string& bytes,
mojo::PendingReceiver<blink::mojom::BytesProvider> receiver) {
if (!bytes_provider_runner_) {
bytes_provider_runner_ = base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock()});
......@@ -167,7 +170,7 @@ class BlobRegistryImplTest : public testing::Test {
&stream_request_count_, &file_request_count_);
bytes_provider_runner_->PostTask(
FROM_HERE, base::BindOnce(&BindBytesProvider, std::move(provider),
std::move(request)));
std::move(receiver)));
}
size_t BlobsUnderConstruction() {
......@@ -842,13 +845,13 @@ TEST_F(BlobRegistryImplTest, Register_ValidBytesAsFile) {
TEST_F(BlobRegistryImplTest, Register_BytesProviderClosedPipe) {
const std::string kId = "id";
blink::mojom::BytesProviderPtrInfo bytes_provider_info;
MakeRequest(&bytes_provider_info);
mojo::PendingRemote<blink::mojom::BytesProvider> bytes_provider_remote;
ignore_result(bytes_provider_remote.InitWithNewPipeAndPassReceiver());
std::vector<blink::mojom::DataElementPtr> elements;
elements.push_back(
blink::mojom::DataElement::NewBytes(blink::mojom::DataElementBytes::New(
32, base::nullopt, std::move(bytes_provider_info))));
32, base::nullopt, std::move(bytes_provider_remote))));
blink::mojom::BlobPtr blob;
EXPECT_TRUE(registry_->Register(MakeRequest(&blob), kId, "", "",
......@@ -867,13 +870,13 @@ TEST_F(BlobRegistryImplTest,
Register_DefereferencedWhileBuildingBeforeBreaking) {
const std::string kId = "id";
blink::mojom::BytesProviderPtrInfo bytes_provider_info;
auto request = MakeRequest(&bytes_provider_info);
mojo::PendingRemote<blink::mojom::BytesProvider> bytes_provider_remote;
auto receiver = bytes_provider_remote.InitWithNewPipeAndPassReceiver();
std::vector<blink::mojom::DataElementPtr> elements;
elements.push_back(
blink::mojom::DataElement::NewBytes(blink::mojom::DataElementBytes::New(
32, base::nullopt, std::move(bytes_provider_info))));
32, base::nullopt, std::move(bytes_provider_remote))));
blink::mojom::BlobPtr blob;
EXPECT_TRUE(registry_->Register(MakeRequest(&blob), kId, "", "",
......@@ -891,7 +894,7 @@ TEST_F(BlobRegistryImplTest,
EXPECT_FALSE(context_->registry().HasEntry(kId));
// Now cause construction to fail, if it would still be going on.
request = nullptr;
receiver.reset();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0u, BlobsUnderConstruction());
}
......@@ -945,13 +948,13 @@ TEST_F(BlobRegistryImplTest,
const std::string kId = "id";
const std::string kData = "hello world";
blink::mojom::BytesProviderPtrInfo bytes_provider_info;
auto request = MakeRequest(&bytes_provider_info);
mojo::PendingRemote<blink::mojom::BytesProvider> bytes_provider_remote;
auto receiver = bytes_provider_remote.InitWithNewPipeAndPassReceiver();
std::vector<blink::mojom::DataElementPtr> elements;
elements.push_back(
blink::mojom::DataElement::NewBytes(blink::mojom::DataElementBytes::New(
kData.size(), base::nullopt, std::move(bytes_provider_info))));
kData.size(), base::nullopt, std::move(bytes_provider_remote))));
blink::mojom::BlobPtr blob;
EXPECT_TRUE(registry_->Register(MakeRequest(&blob), kId, "", "",
......@@ -969,7 +972,7 @@ TEST_F(BlobRegistryImplTest,
EXPECT_FALSE(context_->registry().HasEntry(kId));
// Now cause construction to complete, if it would still be going on.
CreateBytesProvider(kData, std::move(request));
CreateBytesProvider(kData, std::move(receiver));
task_environment_.RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0u, BlobsUnderConstruction());
......@@ -981,13 +984,13 @@ TEST_F(BlobRegistryImplTest,
const std::string kData =
base::RandBytesAsString(kTestBlobStorageMaxBlobMemorySize + 42);
blink::mojom::BytesProviderPtrInfo bytes_provider_info;
auto request = MakeRequest(&bytes_provider_info);
mojo::PendingRemote<blink::mojom::BytesProvider> bytes_provider_remote;
auto receiver = bytes_provider_remote.InitWithNewPipeAndPassReceiver();
std::vector<blink::mojom::DataElementPtr> elements;
elements.push_back(
blink::mojom::DataElement::NewBytes(blink::mojom::DataElementBytes::New(
kData.size(), base::nullopt, std::move(bytes_provider_info))));
kData.size(), base::nullopt, std::move(bytes_provider_remote))));
blink::mojom::BlobPtr blob;
EXPECT_TRUE(registry_->Register(MakeRequest(&blob), kId, "", "",
......@@ -1005,7 +1008,7 @@ TEST_F(BlobRegistryImplTest,
EXPECT_FALSE(context_->registry().HasEntry(kId));
// Now cause construction to complete, if it would still be going on.
CreateBytesProvider(kData, std::move(request));
CreateBytesProvider(kData, std::move(receiver));
task_environment_.RunUntilIdle();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0u, BlobsUnderConstruction());
......
......@@ -26,8 +26,9 @@ class NoneNeededTransportStrategy : public BlobTransportStrategy {
ResultCallback result_callback)
: BlobTransportStrategy(builder, std::move(result_callback)) {}
void AddBytesElement(blink::mojom::DataElementBytes* bytes,
const blink::mojom::BytesProviderPtr& data) override {
void AddBytesElement(
blink::mojom::DataElementBytes* bytes,
const mojo::Remote<blink::mojom::BytesProvider>& data) override {
DCHECK(bytes->embedded_data);
DCHECK_EQ(bytes->length, bytes->embedded_data->size());
builder_->AppendData(
......@@ -48,8 +49,9 @@ class ReplyTransportStrategy : public BlobTransportStrategy {
ResultCallback result_callback)
: BlobTransportStrategy(builder, std::move(result_callback)) {}
void AddBytesElement(blink::mojom::DataElementBytes* bytes,
const blink::mojom::BytesProviderPtr& data) override {
void AddBytesElement(
blink::mojom::DataElementBytes* bytes,
const mojo::Remote<blink::mojom::BytesProvider>& data) override {
BlobDataBuilder::FutureData future_data =
builder_->AppendFutureData(bytes->length);
// base::Unretained is safe because |this| is guaranteed (by the contract
......@@ -109,8 +111,9 @@ class DataPipeTransportStrategy : public BlobTransportStrategy {
mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC,
base::SequencedTaskRunnerHandle::Get()) {}
void AddBytesElement(blink::mojom::DataElementBytes* bytes,
const blink::mojom::BytesProviderPtr& data) override {
void AddBytesElement(
blink::mojom::DataElementBytes* bytes,
const mojo::Remote<blink::mojom::BytesProvider>& data) override {
// Split up the data in |max_bytes_data_item_size| sized chunks.
std::vector<BlobDataBuilder::FutureData> future_data;
for (uint64_t source_offset = 0; source_offset < bytes->length;
......@@ -260,8 +263,9 @@ class FileTransportStrategy : public BlobTransportStrategy {
: BlobTransportStrategy(builder, std::move(result_callback)),
limits_(limits) {}
void AddBytesElement(blink::mojom::DataElementBytes* bytes,
const blink::mojom::BytesProviderPtr& data) override {
void AddBytesElement(
blink::mojom::DataElementBytes* bytes,
const mojo::Remote<blink::mojom::BytesProvider>& data) override {
uint64_t source_offset = 0;
while (source_offset < bytes->length) {
if (current_file_size_ >= limits_.max_file_size ||
......
......@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "base/component_export.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "storage/browser/blob/blob_memory_controller.h"
#include "third_party/blink/public/mojom/blob/blob_registry.mojom.h"
......@@ -35,8 +36,9 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobTransportStrategy {
// outlive the BlobTransportStrategy instance. If |data| is bound, this call
// may use it to acquire the bytes asynchronously rather than reading from
// |bytes|.
virtual void AddBytesElement(blink::mojom::DataElementBytes* bytes,
const blink::mojom::BytesProviderPtr& data) = 0;
virtual void AddBytesElement(
blink::mojom::DataElementBytes* bytes,
const mojo::Remote<blink::mojom::BytesProvider>& data) = 0;
// Called when quota has been allocated and transportation should begin.
// Implementations will call the |result_callback_| when transportation has
......
......@@ -16,7 +16,7 @@
#include "base/test/task_environment.h"
#include "base/threading/thread_restrictions.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "storage/browser/blob/blob_data_builder.h"
#include "storage/browser/test/mock_bytes_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -40,9 +40,10 @@ const uint64_t kTestBlobStorageMaxFileSizeBytes = 100;
const char kId[] = "blob-id";
void BindBytesProvider(std::unique_ptr<MockBytesProvider> impl,
blink::mojom::BytesProviderRequest request) {
mojo::MakeStrongBinding(std::move(impl), std::move(request));
void BindBytesProvider(
std::unique_ptr<MockBytesProvider> impl,
mojo::PendingReceiver<blink::mojom::BytesProvider> receiver) {
mojo::MakeSelfOwnedReceiver(std::move(impl), std::move(receiver));
}
class BlobTransportStrategyTest : public testing::Test {
......@@ -81,16 +82,16 @@ class BlobTransportStrategyTest : public testing::Test {
bad_messages_.push_back(error);
}
blink::mojom::BytesProviderPtr CreateBytesProvider(
mojo::PendingRemote<blink::mojom::BytesProvider> CreateBytesProvider(
const std::string& bytes,
base::Optional<base::Time> time) {
blink::mojom::BytesProviderPtr result;
mojo::PendingRemote<blink::mojom::BytesProvider> result;
auto provider = std::make_unique<MockBytesProvider>(
std::vector<uint8_t>(bytes.begin(), bytes.end()), &reply_request_count_,
&stream_request_count_, &file_request_count_, time);
bytes_provider_runner_->PostTask(
FROM_HERE, base::BindOnce(&BindBytesProvider, std::move(provider),
MakeRequest(&result)));
result.InitWithNewPipeAndPassReceiver()));
return result;
}
......@@ -157,21 +158,27 @@ TEST_P(BasicTests, WithBytes) {
std::string data = base::RandBytesAsString(7);
blink::mojom::DataElementBytes bytes1(
data.size(), std::vector<uint8_t>(data.begin(), data.end()), nullptr);
auto bytes_provider1 = CreateBytesProvider(data, mock_time_);
data.size(), std::vector<uint8_t>(data.begin(), data.end()),
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider1(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes1, bytes_provider1);
expected.AppendData(data);
data = base::RandBytesAsString(3);
blink::mojom::DataElementBytes bytes2(
data.size(), std::vector<uint8_t>(data.begin(), data.end()), nullptr);
auto bytes_provider2 = CreateBytesProvider(data, mock_time_);
data.size(), std::vector<uint8_t>(data.begin(), data.end()),
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider2(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes2, bytes_provider2);
expected.AppendData(data);
data = base::RandBytesAsString(10);
blink::mojom::DataElementBytes bytes3(data.size(), base::nullopt, nullptr);
auto bytes_provider3 = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes3(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider3(
CreateBytesProvider(data, mock_time_));
if (GetParam() != MemoryStrategy::NONE_NEEDED) {
strategy->AddBytesElement(&bytes3, bytes_provider3);
expected.AppendData(data);
......@@ -229,8 +236,10 @@ TEST_P(BasicErrorTests, NotEnoughBytesInProvider) {
limits_);
std::string data = base::RandBytesAsString(7);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt, nullptr);
auto bytes_provider = CreateBytesProvider(data.substr(0, 4), mock_time_);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider(
CreateBytesProvider(data.substr(0, 4), mock_time_));
strategy->AddBytesElement(&bytes, bytes_provider);
strategy->BeginTransport(FileInfoVector());
......@@ -257,8 +266,10 @@ TEST_P(BasicErrorTests, TooManyBytesInProvider) {
limits_);
std::string data = base::RandBytesAsString(4);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt, nullptr);
auto bytes_provider = CreateBytesProvider(data + "foobar", mock_time_);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider(
CreateBytesProvider(data + "foobar", mock_time_));
strategy->AddBytesElement(&bytes, bytes_provider);
strategy->BeginTransport(FileInfoVector());
......@@ -297,8 +308,10 @@ TEST_F(BlobTransportStrategyTest, DataStreamChunksData) {
std::string data =
base::RandBytesAsString(kTestBlobStorageMaxSharedMemoryBytes * 3 + 13);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt, nullptr);
auto bytes_provider = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes, bytes_provider);
size_t offset = 0;
......@@ -363,8 +376,10 @@ TEST_F(BlobTransportStrategyTest, Files_WriteFailed) {
limits_);
std::string data = base::RandBytesAsString(kTestBlobStorageMaxFileSizeBytes);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt, nullptr);
auto bytes_provider = CreateBytesProvider(data, base::nullopt);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider(
CreateBytesProvider(data, base::nullopt));
strategy->AddBytesElement(&bytes, bytes_provider);
FileInfoVector files(1);
......@@ -405,8 +420,10 @@ TEST_F(BlobTransportStrategyTest, Files_ValidBytesOneElement) {
std::string data =
base::RandBytesAsString(kTestBlobStorageMaxBlobMemorySize + 42);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt, nullptr);
auto bytes_provider = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes, bytes_provider);
size_t expected_file_count =
......@@ -459,17 +476,25 @@ TEST_F(BlobTransportStrategyTest, Files_ValidBytesMultipleElements) {
std::string data =
base::RandBytesAsString(kTestBlobStorageMaxBlobMemorySize / 3);
blink::mojom::DataElementBytes bytes1(data.size(), base::nullopt, nullptr);
auto bytes_provider1 = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes1(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider1(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes1, bytes_provider1);
blink::mojom::DataElementBytes bytes2(data.size(), base::nullopt, nullptr);
auto bytes_provider2 = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes2(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider2(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes2, bytes_provider2);
blink::mojom::DataElementBytes bytes3(data.size(), base::nullopt, nullptr);
auto bytes_provider3 = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes3(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider3(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes3, bytes_provider3);
blink::mojom::DataElementBytes bytes4(data.size(), base::nullopt, nullptr);
auto bytes_provider4 = CreateBytesProvider(data, mock_time_);
blink::mojom::DataElementBytes bytes4(data.size(), base::nullopt,
mojo::NullRemote());
mojo::Remote<blink::mojom::BytesProvider> bytes_provider4(
CreateBytesProvider(data, mock_time_));
strategy->AddBytesElement(&bytes4, bytes_provider4);
size_t expected_file_count =
......
......@@ -38,7 +38,7 @@ struct DataElementBytes {
// equal to |length|.
array<uint8>? embedded_data;
// Interface through which the blob registry can request the data.
BytesProvider data;
pending_remote<BytesProvider> data;
};
// Interface through which the blob registry can request data when it is ready
......
......@@ -6,7 +6,7 @@
#include "base/numerics/safe_conversions.h"
#include "base/task/post_task.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
......@@ -116,7 +116,7 @@ constexpr size_t BlobBytesProvider::kMaxConsolidatedItemSizeInBytes;
// static
BlobBytesProvider* BlobBytesProvider::CreateAndBind(
mojom::blink::BytesProviderRequest request) {
mojo::PendingReceiver<mojom::blink::BytesProvider> receiver) {
auto task_runner = base::CreateSequencedTaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE});
auto provider = base::WrapUnique(new BlobBytesProvider(task_runner));
......@@ -127,10 +127,11 @@ BlobBytesProvider* BlobBytesProvider::CreateAndBind(
*task_runner, FROM_HERE,
CrossThreadBindOnce(
[](std::unique_ptr<BlobBytesProvider> provider,
mojom::blink::BytesProviderRequest request) {
mojo::MakeStrongBinding(std::move(provider), std::move(request));
mojo::PendingReceiver<mojom::blink::BytesProvider> receiver) {
mojo::MakeSelfOwnedReceiver(std::move(provider),
std::move(receiver));
},
WTF::Passed(std::move(provider)), WTF::Passed(std::move(request))));
WTF::Passed(std::move(provider)), WTF::Passed(std::move(receiver))));
return result;
}
......
......@@ -28,7 +28,8 @@ class PLATFORM_EXPORT BlobBytesProvider : public mojom::blink::BytesProvider {
// Creates a new instance, and binds it on a new SequencedTaskRunner. The
// returned instance should only be considered valid as long as the request
// passed in to this method is still known to be valid.
static BlobBytesProvider* CreateAndBind(mojom::blink::BytesProviderRequest);
static BlobBytesProvider* CreateAndBind(
mojo::PendingReceiver<mojom::blink::BytesProvider>);
static std::unique_ptr<BlobBytesProvider> CreateForTesting(
scoped_refptr<base::SequencedTaskRunner>);
......
......@@ -57,16 +57,14 @@ namespace blink {
using mojom::blink::BlobPtr;
using mojom::blink::BlobPtrInfo;
using mojom::blink::BytesProviderPtr;
using mojom::blink::BytesProviderPtrInfo;
using mojom::blink::BytesProviderRequest;
using mojom::blink::BytesProvider;
using mojom::blink::DataElement;
using mojom::blink::DataElementBlob;
using mojom::blink::DataElementPtr;
using mojom::blink::DataElementBytes;
using mojom::blink::DataElementBytesPtr;
using mojom::blink::DataElementFile;
using mojom::blink::DataElementFilesystemURL;
using mojom::blink::DataElementPtr;
namespace {
......@@ -286,12 +284,12 @@ void BlobData::AppendDataInternal(base::span<const char> data,
bytes_element->embedded_data = base::nullopt;
}
} else {
BytesProviderPtrInfo bytes_provider_info;
last_bytes_provider_ =
BlobBytesProvider::CreateAndBind(MakeRequest(&bytes_provider_info));
mojo::PendingRemote<BytesProvider> bytes_provider_remote;
last_bytes_provider_ = BlobBytesProvider::CreateAndBind(
bytes_provider_remote.InitWithNewPipeAndPassReceiver());
auto bytes_element = DataElementBytes::New(data.size(), base::nullopt,
std::move(bytes_provider_info));
auto bytes_element = DataElementBytes::New(
data.size(), base::nullopt, std::move(bytes_provider_remote));
if (should_embed_bytes) {
bytes_element->embedded_data = Vector<uint8_t>();
bytes_element->embedded_data->Append(data.data(), data.size());
......
......@@ -42,14 +42,14 @@ struct ExpectedElement {
static ExpectedElement EmbeddedBytes(Vector<uint8_t> embedded_data) {
uint64_t size = embedded_data.size();
return ExpectedElement{DataElement::NewBytes(
DataElementBytes::New(size, std::move(embedded_data), nullptr))};
return ExpectedElement{DataElement::NewBytes(DataElementBytes::New(
size, std::move(embedded_data), mojo::NullRemote()))};
}
static ExpectedElement LargeBytes(Vector<uint8_t> data) {
uint64_t size = data.size();
return ExpectedElement{DataElement::NewBytes(DataElementBytes::New(
size, base::nullopt, nullptr)),
size, base::nullopt, mojo::NullRemote())),
String(), std::move(data)};
}
......@@ -165,7 +165,7 @@ class BlobDataHandleTest : public testing::Test {
base::RunLoop loop;
Vector<uint8_t> received_bytes;
mojom::blink::BytesProviderPtr actual_data(
mojo::Remote<mojom::blink::BytesProvider> actual_data(
std::move(actual->get_bytes()->data));
actual_data->RequestAsReply(base::BindOnce(
[](base::Closure quit_closure, Vector<uint8_t>* bytes_out,
......
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