Commit 9f37231a authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Clean up InterfaceProvider in Blink (2/3)

This CL cleans up testing codes related InterfaceProvider
in Blink.

Bug: 990845, 995556
Change-Id: Ifa9a1f5570f7f5bb1a87a461fd0c28332a96c280
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2007308Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Cr-Commit-Position: refs/heads/master@{#733866}
parent 81449e6f
...@@ -4387,7 +4387,6 @@ class MojoTestHelper { ...@@ -4387,7 +4387,6 @@ class MojoTestHelper {
WebViewImpl* web_view_; WebViewImpl* web_view_;
frame_test_helpers::WebViewHelper& web_view_helper_; frame_test_helpers::WebViewHelper& web_view_helper_;
frame_test_helpers::TestWebFrameClient web_frame_client_; frame_test_helpers::TestWebFrameClient web_frame_client_;
std::unique_ptr<service_manager::InterfaceProvider::TestApi> test_api_;
}; };
// Mock implementation of the UnhandledTapNotifier Mojo receiver, for testing // Mock implementation of the UnhandledTapNotifier Mojo receiver, for testing
......
...@@ -505,8 +505,7 @@ void WebViewHelper::InitializeWebView(TestWebViewClient* web_view_client, ...@@ -505,8 +505,7 @@ void WebViewHelper::InitializeWebView(TestWebViewClient* web_view_client,
int TestWebFrameClient::loads_in_progress_ = 0; int TestWebFrameClient::loads_in_progress_ = 0;
TestWebFrameClient::TestWebFrameClient() TestWebFrameClient::TestWebFrameClient()
: interface_provider_(new service_manager::InterfaceProvider()), : associated_interface_provider_(new AssociatedInterfaceProvider(nullptr)),
associated_interface_provider_(new AssociatedInterfaceProvider(nullptr)),
effective_connection_type_(WebEffectiveConnectionType::kTypeUnknown) {} effective_connection_type_(WebEffectiveConnectionType::kTypeUnknown) {}
TestWebFrameClient::~TestWebFrameClient() = default; TestWebFrameClient::~TestWebFrameClient() = default;
......
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "cc/trees/layer_tree_host.h" #include "cc/trees/layer_tree_host.h"
#include "content/renderer/compositor/layer_tree_view.h" #include "content/renderer/compositor/layer_tree_view.h"
#include "content/test/stub_layer_tree_view_delegate.h" #include "content/test/stub_layer_tree_view_delegate.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/frame/frame_owner_element_type.h" #include "third_party/blink/public/common/frame/frame_owner_element_type.h"
#include "third_party/blink/public/common/input/web_mouse_event.h" #include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink-forward.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-blink-forward.h"
...@@ -440,9 +439,6 @@ class TestWebFrameClient : public WebLocalFrameClient { ...@@ -440,9 +439,6 @@ class TestWebFrameClient : public WebLocalFrameClient {
FrameOwnerElementType) override; FrameOwnerElementType) override;
void DidStartLoading() override; void DidStartLoading() override;
void DidStopLoading() override; void DidStopLoading() override;
service_manager::InterfaceProvider* GetInterfaceProvider() override {
return interface_provider_.get();
}
std::unique_ptr<blink::WebURLLoaderFactory> CreateURLLoaderFactory() std::unique_ptr<blink::WebURLLoaderFactory> CreateURLLoaderFactory()
override { override {
// TODO(kinuko,toyoshim): Stop using Platform's URLLoaderFactory, but create // TODO(kinuko,toyoshim): Stop using Platform's URLLoaderFactory, but create
...@@ -469,10 +465,6 @@ class TestWebFrameClient : public WebLocalFrameClient { ...@@ -469,10 +465,6 @@ class TestWebFrameClient : public WebLocalFrameClient {
// If set to a non-null value, self-deletes on frame detach. // If set to a non-null value, self-deletes on frame detach.
std::unique_ptr<TestWebFrameClient> self_owned_; std::unique_ptr<TestWebFrameClient> self_owned_;
// Use service_manager::InterfaceProvider::TestApi to provide test interfaces
// through this client.
std::unique_ptr<service_manager::InterfaceProvider> interface_provider_;
std::unique_ptr<AssociatedInterfaceProvider> associated_interface_provider_; std::unique_ptr<AssociatedInterfaceProvider> associated_interface_provider_;
// This is null from when the client is created until it is initialized with // This is null from when the client is created until it is initialized with
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
typedef unsigned long MojoResult; typedef unsigned long MojoResult;
enum MojoScope { enum MojoScope {
// Refers to the InterfaceProvider associated with the current execution // Refers to the BrowserInterfaceBroker associated with the current execution
// context. Either a Document or WorkerGlobalScope. // context. Either a Document or WorkerGlobalScope.
"context", "context",
// Refers to the InterfaceProvider of the current process. // Refers to the BrowserInterfaceBroker of the current process.
// //
// Note: A "process" is not a web concept. In some cases the browser process // Note: A "process" is not a web concept. In some cases the browser process
// concept of a "site instance" may be useful however there is currently no // concept of a "site instance" may be useful however there is currently no
// InterfaceProvider per site instance. // BrowserInterfaceBroker per site instance.
"process", "process",
}; };
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h" #include "third_party/blink/renderer/core/mojo/test/mojo_interface_interceptor.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/browser_interface_broker_proxy.h" #include "third_party/blink/public/common/browser_interface_broker_proxy.h"
#include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h" #include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
...@@ -84,32 +83,7 @@ void MojoInterfaceInterceptor::start(ExceptionState& exception_state) { ...@@ -84,32 +83,7 @@ void MojoInterfaceInterceptor::start(ExceptionState& exception_state) {
"Interface " + interface_name_ + "Interface " + interface_name_ +
" is already intercepted by another MojoInterfaceInterceptor."); " is already intercepted by another MojoInterfaceInterceptor.");
} }
return;
}
// TODO(crbug.com/994843): remove when no longer used.
service_manager::InterfaceProvider* interface_provider =
GetInterfaceProvider();
if (!interface_provider) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
"The interface provider is unavailable.");
return;
}
service_manager::InterfaceProvider::TestApi test_api(interface_provider);
if (test_api.HasBinderForName(interface_name)) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidModificationError,
"Interface " + interface_name_ +
" is already intercepted by another MojoInterfaceInterceptor.");
return;
} }
started_ = true;
test_api.SetBinderForName(
interface_name,
WTF::BindRepeating(&MojoInterfaceInterceptor::OnInterfaceRequest,
WrapWeakPersistent(this)));
} }
void MojoInterfaceInterceptor::stop() { void MojoInterfaceInterceptor::stop() {
...@@ -130,15 +104,7 @@ void MojoInterfaceInterceptor::stop() { ...@@ -130,15 +104,7 @@ void MojoInterfaceInterceptor::stop() {
DCHECK(context); DCHECK(context);
context->GetBrowserInterfaceBroker().SetBinderForTesting(interface_name, context->GetBrowserInterfaceBroker().SetBinderForTesting(interface_name,
{}); {});
return;
} }
// TODO(crbug.com/994843): remove when no longer used.
// GetInterfaceProvider() is guaranteed not to return nullptr because this
// method is called when the context is destroyed.
service_manager::InterfaceProvider::TestApi test_api(GetInterfaceProvider());
DCHECK(test_api.HasBinderForName(interface_name));
test_api.ClearBinderForName(interface_name);
} }
void MojoInterfaceInterceptor::Trace(blink::Visitor* visitor) { void MojoInterfaceInterceptor::Trace(blink::Visitor* visitor) {
...@@ -172,19 +138,10 @@ MojoInterfaceInterceptor::MojoInterfaceInterceptor( ...@@ -172,19 +138,10 @@ MojoInterfaceInterceptor::MojoInterfaceInterceptor(
process_scope_(process_scope), process_scope_(process_scope),
use_browser_interface_broker_(use_browser_interface_broker) {} use_browser_interface_broker_(use_browser_interface_broker) {}
service_manager::InterfaceProvider*
MojoInterfaceInterceptor::GetInterfaceProvider() const {
ExecutionContext* context = GetExecutionContext();
if (!context)
return nullptr;
return context->GetInterfaceProvider();
}
void MojoInterfaceInterceptor::OnInterfaceRequest( void MojoInterfaceInterceptor::OnInterfaceRequest(
mojo::ScopedMessagePipeHandle handle) { mojo::ScopedMessagePipeHandle handle) {
// Execution of JavaScript may be forbidden in this context as this method is // Execution of JavaScript may be forbidden in this context as this method is
// called synchronously by the InterfaceProvider. Dispatching of the // called synchronously by the BrowserInterfaceBroker. Dispatching of the
// 'interfacerequest' event is therefore scheduled to take place in the next // 'interfacerequest' event is therefore scheduled to take place in the next
// microtask. This also more closely mirrors the behavior when an interface // microtask. This also more closely mirrors the behavior when an interface
// request is being satisfied by another process. // request is being satisfied by another process.
......
...@@ -14,10 +14,6 @@ ...@@ -14,10 +14,6 @@
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace service_manager {
class InterfaceProvider;
}
namespace blink { namespace blink {
class ExceptionState; class ExceptionState;
...@@ -70,7 +66,6 @@ class MojoInterfaceInterceptor final ...@@ -70,7 +66,6 @@ class MojoInterfaceInterceptor final
void ContextDestroyed(ExecutionContext*) final; void ContextDestroyed(ExecutionContext*) final;
private: private:
service_manager::InterfaceProvider* GetInterfaceProvider() const;
void OnInterfaceRequest(mojo::ScopedMessagePipeHandle); void OnInterfaceRequest(mojo::ScopedMessagePipeHandle);
void DispatchInterfaceRequestEvent(mojo::ScopedMessagePipeHandle); void DispatchInterfaceRequestEvent(mojo::ScopedMessagePipeHandle);
......
...@@ -45,7 +45,6 @@ class PageTestBase : public testing::Test, public ScopedMockOverlayScrollbars { ...@@ -45,7 +45,6 @@ class PageTestBase : public testing::Test, public ScopedMockOverlayScrollbars {
void BindClipboardHost(mojo::ScopedMessagePipeHandle handle); void BindClipboardHost(mojo::ScopedMessagePipeHandle handle);
MockClipboardHost host_; MockClipboardHost host_;
std::unique_ptr<service_manager::InterfaceProvider::TestApi> clipboard_api_;
}; };
PageTestBase(); PageTestBase();
......
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