Chromium Code Reviews| Index: content/browser/webui/web_ui_mojo_browsertest.cc |
| diff --git a/content/browser/webui/web_ui_mojo_browsertest.cc b/content/browser/webui/web_ui_mojo_browsertest.cc |
| index 6261316ab115d4cd2d9da02de1f60c54341da51a..6c634ac44d05f024f0582c9df37f47ef3f0a5877 100644 |
| --- a/content/browser/webui/web_ui_mojo_browsertest.cc |
| +++ b/content/browser/webui/web_ui_mojo_browsertest.cc |
| @@ -28,6 +28,8 @@ |
| #include "content/test/data/web_ui_test_mojo_bindings.mojom.h" |
| #include "grit/content_resources.h" |
| #include "mojo/common/test/test_utils.h" |
| +#include "mojo/public/cpp/bindings/interface_impl.h" |
| +#include "mojo/public/cpp/bindings/interface_request.h" |
| #include "mojo/public/js/bindings/constants.h" |
| namespace content { |
| @@ -57,24 +59,19 @@ bool GetResource(const std::string& id, |
| return true; |
| } |
| -class BrowserTargetImpl : public BrowserTarget { |
| +class BrowserTargetImpl : public mojo::InterfaceImpl<BrowserTarget> { |
| public: |
| - BrowserTargetImpl(mojo::ScopedMessagePipeHandle handle, |
| - base::RunLoop* run_loop) |
| - : run_loop_(run_loop) { |
| - renderer_.Bind(handle.Pass()); |
| - renderer_.set_client(this); |
| - } |
| + explicit BrowserTargetImpl(base::RunLoop* run_loop) : run_loop_(run_loop) {} |
| virtual ~BrowserTargetImpl() {} |
| - // BrowserTarget overrides: |
| + // mojo::InterfaceImpl<BrowserTarget> overrides: |
| virtual void PingResponse() OVERRIDE { |
| NOTREACHED(); |
| } |
| + virtual void OnConnectionError() OVERRIDE {} |
|
darin (slow to review)
2014/07/29 16:22:05
hmm, why bother overriding this? the default imple
Sam McNally
2014/07/30 00:18:08
Done.
|
| protected: |
| - RendererTargetPtr renderer_; |
| base::RunLoop* run_loop_; |
| private: |
| @@ -83,15 +80,16 @@ class BrowserTargetImpl : public BrowserTarget { |
| class PingBrowserTargetImpl : public BrowserTargetImpl { |
| public: |
| - PingBrowserTargetImpl(mojo::ScopedMessagePipeHandle handle, |
| - base::RunLoop* run_loop) |
| - : BrowserTargetImpl(handle.Pass(), run_loop) { |
| - renderer_->Ping(); |
| - } |
| + explicit PingBrowserTargetImpl(base::RunLoop* run_loop) |
| + : BrowserTargetImpl(run_loop) {} |
| virtual ~PingBrowserTargetImpl() {} |
| - // BrowserTarget overrides: |
| + // mojo::InterfaceImpl<BrowserTarget> overrides: |
| + virtual void OnConnectionEstablished() OVERRIDE { |
| + client()->Ping(); |
| + } |
| + |
| // Quit the RunLoop when called. |
| virtual void PingResponse() OVERRIDE { |
| got_message = true; |
| @@ -133,14 +131,14 @@ class PingTestWebUIController : public TestWebUIController { |
| // WebUIController overrides: |
| virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE { |
| - render_view_host->GetMainFrame()->GetServiceRegistry()->AddService( |
| - "webui_controller", |
| - base::Bind(&PingTestWebUIController::CreateHandler, |
| - base::Unretained(this))); |
| + render_view_host->GetMainFrame()->GetServiceRegistry()-> |
| + AddService<BrowserTarget>(base::Bind( |
| + &PingTestWebUIController::CreateHandler, base::Unretained(this))); |
| } |
| - void CreateHandler(mojo::ScopedMessagePipeHandle handle) { |
| - browser_target_.reset(new PingBrowserTargetImpl(handle.Pass(), run_loop_)); |
| + void CreateHandler(mojo::InterfaceRequest<BrowserTarget> request) { |
| + browser_target_.reset( |
| + mojo::BindToRequest(new PingBrowserTargetImpl(run_loop_), &request)); |
|
darin (slow to review)
2014/07/29 16:22:05
did you want to use WeakBindToRequest here? BindTo
Sam McNally
2014/07/30 00:18:08
Done.
|
| } |
| private: |