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

Clean up old Mojo types for BrowserAssociatedInterfaceTestDriver and WebContentsFrameBindingSetTest

This CL cleans up old Mojo types for
mojom::BrowserAssociatedInterfaceTestDriver and
mojom::WebContentsFrameBindingSetTest with using
AssociatedRemote and PendingAssociatedRecevier.

Bug: 955171
Change-Id: Ifd937d9c3014af8616d12426ad239dce98efee59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880407Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#709736}
parent c7598599
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_listener.h" #include "ipc/ipc_listener.h"
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -140,7 +141,7 @@ class TestClientRunner { ...@@ -140,7 +141,7 @@ class TestClientRunner {
base::Thread::Options(base::MessagePumpType::IO, 0)); base::Thread::Options(base::MessagePumpType::IO, 0));
ProxyRunner proxy(std::move(pipe), false, io_thread.task_runner()); ProxyRunner proxy(std::move(pipe), false, io_thread.task_runner());
mojom::BrowserAssociatedInterfaceTestDriverAssociatedPtr driver; mojo::AssociatedRemote<mojom::BrowserAssociatedInterfaceTestDriver> driver;
proxy.channel()->GetRemoteAssociatedInterface(&driver); proxy.channel()->GetRemoteAssociatedInterface(&driver);
for (int i = 0; i < kNumTestMessages; ++i) { for (int i = 0; i < kNumTestMessages; ++i) {
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "content/public/test/web_contents_binding_set_test_binder.h" #include "content/public/test/web_contents_binding_set_test_binder.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/test/test_browser_associated_interfaces.mojom.h" #include "content/test/test_browser_associated_interfaces.mojom.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "net/dns/mock_host_resolver.h" #include "net/dns/mock_host_resolver.h"
namespace content { namespace content {
...@@ -38,9 +40,10 @@ class TestInterfaceBinder : public WebContentsBindingSetTestBinder< ...@@ -38,9 +40,10 @@ class TestInterfaceBinder : public WebContentsBindingSetTestBinder<
: bind_callback_(bind_callback) {} : bind_callback_(bind_callback) {}
~TestInterfaceBinder() override {} ~TestInterfaceBinder() override {}
void BindRequest(RenderFrameHost* frame_host, void BindReceiver(
mojom::BrowserAssociatedInterfaceTestDriverAssociatedRequest RenderFrameHost* frame_host,
request) override { mojo::PendingAssociatedReceiver<
mojom::BrowserAssociatedInterfaceTestDriver> receiver) override {
bind_callback_.Run(); bind_callback_.Run();
} }
...@@ -83,14 +86,15 @@ IN_PROC_BROWSER_TEST_F(WebContentsBindingSetBrowserTest, OverrideForTesting) { ...@@ -83,14 +86,15 @@ IN_PROC_BROWSER_TEST_F(WebContentsBindingSetBrowserTest, OverrideForTesting) {
TestInterfaceBinder test_binder(run_loop.QuitClosure()); TestInterfaceBinder test_binder(run_loop.QuitClosure());
binding_set->SetBinder(&test_binder); binding_set->SetBinder(&test_binder);
// Simulate an inbound request for the test interface. This should get routed // Simulate an inbound receiver for the test interface. This should get routed
// to the overriding binder and allow the test to complete. // to the overriding binder and allow the test to complete.
mojom::BrowserAssociatedInterfaceTestDriverAssociatedPtr override_client; mojo::AssociatedRemote<mojom::BrowserAssociatedInterfaceTestDriver>
override_client;
static_cast<WebContentsImpl*>(web_contents) static_cast<WebContentsImpl*>(web_contents)
->OnAssociatedInterfaceRequest( ->OnAssociatedInterfaceRequest(
web_contents->GetMainFrame(), web_contents->GetMainFrame(),
mojom::BrowserAssociatedInterfaceTestDriver::Name_, mojom::BrowserAssociatedInterfaceTestDriver::Name_,
mojo::MakeRequestAssociatedWithDedicatedPipe(&override_client) override_client.BindNewEndpointAndPassDedicatedReceiverForTesting()
.PassHandle()); .PassHandle());
run_loop.Run(); run_loop.Run();
...@@ -102,19 +106,19 @@ IN_PROC_BROWSER_TEST_F(WebContentsBindingSetBrowserTest, CloseOnFrameDeletion) { ...@@ -102,19 +106,19 @@ IN_PROC_BROWSER_TEST_F(WebContentsBindingSetBrowserTest, CloseOnFrameDeletion) {
EXPECT_TRUE(NavigateToURL( EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL(kTestHost1, "/hello.html"))); shell(), embedded_test_server()->GetURL(kTestHost1, "/hello.html")));
// Simulate an inbound request on the navigated main frame. // Simulate an inbound receiver on the navigated main frame.
auto* web_contents = shell()->web_contents(); auto* web_contents = shell()->web_contents();
TestFrameInterfaceBinder binder(web_contents); TestFrameInterfaceBinder binder(web_contents);
mojom::WebContentsFrameBindingSetTestAssociatedPtr override_client; mojo::AssociatedRemote<mojom::WebContentsFrameBindingSetTest> override_client;
static_cast<WebContentsImpl*>(web_contents) static_cast<WebContentsImpl*>(web_contents)
->OnAssociatedInterfaceRequest( ->OnAssociatedInterfaceRequest(
web_contents->GetMainFrame(), web_contents->GetMainFrame(),
mojom::WebContentsFrameBindingSetTest::Name_, mojom::WebContentsFrameBindingSetTest::Name_,
mojo::MakeRequestAssociatedWithDedicatedPipe(&override_client) override_client.BindNewEndpointAndPassDedicatedReceiverForTesting()
.PassHandle()); .PassHandle());
base::RunLoop run_loop; base::RunLoop run_loop;
override_client.set_connection_error_handler(run_loop.QuitClosure()); override_client.set_disconnect_handler(run_loop.QuitClosure());
// Now navigate the WebContents elsewhere, eventually tearing down the old // Now navigate the WebContents elsewhere, eventually tearing down the old
// main frame. // main frame.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "content/public/browser/web_contents_binding_set.h" #include "content/public/browser/web_contents_binding_set.h"
#include "mojo/public/cpp/bindings/associated_interface_request.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
namespace content { namespace content {
...@@ -19,17 +19,17 @@ class WebContentsBindingSetTestBinder : public WebContentsBindingSet::Binder { ...@@ -19,17 +19,17 @@ class WebContentsBindingSetTestBinder : public WebContentsBindingSet::Binder {
public: public:
~WebContentsBindingSetTestBinder() override {} ~WebContentsBindingSetTestBinder() override {}
// Call for every new incoming interface request for a frame. // Call for every new incoming receiver for a frame.
virtual void BindRequest( virtual void BindReceiver(
RenderFrameHost* render_frame_host, RenderFrameHost* render_frame_host,
mojo::AssociatedInterfaceRequest<Interface> request) = 0; mojo::PendingAssociatedReceiver<Interface> receiver) = 0;
private: private:
// Binder: // Binder:
void OnRequestForFrame(RenderFrameHost* render_frame_host, void OnRequestForFrame(RenderFrameHost* render_frame_host,
mojo::ScopedInterfaceEndpointHandle handle) override { mojo::ScopedInterfaceEndpointHandle handle) override {
BindRequest(render_frame_host, BindReceiver(render_frame_host,
mojo::AssociatedInterfaceRequest<Interface>(std::move(handle))); mojo::PendingAssociatedReceiver<Interface>(std::move(handle)));
} }
void CloseAllBindings() override {} void CloseAllBindings() 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