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/mojo/public/cpp/bindings/binding.h b/mojo/public/cpp/bindings/binding.h
index 5f33a61..2510a31 100644
--- a/mojo/public/cpp/bindings/binding.h
+++ b/mojo/public/cpp/bindings/binding.h
@@ -41,15 +41,6 @@
// Binding<Foo> binding_;
// };
//
-// class MyFooFactory : public InterfaceFactory<Foo> {
-// public:
-// void Create(..., InterfaceRequest<Foo> request) override {
-// auto f = new FooImpl(request.Pass());
-// // Do something to manage the lifetime of |f|. Use StrongBinding<> to
-// // delete FooImpl on connection errors.
-// }
-// };
-//
// The caller may specify a |MojoAsyncWaiter| to be used by the connection when
// waiting for calls to arrive. Normally it is fine to use the default waiter.
// However, the caller may provide their own implementation if needed. The
diff --git a/mojo/public/cpp/bindings/strong_binding.h b/mojo/public/cpp/bindings/strong_binding.h
index 3ccbb75..c6ba5cf 100644
--- a/mojo/public/cpp/bindings/strong_binding.h
+++ b/mojo/public/cpp/bindings/strong_binding.h
@@ -42,14 +42,6 @@
// private:
// StrongBinding<Foo> binding_;
// };
-//
-// class MyFooFactory : public InterfaceFactory<Foo> {
-// public:
-// void Create(..., InterfaceRequest<Foo> request) override {
-// new StronglyBound(request.Pass()); // The binding now owns the
-// // instance of StronglyBound.
-// }
-// };
template <typename Interface>
class StrongBinding {
public:
diff --git a/services/keyboard/linux/keyboard_service_impl.h b/services/keyboard/linux/keyboard_service_impl.h
index 6ac6a89..d493de9 100644
--- a/services/keyboard/linux/keyboard_service_impl.h
+++ b/services/keyboard/linux/keyboard_service_impl.h
@@ -6,7 +6,6 @@
#define SERVICES_KEYBOARD_LINUX_KEYBOARD_SERVICE_IMPL_H_
#include "base/macros.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/interfaces/application/shell.mojom.h"
#include "mojo/services/keyboard/interfaces/keyboard.mojom.h"
diff --git a/services/native_viewport/native_viewport_impl.cc b/services/native_viewport/native_viewport_impl.cc
index 7307714..46961ba 100644
--- a/services/native_viewport/native_viewport_impl.cc
+++ b/services/native_viewport/native_viewport_impl.cc
@@ -12,7 +12,6 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/native_viewport/surface_configuration_type_converters.h"
#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "services/gles2/gpu_state.h"
#include "services/native_viewport/platform_viewport_headless.h"
#include "ui/events/event.h"
diff --git a/services/test_service/test_request_tracker_application.cc b/services/test_service/test_request_tracker_application.cc
index ed23d44..b1f0715 100644
--- a/services/test_service/test_request_tracker_application.cc
+++ b/services/test_service/test_request_tracker_application.cc
@@ -29,30 +29,24 @@
ApplicationConnection* connection) {
// Every instance of the service and recorder shares the context.
// Note, this app is single-threaded, so this is thread safe.
- connection->AddService<TestTimeService>(this);
- connection->AddService<TestRequestTracker>(this);
- connection->AddService<TestTrackedRequestService>(this);
+ connection->GetServiceProviderImpl().AddService<TestTimeService>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestTimeService> request) {
+ new TestTimeServiceImpl(app_impl_, request.Pass());
+ });
+ connection->GetServiceProviderImpl().AddService<TestRequestTracker>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestRequestTracker> request) {
+ new TestRequestTrackerImpl(request.Pass(), &context_);
+ });
+ connection->GetServiceProviderImpl().AddService<TestTrackedRequestService>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestTrackedRequestService> request) {
+ new TestTrackedRequestServiceImpl(request.Pass(), &context_);
+ });
return true;
}
-void TestRequestTrackerApplication::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<TestTimeService> request) {
- new TestTimeServiceImpl(app_impl_, request.Pass());
-}
-
-void TestRequestTrackerApplication::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<TestRequestTracker> request) {
- new TestRequestTrackerImpl(request.Pass(), &context_);
-}
-
-void TestRequestTrackerApplication::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<TestTrackedRequestService> request) {
- new TestTrackedRequestServiceImpl(request.Pass(), &context_);
-}
-
} // namespace test
} // namespace mojo
diff --git a/services/test_service/test_request_tracker_application.h b/services/test_service/test_request_tracker_application.h
index c169c90..d936c48 100644
--- a/services/test_service/test_request_tracker_application.h
+++ b/services/test_service/test_request_tracker_application.h
@@ -6,7 +6,6 @@
#define SERVICES_TEST_SERVICE_TEST_REQUEST_TRACKER_APPLICATION_H_
#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/system/macros.h"
#include "services/test_service/test_request_tracker_impl.h"
@@ -16,11 +15,7 @@
class TestTimeService;
// Embeds TestRequestTracker mojo services into an application.
-class TestRequestTrackerApplication
- : public ApplicationDelegate,
- public InterfaceFactory<TestTimeService>,
- public InterfaceFactory<TestRequestTracker>,
- public InterfaceFactory<TestTrackedRequestService> {
+class TestRequestTrackerApplication : public ApplicationDelegate {
public:
TestRequestTrackerApplication();
~TestRequestTrackerApplication() override;
@@ -30,18 +25,6 @@
// ApplicationDelegate methods:
bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
- // InterfaceFactory<TestTimeService> methods:
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestTimeService> request) override;
-
- // InterfaceFactory<TestRequestTracker> methods:
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestRequestTracker> request) override;
-
- // InterfaceFactory<TestTrackedRequestService> methods:
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestTrackedRequestService> request) override;
-
private:
ApplicationImpl* app_impl_;
TrackingContext context_;
diff --git a/services/test_service/test_service_application.cc b/services/test_service/test_service_application.cc
index 509ddac..bf362d3 100644
--- a/services/test_service/test_service_application.cc
+++ b/services/test_service/test_service_application.cc
@@ -29,22 +29,20 @@
bool TestServiceApplication::ConfigureIncomingConnection(
ApplicationConnection* connection) {
- connection->AddService<TestService>(this);
- connection->AddService<TestTimeService>(this);
+ connection->GetServiceProviderImpl().AddService<TestService>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestService> request) {
+ new TestServiceImpl(app_impl_, this, request.Pass());
+ AddRef();
+ });
+ connection->GetServiceProviderImpl().AddService<TestTimeService>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<TestTimeService> request) {
+ new TestTimeServiceImpl(app_impl_, request.Pass());
+ });
return true;
}
-void TestServiceApplication::Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestService> request) {
- new TestServiceImpl(app_impl_, this, request.Pass());
- AddRef();
-}
-
-void TestServiceApplication::Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestTimeService> request) {
- new TestTimeServiceImpl(app_impl_, request.Pass());
-}
-
void TestServiceApplication::AddRef() {
assert(ref_count_ >= 0);
ref_count_++;
diff --git a/services/test_service/test_service_application.h b/services/test_service/test_service_application.h
index 1839311..625e4bb 100644
--- a/services/test_service/test_service_application.h
+++ b/services/test_service/test_service_application.h
@@ -6,7 +6,6 @@
#define SERVICES_TEST_SERVICE_TEST_SERVICE_APPLICATION_H_
#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/system/macros.h"
namespace mojo {
@@ -16,9 +15,7 @@
class TestService;
class TestTimeService;
-class TestServiceApplication : public ApplicationDelegate,
- public InterfaceFactory<TestService>,
- public InterfaceFactory<TestTimeService> {
+class TestServiceApplication : public ApplicationDelegate {
public:
TestServiceApplication();
~TestServiceApplication() override;
@@ -28,14 +25,6 @@
// ApplicationDelegate implementation.
bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
- // InterfaceFactory<TestService> implementation.
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestService> request) override;
-
- // InterfaceFactory<TestTimeService> implementation.
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<TestTimeService> request) override;
-
void AddRef();
void ReleaseRef();
diff --git a/services/tracing/tracing_app.cc b/services/tracing/tracing_app.cc
index 915ed03..0413158 100644
--- a/services/tracing/tracing_app.cc
+++ b/services/tracing/tracing_app.cc
@@ -17,25 +17,26 @@
bool TracingApp::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService<TraceCollector>(this);
+ connection->GetServiceProviderImpl().AddService<TraceCollector>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<TraceCollector> trace_collector_request) {
+ if (collector_binding_.is_bound()) {
+ LOG(ERROR) << "Another application is already connected to tracing.";
+ return;
+ }
+
+ collector_binding_.Bind(trace_collector_request.Pass());
+ });
+ connection->GetServiceProviderImpl().AddService<TraceProviderRegistry>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<TraceProviderRegistry>
+ trace_provider_registry_request) {
+ provider_registry_bindings_.AddBinding(
+ this, trace_provider_registry_request.Pass());
+ });
return true;
}
-void TracingApp::Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<TraceCollector> request) {
- if (collector_binding_.is_bound()) {
- LOG(ERROR) << "Another application is already connected to tracing.";
- return;
- }
-
- collector_binding_.Bind(request.Pass());
-}
-
-void TracingApp::Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<TraceProviderRegistry> request) {
- provider_registry_bindings_.AddBinding(this, request.Pass());
-}
-
void TracingApp::Start(mojo::ScopedDataPipeProducerHandle stream,
const mojo::String& categories) {
tracing_categories_ = categories;
diff --git a/services/tracing/tracing_app.h b/services/tracing/tracing_app.h
index 24395e0..70c010e 100644
--- a/services/tracing/tracing_app.h
+++ b/services/tracing/tracing_app.h
@@ -21,8 +21,6 @@
namespace tracing {
class TracingApp : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<TraceCollector>,
- public mojo::InterfaceFactory<TraceProviderRegistry>,
public TraceCollector,
public TraceProviderRegistry {
public:
@@ -34,14 +32,6 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // mojo::InterfaceFactory<TraceCollector> implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<TraceCollector> request) override;
-
- // mojo::InterfaceFactory<TraceProviderRegistry> implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<TraceProviderRegistry> request) override;
-
// TraceCollector implementation.
void Start(mojo::ScopedDataPipeProducerHandle stream,
const mojo::String& categories) override;
diff --git a/services/ui/input_manager/input_manager_app.cc b/services/ui/input_manager/input_manager_app.cc
index b6adffb..0d2917d 100644
--- a/services/ui/input_manager/input_manager_app.cc
+++ b/services/ui/input_manager/input_manager_app.cc
@@ -34,14 +34,14 @@
bool InputManagerApp::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService<mojo::ui::ViewAssociate>(this);
+ connection->GetServiceProviderImpl().AddService<mojo::ui::ViewAssociate>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<mojo::ui::ViewAssociate>
+ view_associate_request) {
+ input_associates_.AddBinding(new InputAssociate(),
+ view_associate_request.Pass());
+ });
return true;
}
-void InputManagerApp::Create(
- const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::ui::ViewAssociate> request) {
- input_associates.AddBinding(new InputAssociate(), request.Pass());
-}
-
} // namespace input_manager
diff --git a/services/ui/input_manager/input_manager_app.h b/services/ui/input_manager/input_manager_app.h
index 764487b..5c8a817 100644
--- a/services/ui/input_manager/input_manager_app.h
+++ b/services/ui/input_manager/input_manager_app.h
@@ -11,14 +11,12 @@
#include "mojo/common/strong_binding_set.h"
#include "mojo/common/tracing_impl.h"
#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
namespace input_manager {
// Input manager application entry point.
-class InputManagerApp : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<mojo::ui::ViewAssociate> {
+class InputManagerApp : public mojo::ApplicationDelegate {
public:
InputManagerApp();
~InputManagerApp() override;
@@ -29,14 +27,10 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // |InterfaceFactory<ViewAssociate>|:
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::ui::ViewAssociate> request) override;
-
mojo::ApplicationImpl* app_impl_;
mojo::TracingImpl tracing_;
- mojo::StrongBindingSet<mojo::ui::ViewAssociate> input_associates;
+ mojo::StrongBindingSet<mojo::ui::ViewAssociate> input_associates_;
DISALLOW_COPY_AND_ASSIGN(InputManagerApp);
};
diff --git a/services/ui/launcher/launcher_app.cc b/services/ui/launcher/launcher_app.cc
index d0f1377..9a6fe1f 100644
--- a/services/ui/launcher/launcher_app.cc
+++ b/services/ui/launcher/launcher_app.cc
@@ -42,16 +42,15 @@
if (connection->GetServiceProviderImpl()
.connection_context()
.remote_url.empty()) {
- connection->AddService<Launcher>(this);
+ connection->GetServiceProviderImpl().AddService<Launcher>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<Launcher> launcher_request) {
+ bindings_.AddBinding(this, launcher_request.Pass());
+ });
}
return true;
}
-void LauncherApp::Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<Launcher> request) {
- bindings_.AddBinding(this, request.Pass());
-}
-
void LauncherApp::Launch(const mojo::String& application_url) {
uint32_t next_id = next_id_++;
std::unique_ptr<LaunchInstance> instance(new LaunchInstance(
diff --git a/services/ui/launcher/launcher_app.h b/services/ui/launcher/launcher_app.h
index 153641d..f6a65d1 100644
--- a/services/ui/launcher/launcher_app.h
+++ b/services/ui/launcher/launcher_app.h
@@ -16,9 +16,7 @@
namespace launcher {
-class LauncherApp : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<Launcher>,
- public Launcher {
+class LauncherApp : public mojo::ApplicationDelegate, public Launcher {
public:
LauncherApp();
~LauncherApp() override;
@@ -29,10 +27,6 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // mojo::InterfaceRequest<Launcher> implementation
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<Launcher> request) override;
-
// |Launcher|:
void Launch(const mojo::String& application_url) override;
diff --git a/services/ui/view_manager/view_manager_app.cc b/services/ui/view_manager/view_manager_app.cc
index 63ebbba..ae5c2eb 100644
--- a/services/ui/view_manager/view_manager_app.cc
+++ b/services/ui/view_manager/view_manager_app.cc
@@ -61,18 +61,16 @@
bool ViewManagerApp::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService<mojo::ui::ViewManager>(this);
+ connection->GetServiceProviderImpl().AddService<mojo::ui::ViewManager>([this](
+ const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<mojo::ui::ViewManager> view_manager_request) {
+ DCHECK(registry_);
+ view_managers_.AddBinding(new ViewManagerImpl(registry_.get()),
+ view_manager_request.Pass());
+ });
return true;
}
-void ViewManagerApp::Create(
- const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::ui::ViewManager> request) {
- DCHECK(registry_);
- view_managers_.AddBinding(new ViewManagerImpl(registry_.get()),
- request.Pass());
-}
-
void ViewManagerApp::OnCompositorConnectionError() {
LOG(ERROR) << "Exiting due to compositor connection error.";
Shutdown();
diff --git a/services/ui/view_manager/view_manager_app.h b/services/ui/view_manager/view_manager_app.h
index 2088435..39c32cc 100644
--- a/services/ui/view_manager/view_manager_app.h
+++ b/services/ui/view_manager/view_manager_app.h
@@ -18,8 +18,7 @@
namespace view_manager {
// View manager application entry point.
-class ViewManagerApp : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<mojo::ui::ViewManager> {
+class ViewManagerApp : public mojo::ApplicationDelegate {
public:
ViewManagerApp();
~ViewManagerApp() override;
@@ -30,10 +29,6 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // |InterfaceFactory<ViewManager>|:
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::ui::ViewManager> request) override;
-
void OnCompositorConnectionError();
void OnAssociateConnectionError(const std::string& url);
diff --git a/services/url_response_disk_cache/url_response_disk_cache_app.cc b/services/url_response_disk_cache/url_response_disk_cache_app.cc
index e63d15f..a2f6ed8 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_app.cc
+++ b/services/url_response_disk_cache/url_response_disk_cache_app.cc
@@ -25,15 +25,13 @@
bool URLResponseDiskCacheApp::ConfigureIncomingConnection(
ApplicationConnection* connection) {
- connection->AddService<URLResponseDiskCache>(this);
+ connection->GetServiceProviderImpl().AddService<URLResponseDiskCache>([this](
+ const ConnectionContext& connection_context,
+ InterfaceRequest<URLResponseDiskCache> request) {
+ new URLResponseDiskCacheImpl(task_runner_, delegate_, db_,
+ connection_context.remote_url, request.Pass());
+ });
return true;
}
-void URLResponseDiskCacheApp::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<URLResponseDiskCache> request) {
- new URLResponseDiskCacheImpl(task_runner_, delegate_, db_,
- connection_context.remote_url, request.Pass());
-}
-
} // namespace mojo
diff --git a/services/url_response_disk_cache/url_response_disk_cache_app.h b/services/url_response_disk_cache/url_response_disk_cache_app.h
index 7e0715c..52d4e14 100644
--- a/services/url_response_disk_cache/url_response_disk_cache_app.h
+++ b/services/url_response_disk_cache/url_response_disk_cache_app.h
@@ -12,15 +12,13 @@
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/services/url_response_disk_cache/interfaces/url_response_disk_cache.mojom.h"
#include "services/url_response_disk_cache/url_response_disk_cache_db.h"
#include "services/url_response_disk_cache/url_response_disk_cache_delegate.h"
namespace mojo {
-class URLResponseDiskCacheApp : public ApplicationDelegate,
- public InterfaceFactory<URLResponseDiskCache> {
+class URLResponseDiskCacheApp : public ApplicationDelegate {
public:
explicit URLResponseDiskCacheApp(scoped_refptr<base::TaskRunner> task_runner,
URLResponseDiskCacheDelegate* delegate);
@@ -31,10 +29,6 @@
void Initialize(ApplicationImpl* app) override;
bool ConfigureIncomingConnection(ApplicationConnection* connection) override;
- // InterfaceFactory<URLResponseDiskCache>:
- void Create(const ConnectionContext& connection_context,
- InterfaceRequest<URLResponseDiskCache> request) override;
-
scoped_refptr<base::TaskRunner> task_runner_;
scoped_refptr<URLResponseDiskCacheDB> db_;
URLResponseDiskCacheDelegate* delegate_;
diff --git a/shell/android/native_viewport_application_loader.cc b/shell/android/native_viewport_application_loader.cc
index ea9bc9b..359f004 100644
--- a/shell/android/native_viewport_application_loader.cc
+++ b/shell/android/native_viewport_application_loader.cc
@@ -29,26 +29,22 @@
bool NativeViewportApplicationLoader::ConfigureIncomingConnection(
ApplicationConnection* connection) {
- connection->AddService<mojo::NativeViewport>(this);
- connection->AddService<mojo::Gpu>(this);
+ connection->GetServiceProviderImpl().AddService<mojo::NativeViewport>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<mojo::NativeViewport> native_viewport_request) {
+ if (!gpu_state_)
+ gpu_state_ = new gles2::GpuState();
+ new native_viewport::NativeViewportImpl(app_.get(), false, gpu_state_,
+ native_viewport_request.Pass());
+ });
+ connection->GetServiceProviderImpl().AddService<mojo::Gpu>(
+ [this](const ConnectionContext& connection_context,
+ InterfaceRequest<mojo::Gpu> gpu_request) {
+ if (!gpu_state_)
+ gpu_state_ = new gles2::GpuState();
+ new gles2::GpuImpl(gpu_request.Pass(), gpu_state_);
+ });
return true;
}
-void NativeViewportApplicationLoader::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<mojo::NativeViewport> request) {
- if (!gpu_state_)
- gpu_state_ = new gles2::GpuState;
- new native_viewport::NativeViewportImpl(app_.get(), false, gpu_state_,
- request.Pass());
-}
-
-void NativeViewportApplicationLoader::Create(
- const ConnectionContext& connection_context,
- InterfaceRequest<mojo::Gpu> request) {
- if (!gpu_state_)
- gpu_state_ = new gles2::GpuState;
- new gles2::GpuImpl(request.Pass(), gpu_state_);
-}
-
} // namespace shell
diff --git a/shell/android/native_viewport_application_loader.h b/shell/android/native_viewport_application_loader.h
index 861a691..a1663b1 100644
--- a/shell/android/native_viewport_application_loader.h
+++ b/shell/android/native_viewport_application_loader.h
@@ -6,7 +6,6 @@
#define MOJO_SHELL_ANDROID_NATIVE_VIEWPORT_APPLICATION_LOADER_H_
#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/services/gpu/interfaces/gpu.mojom.h"
#include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h"
#include "services/gles2/gpu_impl.h"
@@ -22,11 +21,8 @@
namespace shell {
-class NativeViewportApplicationLoader
- : public ApplicationLoader,
- public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<mojo::NativeViewport>,
- public mojo::InterfaceFactory<mojo::Gpu> {
+class NativeViewportApplicationLoader : public ApplicationLoader,
+ public mojo::ApplicationDelegate {
public:
NativeViewportApplicationLoader();
~NativeViewportApplicationLoader();
@@ -41,14 +37,6 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override;
- // mojo::InterfaceFactory<mojo::NativeViewport> implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::NativeViewport> request) override;
-
- // mojo::InterfaceFactory<mojo::Gpu> implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::Gpu> request) override;
-
scoped_refptr<gles2::GpuState> gpu_state_;
scoped_ptr<mojo::ApplicationImpl> app_;
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_;
diff --git a/shell/test/pingable_app.cc b/shell/test/pingable_app.cc
index 2436a7d..f4520f6 100644
--- a/shell/test/pingable_app.cc
+++ b/shell/test/pingable_app.cc
@@ -8,7 +8,6 @@
#include "mojo/public/cpp/application/application_delegate.h"
#include "mojo/public/cpp/application/application_impl.h"
#include "mojo/public/cpp/application/application_runner.h"
-#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
@@ -39,8 +38,7 @@
std::string connection_url_;
};
-class PingableApp : public mojo::ApplicationDelegate,
- public mojo::InterfaceFactory<Pingable> {
+class PingableApp : public mojo::ApplicationDelegate {
public:
PingableApp() {}
~PingableApp() override {}
@@ -53,17 +51,15 @@
bool ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) override {
- connection->AddService(this);
+ connection->GetServiceProviderImpl().AddService<Pingable>(
+ [this](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<Pingable> pingable_request) {
+ new PingableImpl(pingable_request.Pass(), app_url_,
+ connection_context.connection_url);
+ });
return true;
}
- // InterfaceFactory<Pingable>:
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<Pingable> request) override {
- new PingableImpl(request.Pass(), app_url_,
- connection_context.connection_url);
- }
-
std::string app_url_;
};
diff --git a/ui/ozone/platform/drm/mojo/drm_ipc_init_helper.cc b/ui/ozone/platform/drm/mojo/drm_ipc_init_helper.cc
index ecbd1a9..5182396 100644
--- a/ui/ozone/platform/drm/mojo/drm_ipc_init_helper.cc
+++ b/ui/ozone/platform/drm/mojo/drm_ipc_init_helper.cc
@@ -14,24 +14,6 @@
namespace ui {
-class InterfaceFactoryDrmHost
- : public mojo::InterfaceFactory<mojo::OzoneDrmHost> {
- // mojo::InterfaceFactory implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::OzoneDrmHost> request) override {
- new MojoDrmHostImpl(request.Pass());
- }
-};
-
-class InterfaceFactoryDrmGpu
- : public mojo::InterfaceFactory<mojo::OzoneDrmGpu> {
- // mojo::InterfaceFactory<OzoneDrmGpu> implementation.
- void Create(const mojo::ConnectionContext& connection_context,
- mojo::InterfaceRequest<mojo::OzoneDrmGpu> request) override {
- new MojoDrmGpuImpl(request.Pass());
- }
-};
-
class DrmIpcInitHelperMojo : public IpcInitHelperMojo {
public:
DrmIpcInitHelperMojo();
@@ -68,13 +50,21 @@
bool DrmIpcInitHelperMojo::HostConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService<mojo::OzoneDrmHost>(new InterfaceFactoryDrmHost());
+ connection->GetServiceProviderImpl().AddService<mojo::OzoneDrmHost>(
+ [](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<mojo::OzoneDrmHost> request) {
+ new MojoDrmHostImpl(request.Pass());
+ });
return true;
}
bool DrmIpcInitHelperMojo::GpuConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService<mojo::OzoneDrmGpu>(new InterfaceFactoryDrmGpu());
+ connection->GetServiceProviderImpl().AddService<mojo::OzoneDrmGpu>(
+ [](const mojo::ConnectionContext& connection_context,
+ mojo::InterfaceRequest<mojo::OzoneDrmGpu> request) {
+ new MojoDrmGpuImpl(request.Pass());
+ });
return true;
}