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
This commit is contained in:
@@ -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<TestHarness> 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.
|
||||
|
||||
@@ -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<TestHarness> {
|
||||
class TestHarnessImpl : public TestHarness {
|
||||
public:
|
||||
explicit TestHarnessImpl(TestRunner*);
|
||||
TestHarnessImpl(TestRunner* runner,
|
||||
mojo::InterfaceRequest<TestHarness> request);
|
||||
virtual ~TestHarnessImpl();
|
||||
|
||||
private:
|
||||
@@ -25,14 +27,12 @@ class TestHarnessImpl : public mojo::InterfaceImpl<TestHarness> {
|
||||
const mojo::Array<uint8_t> pixels) override;
|
||||
void DispatchInputEvent(mojo::EventPtr event) override;
|
||||
|
||||
mojo::StrongBinding<TestHarness> binding_;
|
||||
base::WeakPtr<TestRunner> test_runner_;
|
||||
|
||||
MOJO_DISALLOW_COPY_AND_ASSIGN(TestHarnessImpl);
|
||||
};
|
||||
|
||||
typedef mojo::InterfaceFactoryImplWithContext<
|
||||
TestHarnessImpl, TestRunner> TestHarnessFactory;
|
||||
|
||||
} // namespace tester
|
||||
} // namespace sky
|
||||
|
||||
|
||||
@@ -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<TestHarness> request) {
|
||||
new TestHarnessImpl(this, request.Pass());
|
||||
}
|
||||
|
||||
} // namespace tester
|
||||
} // namespace sky
|
||||
|
||||
@@ -25,14 +25,13 @@ class TestRunnerClient {
|
||||
virtual ~TestRunnerClient();
|
||||
};
|
||||
|
||||
class TestRunner {
|
||||
class TestRunner : public mojo::InterfaceFactory<TestHarness> {
|
||||
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<TestRunner> GetWeakPtr();
|
||||
void OnTestStart();
|
||||
@@ -40,7 +39,10 @@ class TestRunner {
|
||||
const mojo::Array<uint8_t>& pixels);
|
||||
|
||||
private:
|
||||
TestHarnessFactory test_harness_factory_;
|
||||
// mojo::InterfaceFactory<TestHarness> implementation:
|
||||
void Create(mojo::ApplicationConnection* app,
|
||||
mojo::InterfaceRequest<TestHarness> request) override;
|
||||
|
||||
mojo::ServiceProviderImpl test_harness_provider_impl_;
|
||||
TestRunnerClient* client_;
|
||||
base::WeakPtrFactory<TestRunner> weak_ptr_factory_;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user