From 313c22a3215a7007564227ad4da983813b0eda7f Mon Sep 17 00:00:00 2001 From: James Robinson Date: Wed, 18 Feb 2015 18:17:50 -0800 Subject: [PATCH] Remove last uses of InterfaceImpl<> in Sky C++ code This switches to using StrongBinding<>s in sky's ContentHandlerImpl and TestHarnessImpl implementations. These are the last uses of the deprecated InterfaceImpl<> helper in the mojo repo (more uses exist in other repos). R=eseidel@chromium.org Review URL: https://codereview.chromium.org/934403002 --- .../flutter/tools/tester/test_harness_impl.cc | 5 +++-- .../src/flutter/tools/tester/test_harness_impl.h | 10 +++++----- engine/src/flutter/tools/tester/test_runner.cc | 16 +++++++++++----- engine/src/flutter/tools/tester/test_runner.h | 10 ++++++---- engine/src/flutter/tools/tester/tester.cc | 2 +- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/engine/src/flutter/tools/tester/test_harness_impl.cc b/engine/src/flutter/tools/tester/test_harness_impl.cc index 882aff34f2..1ece58c178 100644 --- a/engine/src/flutter/tools/tester/test_harness_impl.cc +++ b/engine/src/flutter/tools/tester/test_harness_impl.cc @@ -9,8 +9,9 @@ namespace sky { namespace tester { -TestHarnessImpl::TestHarnessImpl(TestRunner* test_runner) - : test_runner_(test_runner->GetWeakPtr()) { +TestHarnessImpl::TestHarnessImpl(TestRunner* test_runner, + mojo::InterfaceRequest request) + : binding_(this, request.Pass()), test_runner_(test_runner->GetWeakPtr()) { // FIXME: This is technically when the V8 context gets created and // not when the test is started. An error before we instantiated // the V8 context would show up before the #BEGIN line for this test. diff --git a/engine/src/flutter/tools/tester/test_harness_impl.h b/engine/src/flutter/tools/tester/test_harness_impl.h index 8a597035b8..3067b525f6 100644 --- a/engine/src/flutter/tools/tester/test_harness_impl.h +++ b/engine/src/flutter/tools/tester/test_harness_impl.h @@ -7,6 +7,7 @@ #include "base/memory/weak_ptr.h" #include "mojo/public/cpp/application/interface_factory_impl.h" +#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/system/core.h" #include "sky/services/testing/test_harness.mojom.h" @@ -14,9 +15,10 @@ namespace sky { namespace tester { class TestRunner; -class TestHarnessImpl : public mojo::InterfaceImpl { +class TestHarnessImpl : public TestHarness { public: - explicit TestHarnessImpl(TestRunner*); + TestHarnessImpl(TestRunner* runner, + mojo::InterfaceRequest request); virtual ~TestHarnessImpl(); private: @@ -25,14 +27,12 @@ class TestHarnessImpl : public mojo::InterfaceImpl { const mojo::Array pixels) override; void DispatchInputEvent(mojo::EventPtr event) override; + mojo::StrongBinding binding_; base::WeakPtr test_runner_; MOJO_DISALLOW_COPY_AND_ASSIGN(TestHarnessImpl); }; -typedef mojo::InterfaceFactoryImplWithContext< - TestHarnessImpl, TestRunner> TestHarnessFactory; - } // namespace tester } // namespace sky diff --git a/engine/src/flutter/tools/tester/test_runner.cc b/engine/src/flutter/tools/tester/test_runner.cc index e187cfa8e4..c726989ce1 100644 --- a/engine/src/flutter/tools/tester/test_runner.cc +++ b/engine/src/flutter/tools/tester/test_runner.cc @@ -15,16 +15,17 @@ namespace tester { TestRunnerClient::~TestRunnerClient() { } -TestRunner::TestRunner(TestRunnerClient* client, mojo::View* container, - const std::string& url, bool enable_pixel_dumping) - : test_harness_factory_(this), - client_(client), +TestRunner::TestRunner(TestRunnerClient* client, + mojo::View* container, + const std::string& url, + bool enable_pixel_dumping) + : client_(client), weak_ptr_factory_(this), enable_pixel_dumping_(enable_pixel_dumping) { CHECK(client); mojo::ServiceProviderPtr test_harness_provider; - test_harness_provider_impl_.AddService(&test_harness_factory_); + test_harness_provider_impl_.AddService(this); test_harness_provider_impl_.Bind(GetProxy(&test_harness_provider)); container->Embed(url, nullptr, test_harness_provider.Pass()); @@ -67,5 +68,10 @@ void TestRunner::OnTestComplete(const std::string& test_result, client_->OnTestComplete(); } +void TestRunner::Create(mojo::ApplicationConnection* app, + mojo::InterfaceRequest request) { + new TestHarnessImpl(this, request.Pass()); +} + } // namespace tester } // namespace sky diff --git a/engine/src/flutter/tools/tester/test_runner.h b/engine/src/flutter/tools/tester/test_runner.h index 5a775355f6..57bfab2cac 100644 --- a/engine/src/flutter/tools/tester/test_runner.h +++ b/engine/src/flutter/tools/tester/test_runner.h @@ -25,14 +25,13 @@ class TestRunnerClient { virtual ~TestRunnerClient(); }; -class TestRunner { +class TestRunner : public mojo::InterfaceFactory { public: TestRunner(TestRunnerClient* client, mojo::View* container, const std::string& url, bool enable_pixel_dumping); - virtual ~TestRunner(); + ~TestRunner() override; TestRunnerClient* client() const { return client_; } - TestHarnessFactory* test_harness_factory() { return &test_harness_factory_; } base::WeakPtr GetWeakPtr(); void OnTestStart(); @@ -40,7 +39,10 @@ class TestRunner { const mojo::Array& pixels); private: - TestHarnessFactory test_harness_factory_; + // mojo::InterfaceFactory implementation: + void Create(mojo::ApplicationConnection* app, + mojo::InterfaceRequest request) override; + mojo::ServiceProviderImpl test_harness_provider_impl_; TestRunnerClient* client_; base::WeakPtrFactory weak_ptr_factory_; diff --git a/engine/src/flutter/tools/tester/tester.cc b/engine/src/flutter/tools/tester/tester.cc index d46c84f1bf..631ca4e260 100644 --- a/engine/src/flutter/tools/tester/tester.cc +++ b/engine/src/flutter/tools/tester/tester.cc @@ -78,7 +78,7 @@ class SkyTester : public mojo::ApplicationDelegate, mojo::ApplicationConnection* connection) override { window_manager_app_->ConfigureIncomingConnection(connection); if (test_runner_) - connection->AddService(test_runner_->test_harness_factory()); + connection->AddService(test_runner_.get()); return true; }