Commit 10ac59ac authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate TestRendererServiceImpl to the new Mojo types

This CL converts mojo::Binding to mojo::Receiver in
TestRendererServiceImpl. And also, this CL applies
mojo::Receiver to mojom::TestServiceRequest.

Bug: 955171
Change-Id: I74c3b39f48060544adc7496657c0485eb504800c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1786364Reviewed-by: default avatarMike West <mkwst@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#693838}
parent d7006cb6
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#include "content/shell/common/power_monitor_test_impl.h" #include "content/shell/common/power_monitor_test_impl.h"
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/shell_render_view_observer.h" #include "content/shell/renderer/shell_render_view_observer.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "ppapi/buildflags/buildflags.h" #include "ppapi/buildflags/buildflags.h"
...@@ -46,9 +47,10 @@ namespace { ...@@ -46,9 +47,10 @@ namespace {
// A test service which can be driven by browser tests for various reasons. // A test service which can be driven by browser tests for various reasons.
class TestRendererServiceImpl : public mojom::TestService { class TestRendererServiceImpl : public mojom::TestService {
public: public:
explicit TestRendererServiceImpl(mojom::TestServiceRequest request) explicit TestRendererServiceImpl(
: binding_(this, std::move(request)) { mojo::PendingReceiver<mojom::TestService> receiver)
binding_.set_connection_error_handler(base::BindOnce( : receiver_(this, std::move(receiver)) {
receiver_.set_disconnect_handler(base::BindOnce(
&TestRendererServiceImpl::OnConnectionError, base::Unretained(this))); &TestRendererServiceImpl::OnConnectionError, base::Unretained(this)));
} }
...@@ -62,7 +64,7 @@ class TestRendererServiceImpl : public mojom::TestService { ...@@ -62,7 +64,7 @@ class TestRendererServiceImpl : public mojom::TestService {
// Instead of responding normally, unbind the pipe, write some garbage, // Instead of responding normally, unbind the pipe, write some garbage,
// and go away. // and go away.
const std::string kBadMessage = "This is definitely not a valid response!"; const std::string kBadMessage = "This is definitely not a valid response!";
mojo::ScopedMessagePipeHandle pipe = binding_.Unbind().PassMessagePipe(); mojo::ScopedMessagePipeHandle pipe = receiver_.Unbind().PassPipe();
MojoResult rv = mojo::WriteMessageRaw( MojoResult rv = mojo::WriteMessageRaw(
pipe.get(), kBadMessage.data(), kBadMessage.size(), nullptr, 0, pipe.get(), kBadMessage.data(), kBadMessage.size(), nullptr, 0,
MOJO_WRITE_MESSAGE_FLAG_NONE); MOJO_WRITE_MESSAGE_FLAG_NONE);
...@@ -91,14 +93,15 @@ class TestRendererServiceImpl : public mojom::TestService { ...@@ -91,14 +93,15 @@ class TestRendererServiceImpl : public mojom::TestService {
NOTREACHED(); NOTREACHED();
} }
mojo::Binding<mojom::TestService> binding_; mojo::Receiver<mojom::TestService> receiver_;
DISALLOW_COPY_AND_ASSIGN(TestRendererServiceImpl); DISALLOW_COPY_AND_ASSIGN(TestRendererServiceImpl);
}; };
void CreateRendererTestService(mojom::TestServiceRequest request) { void CreateRendererTestService(
mojo::PendingReceiver<mojom::TestService> receiver) {
// Owns itself. // Owns itself.
new TestRendererServiceImpl(std::move(request)); new TestRendererServiceImpl(std::move(receiver));
} }
} // namespace } // namespace
......
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