ApplicationConnection devolution, part 2.3.
A.k.a. nuke InterfaceFactory, part 3.
I also noticed that I previously forgot to call AddService() in
tracing_app.cc.
R=vardhan@google.com
BUG=probably has something to do with #775 and #776 (may fix them)
Review URL: https://codereview.chromium.org/1980763002 .
diff --git a/shell/application_manager/application_manager_unittest.cc b/shell/application_manager/application_manager_unittest.cc
index 8ea79c0..c8c677e 100644
--- a/shell/application_manager/application_manager_unittest.cc
+++ b/shell/application_manager/application_manager_unittest.cc
@@ -15,7 +15,6 @@
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "shell/application_manager/application_loader.h"
@@ -28,7 +27,6 @@
using mojo::ApplicationImpl;
using mojo::Callback;
using mojo::ConnectionContext;
-using mojo::InterfaceFactory;
using mojo::InterfaceRequest;
using mojo::StrongBinding;
@@ -100,8 +98,7 @@
};
class TestApplicationLoader : public ApplicationLoader,
- public ApplicationDelegate,
- public InterfaceFactory<TestService> {
+ public ApplicationDelegate {
public:
TestApplicationLoader() : context_(nullptr), num_loads_(0) {}
@@ -125,16 +122,14 @@
// ApplicationDelegate implementation.
bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- connection->AddService(this);
+ connection->GetServiceProviderImpl().AddService<TestService>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestService> request) {
+ new TestServiceImpl(context_, request.Pass());
+ });
return true;
}
- // InterfaceFactory implementation.
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestService> request) override {
- new TestServiceImpl(context_, request.Pass());
- }
-
scoped_ptr<ApplicationImpl> test_app_;
TestContext* context_;
int num_loads_;
@@ -298,10 +293,7 @@
StrongBinding<TestB> binding_;
};
-class Tester : public ApplicationDelegate,
- public ApplicationLoader,
- public InterfaceFactory<TestA>,
- public InterfaceFactory<TestB> {
+class Tester : public ApplicationDelegate, public ApplicationLoader {
public:
Tester(TesterContext* context, const std::string& requestor_url)
: context_(context), requestor_url_(requestor_url) {}
@@ -323,27 +315,26 @@
return false;
}
// If we're coming from A, then add B, otherwise A.
- if (remote_url == kTestAURLString)
- connection->AddService<TestB>(this);
- else
- connection->AddService<TestA>(this);
+ if (remote_url == kTestAURLString) {
+ connection->GetServiceProviderImpl().AddService<TestB>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestB> test_b_request) {
+ new TestBImpl(context_, test_b_request.Pass());
+ });
+ } else {
+ connection->GetServiceProviderImpl().AddService<TestA>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestA> test_a_request) {
+ mojo::InterfaceHandle<mojo::ServiceProvider> incoming_sp_handle;
+ app_->shell()->ConnectToApplication(
+ kTestBURLString, GetProxy(&incoming_sp_handle), nullptr);
+ a_bindings_.push_back(new TestAImpl(
+ incoming_sp_handle.Pass(), context_, test_a_request.Pass()));
+ });
+ }
return true;
}
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestA> request) override {
- mojo::InterfaceHandle<mojo::ServiceProvider> incoming_sp_handle;
- app_->shell()->ConnectToApplication(kTestBURLString,
- GetProxy(&incoming_sp_handle), nullptr);
- a_bindings_.push_back(
- new TestAImpl(incoming_sp_handle.Pass(), context_, request.Pass()));
- }
-
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestB> request) override {
- new TestBImpl(context_, request.Pass());
- }
-
TesterContext* context_;
scoped_ptr<ApplicationImpl> app_;
std::string requestor_url_;