Commit 74debd20 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert BlobURLStore to new Mojo types

This CL converts BlobURLStoreAssociatedRequest,
BlobURLStoreAssociatedPtr, BlobURLStorePtr, and
BlobURLStoreAssociatedRequest to new Mojo types.
It updates URLStoreForOrigin from blob_registry.mojom and
methods and members with new Mojo types.

Bug: 955171, 978694
Change-Id: I4206429d8d46cd9321ec871599818153ef9d1fe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1772790Reviewed-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@{#691550}
parent 19206c68
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "base/barrier_closure.h" #include "base/barrier_closure.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "storage/browser/blob/blob_builder_from_stream.h" #include "storage/browser/blob/blob_builder_from_stream.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"
...@@ -603,17 +601,17 @@ void BlobRegistryImpl::GetBlobFromUUID( ...@@ -603,17 +601,17 @@ void BlobRegistryImpl::GetBlobFromUUID(
void BlobRegistryImpl::URLStoreForOrigin( void BlobRegistryImpl::URLStoreForOrigin(
const url::Origin& origin, const url::Origin& origin,
blink::mojom::BlobURLStoreAssociatedRequest request) { mojo::PendingAssociatedReceiver<blink::mojom::BlobURLStore> receiver) {
// TODO(mek): Pass origin on to BlobURLStoreImpl so it can use it to generate // TODO(mek): Pass origin on to BlobURLStoreImpl so it can use it to generate
// Blob URLs, and verify at this point that the renderer can create URLs for // Blob URLs, and verify at this point that the renderer can create URLs for
// that origin. // that origin.
Delegate* delegate = receivers_.current_context().get(); Delegate* delegate = receivers_.current_context().get();
DCHECK(delegate); DCHECK(delegate);
auto binding = mojo::MakeStrongAssociatedBinding( auto self_owned_associated_receiver = mojo::MakeSelfOwnedAssociatedReceiver(
std::make_unique<BlobURLStoreImpl>(context_, delegate), std::make_unique<BlobURLStoreImpl>(context_, delegate),
std::move(request)); std::move(receiver));
if (g_url_store_creation_hook) if (g_url_store_creation_hook)
g_url_store_creation_hook->Run(binding); g_url_store_creation_hook->Run(self_owned_associated_receiver);
} }
// static // static
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/containers/flat_set.h" #include "base/containers/flat_set.h"
#include "base/containers/unique_ptr_adapters.h" #include "base/containers/unique_ptr_adapters.h"
#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
#include "storage/browser/fileapi/file_system_context.h" #include "storage/browser/fileapi/file_system_context.h"
#include "third_party/blink/public/mojom/blob/blob_registry.mojom.h" #include "third_party/blink/public/mojom/blob/blob_registry.mojom.h"
...@@ -62,7 +62,8 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl ...@@ -62,7 +62,8 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl
void URLStoreForOrigin( void URLStoreForOrigin(
const url::Origin& origin, const url::Origin& origin,
blink::mojom::BlobURLStoreAssociatedRequest url_store) override; mojo::PendingAssociatedReceiver<blink::mojom::BlobURLStore> url_store)
override;
size_t BlobsUnderConstructionForTesting() const { size_t BlobsUnderConstructionForTesting() const {
return blobs_under_construction_.size(); return blobs_under_construction_.size();
...@@ -73,7 +74,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl ...@@ -73,7 +74,7 @@ class COMPONENT_EXPORT(STORAGE_BROWSER) BlobRegistryImpl
} }
using URLStoreCreationHook = base::RepeatingCallback<void( using URLStoreCreationHook = base::RepeatingCallback<void(
mojo::StrongAssociatedBindingPtr<blink::mojom::BlobURLStore>)>; mojo::SelfOwnedAssociatedReceiverRef<blink::mojom::BlobURLStore>)>;
static void SetURLStoreCreationHookForTesting(URLStoreCreationHook* hook); static void SetURLStoreCreationHookForTesting(URLStoreCreationHook* hook);
private: private:
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "mojo/core/embedder/embedder.h" #include "mojo/core/embedder/embedder.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/simple_url_loader.h" #include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
...@@ -20,7 +21,6 @@ ...@@ -20,7 +21,6 @@
using blink::mojom::BlobPtr; using blink::mojom::BlobPtr;
using blink::mojom::BlobURLStore; using blink::mojom::BlobURLStore;
using blink::mojom::BlobURLStorePtr;
namespace storage { namespace storage {
...@@ -67,11 +67,11 @@ class BlobURLStoreImplTest : public testing::Test { ...@@ -67,11 +67,11 @@ class BlobURLStoreImplTest : public testing::Test {
return received_uuid; return received_uuid;
} }
BlobURLStorePtr CreateURLStore() { mojo::PendingRemote<BlobURLStore> CreateURLStore() {
BlobURLStorePtr result; mojo::PendingRemote<BlobURLStore> result;
mojo::MakeStrongBinding( mojo::MakeSelfOwnedReceiver(
std::make_unique<BlobURLStoreImpl>(context_->AsWeakPtr(), &delegate_), std::make_unique<BlobURLStoreImpl>(context_->AsWeakPtr(), &delegate_),
MakeRequest(&result)); result.InitWithNewPipeAndPassReceiver());
return result; return result;
} }
...@@ -132,7 +132,7 @@ TEST_F(BlobURLStoreImplTest, BasicRegisterRevoke) { ...@@ -132,7 +132,7 @@ TEST_F(BlobURLStoreImplTest, BasicRegisterRevoke) {
TEST_F(BlobURLStoreImplTest, RegisterInvalidScheme) { TEST_F(BlobURLStoreImplTest, RegisterInvalidScheme) {
BlobPtr blob = CreateBlobFromString(kId, "hello world"); BlobPtr blob = CreateBlobFromString(kId, "hello world");
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
RegisterURL(url_store.get(), std::move(blob), kInvalidUrl); RegisterURL(url_store.get(), std::move(blob), kInvalidUrl);
EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kInvalidUrl)); EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kInvalidUrl));
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
...@@ -143,7 +143,7 @@ TEST_F(BlobURLStoreImplTest, RegisterCantCommit) { ...@@ -143,7 +143,7 @@ TEST_F(BlobURLStoreImplTest, RegisterCantCommit) {
delegate_.can_commit_url_result = false; delegate_.can_commit_url_result = false;
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
RegisterURL(url_store.get(), std::move(blob), kValidUrl); RegisterURL(url_store.get(), std::move(blob), kValidUrl);
EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kValidUrl)); EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kValidUrl));
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
...@@ -152,7 +152,7 @@ TEST_F(BlobURLStoreImplTest, RegisterCantCommit) { ...@@ -152,7 +152,7 @@ TEST_F(BlobURLStoreImplTest, RegisterCantCommit) {
TEST_F(BlobURLStoreImplTest, RegisterUrlFragment) { TEST_F(BlobURLStoreImplTest, RegisterUrlFragment) {
BlobPtr blob = CreateBlobFromString(kId, "hello world"); BlobPtr blob = CreateBlobFromString(kId, "hello world");
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
RegisterURL(url_store.get(), std::move(blob), kFragmentUrl); RegisterURL(url_store.get(), std::move(blob), kFragmentUrl);
EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kFragmentUrl)); EXPECT_FALSE(context_->GetBlobDataFromPublicURL(kFragmentUrl));
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
...@@ -191,7 +191,7 @@ TEST_F(BlobURLStoreImplTest, RevokeThroughDifferentURLStore) { ...@@ -191,7 +191,7 @@ TEST_F(BlobURLStoreImplTest, RevokeThroughDifferentURLStore) {
} }
TEST_F(BlobURLStoreImplTest, RevokeInvalidScheme) { TEST_F(BlobURLStoreImplTest, RevokeInvalidScheme) {
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
url_store->Revoke(kInvalidUrl); url_store->Revoke(kInvalidUrl);
url_store.FlushForTesting(); url_store.FlushForTesting();
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
...@@ -200,7 +200,7 @@ TEST_F(BlobURLStoreImplTest, RevokeInvalidScheme) { ...@@ -200,7 +200,7 @@ TEST_F(BlobURLStoreImplTest, RevokeInvalidScheme) {
TEST_F(BlobURLStoreImplTest, RevokeCantCommit) { TEST_F(BlobURLStoreImplTest, RevokeCantCommit) {
delegate_.can_commit_url_result = false; delegate_.can_commit_url_result = false;
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
url_store->Revoke(kValidUrl); url_store->Revoke(kValidUrl);
url_store.FlushForTesting(); url_store.FlushForTesting();
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
...@@ -210,7 +210,7 @@ TEST_F(BlobURLStoreImplTest, RevokeCantCommit_ProcessNotValid) { ...@@ -210,7 +210,7 @@ TEST_F(BlobURLStoreImplTest, RevokeCantCommit_ProcessNotValid) {
delegate_.can_commit_url_result = false; delegate_.can_commit_url_result = false;
delegate_.is_process_valid_result = false; delegate_.is_process_valid_result = false;
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
url_store->Revoke(kValidUrl); url_store->Revoke(kValidUrl);
url_store.FlushForTesting(); url_store.FlushForTesting();
EXPECT_TRUE(bad_messages_.empty()); EXPECT_TRUE(bad_messages_.empty());
...@@ -218,7 +218,7 @@ TEST_F(BlobURLStoreImplTest, RevokeCantCommit_ProcessNotValid) { ...@@ -218,7 +218,7 @@ TEST_F(BlobURLStoreImplTest, RevokeCantCommit_ProcessNotValid) {
} }
TEST_F(BlobURLStoreImplTest, RevokeURLWithFragment) { TEST_F(BlobURLStoreImplTest, RevokeURLWithFragment) {
BlobURLStorePtr url_store = CreateURLStore(); mojo::Remote<BlobURLStore> url_store(CreateURLStore());
url_store->Revoke(kFragmentUrl); url_store->Revoke(kFragmentUrl);
url_store.FlushForTesting(); url_store.FlushForTesting();
EXPECT_EQ(1u, bad_messages_.size()); EXPECT_EQ(1u, bad_messages_.size());
......
...@@ -53,5 +53,5 @@ interface BlobRegistry { ...@@ -53,5 +53,5 @@ interface BlobRegistry {
// Returns a BlobURLStore for a specific origin. // Returns a BlobURLStore for a specific origin.
URLStoreForOrigin(url.mojom.Origin origin, URLStoreForOrigin(url.mojom.Origin origin,
associated blink.mojom.BlobURLStore& url_store); pending_associated_receiver<blink.mojom.BlobURLStore> url_store);
}; };
...@@ -117,7 +117,7 @@ String PublicURLManager::RegisterURL(URLRegistrable* registrable) { ...@@ -117,7 +117,7 @@ String PublicURLManager::RegisterURL(URLRegistrable* registrable) {
SCOPED_UMA_HISTOGRAM_TIMER("Storage.Blob.RegisterPublicURLTime"); SCOPED_UMA_HISTOGRAM_TIMER("Storage.Blob.RegisterPublicURLTime");
if (!url_store_) { if (!url_store_) {
BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin( BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin(
origin, MakeRequest(&url_store_)); origin, url_store_.BindNewEndpointAndPassReceiver());
} }
url_store_->Register(std::move(blob), url); url_store_->Register(std::move(blob), url);
mojo_urls_.insert(url_string); mojo_urls_.insert(url_string);
...@@ -144,7 +144,8 @@ void PublicURLManager::Revoke(const KURL& url) { ...@@ -144,7 +144,8 @@ void PublicURLManager::Revoke(const KURL& url) {
if (!url_store_) { if (!url_store_) {
BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin( BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin(
GetExecutionContext()->GetSecurityOrigin(), MakeRequest(&url_store_)); GetExecutionContext()->GetSecurityOrigin(),
url_store_.BindNewEndpointAndPassReceiver());
} }
url_store_->Revoke(url); url_store_->Revoke(url);
mojo_urls_.erase(url.GetString()); mojo_urls_.erase(url.GetString());
...@@ -166,7 +167,8 @@ void PublicURLManager::Resolve( ...@@ -166,7 +167,8 @@ void PublicURLManager::Resolve(
DCHECK(url.ProtocolIs("blob")); DCHECK(url.ProtocolIs("blob"));
if (!url_store_) { if (!url_store_) {
BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin( BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin(
GetExecutionContext()->GetSecurityOrigin(), MakeRequest(&url_store_)); GetExecutionContext()->GetSecurityOrigin(),
url_store_.BindNewEndpointAndPassReceiver());
} }
url_store_->ResolveAsURLLoaderFactory(url, std::move(factory_request)); url_store_->ResolveAsURLLoaderFactory(url, std::move(factory_request));
} }
...@@ -180,7 +182,8 @@ void PublicURLManager::Resolve( ...@@ -180,7 +182,8 @@ void PublicURLManager::Resolve(
DCHECK(url.ProtocolIs("blob")); DCHECK(url.ProtocolIs("blob"));
if (!url_store_) { if (!url_store_) {
BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin( BlobDataHandle::GetBlobRegistry()->URLStoreForOrigin(
GetExecutionContext()->GetSecurityOrigin(), MakeRequest(&url_store_)); GetExecutionContext()->GetSecurityOrigin(),
url_store_.BindNewEndpointAndPassReceiver());
} }
url_store_->ResolveForNavigation(url, std::move(token_request)); url_store_->ResolveForNavigation(url, std::move(token_request));
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FILEAPI_PUBLIC_URL_MANAGER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FILEAPI_PUBLIC_URL_MANAGER_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_FILEAPI_PUBLIC_URL_MANAGER_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_FILEAPI_PUBLIC_URL_MANAGER_H_
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "services/network/public/mojom/url_loader_factory.mojom-blink.h" #include "services/network/public/mojom/url_loader_factory.mojom-blink.h"
#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 "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
...@@ -71,7 +72,7 @@ class CORE_EXPORT PublicURLManager final ...@@ -71,7 +72,7 @@ class CORE_EXPORT PublicURLManager final
void Trace(blink::Visitor*) override; void Trace(blink::Visitor*) override;
void SetURLStoreForTesting( void SetURLStoreForTesting(
mojom::blink::BlobURLStoreAssociatedPtr url_store) { mojo::AssociatedRemote<mojom::blink::BlobURLStore> url_store) {
url_store_ = std::move(url_store); url_store_ = std::move(url_store);
} }
...@@ -84,7 +85,7 @@ class CORE_EXPORT PublicURLManager final ...@@ -84,7 +85,7 @@ class CORE_EXPORT PublicURLManager final
bool is_stopped_; bool is_stopped_;
mojom::blink::BlobURLStoreAssociatedPtr url_store_; mojo::AssociatedRemote<mojom::blink::BlobURLStore> url_store_;
}; };
} // namespace blink } // namespace blink
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "third_party/blink/renderer/core/fileapi/public_url_manager.h" #include "third_party/blink/renderer/core/fileapi/public_url_manager.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
...@@ -23,7 +23,6 @@ namespace { ...@@ -23,7 +23,6 @@ namespace {
using mojom::blink::Blob; using mojom::blink::Blob;
using mojom::blink::BlobPtr; using mojom::blink::BlobPtr;
using mojom::blink::BlobURLStore; using mojom::blink::BlobURLStore;
using mojom::blink::BlobURLStoreAssociatedPtr;
class TestURLRegistrable : public URLRegistrable { class TestURLRegistrable : public URLRegistrable {
public: public:
...@@ -66,7 +65,7 @@ class FakeURLRegistry : public URLRegistry { ...@@ -66,7 +65,7 @@ class FakeURLRegistry : public URLRegistry {
class PublicURLManagerTest : public testing::Test { class PublicURLManagerTest : public testing::Test {
public: public:
PublicURLManagerTest() : url_store_binding_(&url_store_) {} PublicURLManagerTest() : url_store_receiver_(&url_store_) {}
void SetUp() override { void SetUp() override {
execution_context_ = MakeGarbageCollected<NullExecutionContext>(); execution_context_ = MakeGarbageCollected<NullExecutionContext>();
...@@ -74,10 +73,10 @@ class PublicURLManagerTest : public testing::Test { ...@@ -74,10 +73,10 @@ class PublicURLManagerTest : public testing::Test {
// wants. // wants.
execution_context_->SetUpSecurityContext(); execution_context_->SetUpSecurityContext();
BlobURLStoreAssociatedPtr url_store_ptr; mojo::AssociatedRemote<BlobURLStore> url_store_remote;
url_store_binding_.Bind( url_store_receiver_.Bind(
MakeRequestAssociatedWithDedicatedPipe(&url_store_ptr)); url_store_remote.BindNewEndpointAndPassDedicatedReceiverForTesting());
url_manager().SetURLStoreForTesting(std::move(url_store_ptr)); url_manager().SetURLStoreForTesting(std::move(url_store_remote));
} }
PublicURLManager& url_manager() { PublicURLManager& url_manager() {
...@@ -95,7 +94,7 @@ class PublicURLManagerTest : public testing::Test { ...@@ -95,7 +94,7 @@ class PublicURLManagerTest : public testing::Test {
Persistent<NullExecutionContext> execution_context_; Persistent<NullExecutionContext> execution_context_;
FakeBlobURLStore url_store_; FakeBlobURLStore url_store_;
mojo::AssociatedBinding<BlobURLStore> url_store_binding_; mojo::AssociatedReceiver<BlobURLStore> url_store_receiver_;
}; };
TEST_F(PublicURLManagerTest, RegisterNonMojoBlob) { TEST_F(PublicURLManagerTest, RegisterNonMojoBlob) {
...@@ -117,7 +116,7 @@ TEST_F(PublicURLManagerTest, RegisterNonMojoBlob) { ...@@ -117,7 +116,7 @@ TEST_F(PublicURLManagerTest, RegisterNonMojoBlob) {
url_manager().Revoke(KURL(url)); url_manager().Revoke(KURL(url));
EXPECT_FALSE(SecurityOrigin::CreateFromString(url)->IsSameSchemeHostPort( EXPECT_FALSE(SecurityOrigin::CreateFromString(url)->IsSameSchemeHostPort(
execution_context_->GetSecurityOrigin())); execution_context_->GetSecurityOrigin()));
url_store_binding_.FlushForTesting(); url_store_receiver_.FlushForTesting();
// Even though this was not a mojo blob, the PublicURLManager might not know // Even though this was not a mojo blob, the PublicURLManager might not know
// that, so still expect a revocation on the mojo interface. // that, so still expect a revocation on the mojo interface.
ASSERT_EQ(1u, url_store_.revocations.size()); ASSERT_EQ(1u, url_store_.revocations.size());
...@@ -141,7 +140,7 @@ TEST_F(PublicURLManagerTest, RegisterMojoBlob) { ...@@ -141,7 +140,7 @@ TEST_F(PublicURLManagerTest, RegisterMojoBlob) {
url_manager().Revoke(KURL(url)); url_manager().Revoke(KURL(url));
EXPECT_FALSE(SecurityOrigin::CreateFromString(url)->IsSameSchemeHostPort( EXPECT_FALSE(SecurityOrigin::CreateFromString(url)->IsSameSchemeHostPort(
execution_context_->GetSecurityOrigin())); execution_context_->GetSecurityOrigin()));
url_store_binding_.FlushForTesting(); url_store_receiver_.FlushForTesting();
ASSERT_EQ(1u, url_store_.revocations.size()); ASSERT_EQ(1u, url_store_.revocations.size());
EXPECT_EQ(url, url_store_.revocations[0]); EXPECT_EQ(url, url_store_.revocations[0]);
} }
...@@ -152,7 +151,7 @@ TEST_F(PublicURLManagerTest, RevokeValidNonRegisteredURL) { ...@@ -152,7 +151,7 @@ TEST_F(PublicURLManagerTest, RevokeValidNonRegisteredURL) {
KURL url = KURL("blob:http://example.com/id"); KURL url = KURL("blob:http://example.com/id");
url_manager().Revoke(url); url_manager().Revoke(url);
url_store_binding_.FlushForTesting(); url_store_receiver_.FlushForTesting();
ASSERT_EQ(1u, url_store_.revocations.size()); ASSERT_EQ(1u, url_store_.revocations.size());
EXPECT_EQ(url, url_store_.revocations[0]); EXPECT_EQ(url, url_store_.revocations[0]);
} }
...@@ -167,7 +166,7 @@ TEST_F(PublicURLManagerTest, RevokeInvalidURL) { ...@@ -167,7 +166,7 @@ TEST_F(PublicURLManagerTest, RevokeInvalidURL) {
url_manager().Revoke(invalid_scheme_url); url_manager().Revoke(invalid_scheme_url);
url_manager().Revoke(fragment_url); url_manager().Revoke(fragment_url);
url_manager().Revoke(invalid_origin_url); url_manager().Revoke(invalid_origin_url);
url_store_binding_.FlushForTesting(); url_store_receiver_.FlushForTesting();
// Both should have been silently ignored. // Both should have been silently ignored.
EXPECT_TRUE(url_store_.revocations.IsEmpty()); EXPECT_TRUE(url_store_.revocations.IsEmpty());
} }
......
...@@ -147,7 +147,7 @@ class BlobDataHandleTest : public testing::Test { ...@@ -147,7 +147,7 @@ class BlobDataHandleTest : public testing::Test {
EXPECT_EQ(is_single_unknown_size_file, handle->IsSingleUnknownSizeFile()); EXPECT_EQ(is_single_unknown_size_file, handle->IsSingleUnknownSizeFile());
blob_registry_remote_.FlushForTesting(); blob_registry_remote_.FlushForTesting();
EXPECT_EQ(0u, mock_blob_registry_.binding_requests.size()); EXPECT_EQ(0u, mock_blob_registry_.owned_receivers.size());
ASSERT_EQ(1u, mock_blob_registry_.registrations.size()); ASSERT_EQ(1u, mock_blob_registry_.registrations.size());
auto& reg = mock_blob_registry_.registrations[0]; auto& reg = mock_blob_registry_.registrations[0];
EXPECT_EQ(handle->Uuid(), reg.uuid); EXPECT_EQ(handle->Uuid(), reg.uuid);
...@@ -244,7 +244,7 @@ TEST_F(BlobDataHandleTest, CreateEmpty) { ...@@ -244,7 +244,7 @@ TEST_F(BlobDataHandleTest, CreateEmpty) {
EXPECT_FALSE(handle->IsSingleUnknownSizeFile()); EXPECT_FALSE(handle->IsSingleUnknownSizeFile());
blob_registry_remote_.FlushForTesting(); blob_registry_remote_.FlushForTesting();
EXPECT_EQ(0u, mock_blob_registry_.binding_requests.size()); EXPECT_EQ(0u, mock_blob_registry_.owned_receivers.size());
ASSERT_EQ(1u, mock_blob_registry_.registrations.size()); ASSERT_EQ(1u, mock_blob_registry_.registrations.size());
const auto& reg = mock_blob_registry_.registrations[0]; const auto& reg = mock_blob_registry_.registrations[0];
EXPECT_EQ(handle->Uuid(), reg.uuid); EXPECT_EQ(handle->Uuid(), reg.uuid);
...@@ -276,8 +276,8 @@ TEST_F(BlobDataHandleTest, CreateFromUUID) { ...@@ -276,8 +276,8 @@ TEST_F(BlobDataHandleTest, CreateFromUUID) {
blob_registry_remote_.FlushForTesting(); blob_registry_remote_.FlushForTesting();
EXPECT_EQ(0u, mock_blob_registry_.registrations.size()); EXPECT_EQ(0u, mock_blob_registry_.registrations.size());
ASSERT_EQ(1u, mock_blob_registry_.binding_requests.size()); ASSERT_EQ(1u, mock_blob_registry_.owned_receivers.size());
EXPECT_EQ(kUuid, mock_blob_registry_.binding_requests[0].uuid); EXPECT_EQ(kUuid, mock_blob_registry_.owned_receivers[0].uuid);
} }
TEST_F(BlobDataHandleTest, CreateFromEmptyElements) { TEST_F(BlobDataHandleTest, CreateFromEmptyElements) {
......
...@@ -37,7 +37,7 @@ void FakeBlobRegistry::GetBlobFromUUID( ...@@ -37,7 +37,7 @@ void FakeBlobRegistry::GetBlobFromUUID(
mojo::PendingReceiver<mojom::blink::Blob> blob, mojo::PendingReceiver<mojom::blink::Blob> blob,
const String& uuid, const String& uuid,
GetBlobFromUUIDCallback callback) { GetBlobFromUUIDCallback callback) {
binding_requests.push_back(BindingRequest{uuid}); owned_receivers.push_back(OwnedReceiver{uuid});
mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid), mojo::MakeSelfOwnedReceiver(std::make_unique<FakeBlob>(uuid),
std::move(blob)); std::move(blob));
std::move(callback).Run(); std::move(callback).Run();
...@@ -45,7 +45,7 @@ void FakeBlobRegistry::GetBlobFromUUID( ...@@ -45,7 +45,7 @@ void FakeBlobRegistry::GetBlobFromUUID(
void FakeBlobRegistry::URLStoreForOrigin( void FakeBlobRegistry::URLStoreForOrigin(
const scoped_refptr<const SecurityOrigin>& origin, const scoped_refptr<const SecurityOrigin>& origin,
mojom::blink::BlobURLStoreAssociatedRequest request) { mojo::PendingAssociatedReceiver<mojom::blink::BlobURLStore> receiver) {
NOTREACHED(); NOTREACHED();
} }
......
...@@ -33,8 +33,9 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry { ...@@ -33,8 +33,9 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry {
const String& uuid, const String& uuid,
GetBlobFromUUIDCallback) override; GetBlobFromUUIDCallback) override;
void URLStoreForOrigin(const scoped_refptr<const SecurityOrigin>&, void URLStoreForOrigin(
mojom::blink::BlobURLStoreAssociatedRequest) override; const scoped_refptr<const SecurityOrigin>&,
mojo::PendingAssociatedReceiver<mojom::blink::BlobURLStore>) override;
struct Registration { struct Registration {
String uuid; String uuid;
...@@ -44,10 +45,10 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry { ...@@ -44,10 +45,10 @@ class FakeBlobRegistry : public mojom::blink::BlobRegistry {
}; };
Vector<Registration> registrations; Vector<Registration> registrations;
struct BindingRequest { struct OwnedReceiver {
String uuid; String uuid;
}; };
Vector<BindingRequest> binding_requests; Vector<OwnedReceiver> owned_receivers;
}; };
} // namespace blink } // namespace blink
......
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