Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: services/window_manager/window_manager_app.cc

Issue 924653002: Use StrongBinding instead of InterfaceImpl in wm event dispatcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/window_manager/window_manager_app.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/window_manager/window_manager_app.h" 5 #include "services/window_manager/window_manager_app.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/converters/input_events/input_events_type_converters.h" 10 #include "mojo/converters/input_events/input_events_type_converters.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 mojo::ServiceProviderPtr exposed_services; 46 mojo::ServiceProviderPtr exposed_services;
47 }; 47 };
48 48
49 //////////////////////////////////////////////////////////////////////////////// 49 ////////////////////////////////////////////////////////////////////////////////
50 // WindowManagerApp, public: 50 // WindowManagerApp, public:
51 51
52 WindowManagerApp::WindowManagerApp( 52 WindowManagerApp::WindowManagerApp(
53 ViewManagerDelegate* view_manager_delegate, 53 ViewManagerDelegate* view_manager_delegate,
54 WindowManagerDelegate* window_manager_delegate) 54 WindowManagerDelegate* window_manager_delegate)
55 : shell_(nullptr), 55 : shell_(nullptr),
56 native_viewport_event_dispatcher_factory_(this),
57 wrapped_view_manager_delegate_(view_manager_delegate), 56 wrapped_view_manager_delegate_(view_manager_delegate),
58 window_manager_delegate_(window_manager_delegate), 57 window_manager_delegate_(window_manager_delegate),
59 root_(nullptr) { 58 root_(nullptr) {
60 } 59 }
61 60
62 WindowManagerApp::~WindowManagerApp() { 61 WindowManagerApp::~WindowManagerApp() {
63 // TODO(msw|sky): Should this destructor explicitly delete the ViewManager? 62 // TODO(msw|sky): Should this destructor explicitly delete the ViewManager?
64 mojo::ViewManager* cached_view_manager = view_manager(); 63 mojo::ViewManager* cached_view_manager = view_manager();
65 for (RegisteredViewIdSet::const_iterator it = registered_view_id_set_.begin(); 64 for (RegisteredViewIdSet::const_iterator it = registered_view_id_set_.begin();
66 cached_view_manager && it != registered_view_id_set_.end(); ++it) { 65 cached_view_manager && it != registered_view_id_set_.end(); ++it) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 //////////////////////////////////////////////////////////////////////////////// 144 ////////////////////////////////////////////////////////////////////////////////
146 // WindowManagerApp, ApplicationDelegate implementation: 145 // WindowManagerApp, ApplicationDelegate implementation:
147 146
148 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) { 147 void WindowManagerApp::Initialize(mojo::ApplicationImpl* impl) {
149 shell_ = impl->shell(); 148 shell_ = impl->shell();
150 LaunchViewManager(impl); 149 LaunchViewManager(impl);
151 } 150 }
152 151
153 bool WindowManagerApp::ConfigureIncomingConnection( 152 bool WindowManagerApp::ConfigureIncomingConnection(
154 ApplicationConnection* connection) { 153 ApplicationConnection* connection) {
155 connection->AddService(static_cast<InterfaceFactory<WindowManager>*>(this)); 154 connection->AddService<WindowManager>(this);
156 return true; 155 return true;
157 } 156 }
158 157
159 //////////////////////////////////////////////////////////////////////////////// 158 ////////////////////////////////////////////////////////////////////////////////
160 // WindowManagerApp, ViewManagerDelegate implementation: 159 // WindowManagerApp, ViewManagerDelegate implementation:
161 160
162 void WindowManagerApp::OnEmbed( 161 void WindowManagerApp::OnEmbed(
163 View* root, 162 View* root,
164 mojo::InterfaceRequest<mojo::ServiceProvider> services, 163 mojo::InterfaceRequest<mojo::ServiceProvider> services,
165 mojo::ServiceProviderPtr exposed_services) { 164 mojo::ServiceProviderPtr exposed_services) {
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 325
327 void WindowManagerApp::LaunchViewManager(mojo::ApplicationImpl* app) { 326 void WindowManagerApp::LaunchViewManager(mojo::ApplicationImpl* app) {
328 // TODO(sky): figure out logic if this connection goes away. 327 // TODO(sky): figure out logic if this connection goes away.
329 view_manager_client_factory_.reset( 328 view_manager_client_factory_.reset(
330 new mojo::ViewManagerClientFactory(shell_, this)); 329 new mojo::ViewManagerClientFactory(shell_, this));
331 330
332 ApplicationConnection* view_manager_app = 331 ApplicationConnection* view_manager_app =
333 app->ConnectToApplication("mojo:view_manager"); 332 app->ConnectToApplication("mojo:view_manager");
334 view_manager_app->ConnectToService(&view_manager_service_); 333 view_manager_app->ConnectToService(&view_manager_service_);
335 334
336 view_manager_app->AddService(&native_viewport_event_dispatcher_factory_);
337 view_manager_app->AddService<WindowManagerInternal>(this); 335 view_manager_app->AddService<WindowManagerInternal>(this);
336 view_manager_app->AddService<mojo::NativeViewportEventDispatcher>(this);
338 337
339 view_manager_app->ConnectToService(&window_manager_client_); 338 view_manager_app->ConnectToService(&window_manager_client_);
340 } 339 }
341 340
342 void WindowManagerApp::Create( 341 void WindowManagerApp::Create(
343 ApplicationConnection* connection, 342 ApplicationConnection* connection,
344 mojo::InterfaceRequest<WindowManagerInternal> request) { 343 mojo::InterfaceRequest<WindowManagerInternal> request) {
345 if (wm_internal_binding_.get()) { 344 if (wm_internal_binding_.get()) {
346 VLOG(1) << 345 VLOG(1) <<
347 "WindowManager allows only one WindowManagerInternal connection."; 346 "WindowManager allows only one WindowManagerInternal connection.";
348 return; 347 return;
349 } 348 }
350 wm_internal_binding_.reset( 349 wm_internal_binding_.reset(
351 new mojo::Binding<WindowManagerInternal>(this, request.Pass())); 350 new mojo::Binding<WindowManagerInternal>(this, request.Pass()));
352 } 351 }
353 352
354 void WindowManagerApp::Create(ApplicationConnection* connection, 353 void WindowManagerApp::Create(ApplicationConnection* connection,
355 mojo::InterfaceRequest<WindowManager> request) { 354 mojo::InterfaceRequest<WindowManager> request) {
356 WindowManagerImpl* wm = new WindowManagerImpl(this, false); 355 WindowManagerImpl* wm = new WindowManagerImpl(this, false);
357 wm->Bind(request.PassMessagePipe()); 356 wm->Bind(request.PassMessagePipe());
358 // WindowManagerImpl is deleted when the connection has an error, or from our 357 // WindowManagerImpl is deleted when the connection has an error, or from our
359 // destructor. 358 // destructor.
360 } 359 }
361 360
361 void WindowManagerApp::Create(
362 mojo::ApplicationConnection* connection,
363 mojo::InterfaceRequest<mojo::NativeViewportEventDispatcher> request) {
364 new NativeViewportEventDispatcherImpl(this, request.Pass());
365 }
366
362 void WindowManagerApp::CreateWindowManagerForViewManagerClient( 367 void WindowManagerApp::CreateWindowManagerForViewManagerClient(
363 uint16_t connection_id, 368 uint16_t connection_id,
364 mojo::ScopedMessagePipeHandle window_manager_pipe) { 369 mojo::ScopedMessagePipeHandle window_manager_pipe) {
365 // TODO(sky): pass in |connection_id| for validation. 370 // TODO(sky): pass in |connection_id| for validation.
366 WindowManagerImpl* wm = new WindowManagerImpl(this, true); 371 WindowManagerImpl* wm = new WindowManagerImpl(this, true);
367 wm->Bind(window_manager_pipe.Pass()); 372 wm->Bind(window_manager_pipe.Pass());
368 // WindowManagerImpl is deleted when the connection has an error, or from our 373 // WindowManagerImpl is deleted when the connection has an error, or from our
369 // destructor. 374 // destructor.
370 } 375 }
371 376
372 void WindowManagerApp::SetViewManagerClient( 377 void WindowManagerApp::SetViewManagerClient(
373 mojo::ScopedMessagePipeHandle view_manager_client_request) { 378 mojo::ScopedMessagePipeHandle view_manager_client_request) {
374 view_manager_client_.reset( 379 view_manager_client_.reset(
375 mojo::ViewManagerClientFactory::WeakBindViewManagerToPipe( 380 mojo::ViewManagerClientFactory::WeakBindViewManagerToPipe(
376 mojo::MakeRequest<mojo::ViewManagerClient>( 381 mojo::MakeRequest<mojo::ViewManagerClient>(
377 view_manager_client_request.Pass()), 382 view_manager_client_request.Pass()),
378 view_manager_service_.Pass(), shell_, this)); 383 view_manager_service_.Pass(), shell_, this));
379 } 384 }
380 385
381 } // namespace window_manager 386 } // namespace window_manager
OLDNEW
« no previous file with comments | « services/window_manager/window_manager_app.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698