Use StrongBinding instead of InterfaceImpl in wm event dispatcher
R=sky@chromium.org
Review URL: https://codereview.chromium.org/924653002
diff --git a/services/window_manager/native_viewport_event_dispatcher_impl.cc b/services/window_manager/native_viewport_event_dispatcher_impl.cc
index 1d96584..05e415e 100644
--- a/services/window_manager/native_viewport_event_dispatcher_impl.cc
+++ b/services/window_manager/native_viewport_event_dispatcher_impl.cc
@@ -11,8 +11,9 @@
namespace window_manager {
NativeViewportEventDispatcherImpl::NativeViewportEventDispatcherImpl(
- WindowManagerApp* app)
- : app_(app) {
+ WindowManagerApp* app,
+ mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher> request)
+ : app_(app), binding_(this, request.Pass()) {
}
NativeViewportEventDispatcherImpl::~NativeViewportEventDispatcherImpl() {
}
diff --git a/services/window_manager/native_viewport_event_dispatcher_impl.h b/services/window_manager/native_viewport_event_dispatcher_impl.h
index a95821d..d09160d 100644
--- a/services/window_manager/native_viewport_event_dispatcher_impl.h
+++ b/services/window_manager/native_viewport_event_dispatcher_impl.h
@@ -6,6 +6,7 @@
#define SERVICES_WINDOW_MANAGER_NATIVE_VIEWPORT_EVENT_DISPATCHER_IMPL_H_
#include "base/basictypes.h"
+#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom.h"
#include "ui/events/event_source.h"
@@ -15,9 +16,11 @@
class NativeViewportEventDispatcherImpl
: public ui::EventSource,
- public mojo::InterfaceImpl<mojo::NativeViewportEventDispatcher> {
+ public mojo::NativeViewportEventDispatcher {
public:
- explicit NativeViewportEventDispatcherImpl(WindowManagerApp* app);
+ NativeViewportEventDispatcherImpl(
+ WindowManagerApp* app,
+ mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher> request);
~NativeViewportEventDispatcherImpl() override;
private:
@@ -30,6 +33,7 @@
WindowManagerApp* app_;
+ mojo::StrongBinding<mojo::NativeViewportEventDispatcher> binding_;
DISALLOW_COPY_AND_ASSIGN(NativeViewportEventDispatcherImpl);
};
diff --git a/services/window_manager/window_manager_app.cc b/services/window_manager/window_manager_app.cc
index c35c5ff..9b1a87b 100644
--- a/services/window_manager/window_manager_app.cc
+++ b/services/window_manager/window_manager_app.cc
@@ -53,7 +53,6 @@
ViewManagerDelegate* view_manager_delegate,
WindowManagerDelegate* window_manager_delegate)
: shell_(nullptr),
- native_viewport_event_dispatcher_factory_(this),
wrapped_view_manager_delegate_(view_manager_delegate),
window_manager_delegate_(window_manager_delegate),
root_(nullptr) {
@@ -152,7 +151,7 @@
bool WindowManagerApp::ConfigureIncomingConnection(
ApplicationConnection* connection) {
- connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this));
+ connection->AddService<WindowManager>(this);
return true;
}
@@ -333,8 +332,8 @@
app->ConnectToApplication("mojo:view_manager");
view_manager_app->ConnectToService(&view_manager_service_);
- view_manager_app->AddService(&native_viewport_event_dispatcher_factory_);
view_manager_app->AddService<WindowManagerInternal>(this);
+ view_manager_app->AddService<mojo::NativeViewportEventDispatcher>(this);
view_manager_app->ConnectToService(&window_manager_client_);
}
@@ -359,6 +358,12 @@
// destructor.
}
+void WindowManagerApp::Create(
+ mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher> request) {
+ new NativeViewportEventDispatcherImpl(this, request.Pass());
+}
+
void WindowManagerApp::CreateWindowManagerForViewManagerClient(
uint16_t connection_id,
mojo::ScopedMessagePipeHandle window_manager_pipe) {
diff --git a/services/window_manager/window_manager_app.h b/services/window_manager/window_manager_app.h
index ef8f555..a384600 100644
--- a/services/window_manager/window_manager_app.h
+++ b/services/window_manager/window_manager_app.h
@@ -55,6 +55,7 @@
public CaptureControllerObserver,
public mojo::InterfaceFactory<mojo::WindowManager>,
public mojo::InterfaceFactory<mojo::WindowManagerInternal>,
+ public mojo::InterfaceFactory<mojo::NativeViewportEventDispatcher>,
public mojo::WindowManagerInternal {
public:
WindowManagerApp(ViewManagerDelegate* view_manager_delegate,
@@ -153,6 +154,11 @@
void Create(mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mojo::WindowManager> request) override;
+ // InterfaceFactory<NativeViewportEventDispatcher>:
+ void Create(mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher>
+ request) override;
+
// WindowManagerInternal:
void CreateWindowManagerForViewManagerClient(
uint16_t connection_id,
@@ -162,10 +168,6 @@
mojo::Shell* shell_;
- mojo::InterfaceFactoryImplWithContext<NativeViewportEventDispatcherImpl,
- WindowManagerApp>
- native_viewport_event_dispatcher_factory_;
-
ViewManagerDelegate* wrapped_view_manager_delegate_;
WindowManagerDelegate* window_manager_delegate_;