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

Side by Side Diff: mojo/services/view_manager/connection_manager.cc

Issue 636363002: Splits window manager like methods into ViewManagerServiceDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge 2 trunk Created 6 years, 2 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
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 "mojo/services/view_manager/connection_manager.h" 5 #include "mojo/services/view_manager/connection_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/converters/input_events/input_events_type_converters.h" 8 #include "mojo/converters/input_events/input_events_type_converters.h"
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/interfaces/application/service_provider.mojom.h" 10 #include "mojo/public/interfaces/application/service_provider.mojom.h"
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 ConnectionManager::ScopedChange::~ScopedChange() { 26 ConnectionManager::ScopedChange::~ScopedChange() {
27 connection_manager_->FinishChange(); 27 connection_manager_->FinishChange();
28 } 28 }
29 29
30 ConnectionManager::ConnectionManager( 30 ConnectionManager::ConnectionManager(
31 ApplicationConnection* app_connection, 31 ApplicationConnection* app_connection,
32 const Callback<void()>& native_viewport_closed_callback) 32 const Callback<void()>& native_viewport_closed_callback)
33 : app_connection_(app_connection), 33 : app_connection_(app_connection),
34 wm_client_impl_(this),
34 next_connection_id_(1), 35 next_connection_id_(1),
35 display_manager_(app_connection, 36 display_manager_(app_connection, this, native_viewport_closed_callback),
36 this,
37 native_viewport_closed_callback),
38 root_(new ServerView(this, RootViewId())), 37 root_(new ServerView(this, RootViewId())),
39 current_change_(NULL) { 38 current_change_(NULL) {
40 root_->SetBounds(gfx::Rect(800, 600)); 39 root_->SetBounds(gfx::Rect(800, 600));
41 } 40 }
42 41
43 ConnectionManager::~ConnectionManager() { 42 ConnectionManager::~ConnectionManager() {
44 while (!connections_created_by_connect_.empty()) 43 while (!connections_created_by_connect_.empty())
45 delete *(connections_created_by_connect_.begin()); 44 delete *(connections_created_by_connect_.begin());
46 // All the connections should have been destroyed. 45 // All the connections should have been destroyed.
47 DCHECK(connection_map_.empty()); 46 DCHECK(connection_map_.empty());
(...skipping 16 matching lines...) Expand all
64 connections_created_by_connect_.erase(connection); 63 connections_created_by_connect_.erase(connection);
65 64
66 // Notify remaining connections so that they can cleanup. 65 // Notify remaining connections so that they can cleanup.
67 for (ConnectionMap::const_iterator i = connection_map_.begin(); 66 for (ConnectionMap::const_iterator i = connection_map_.begin();
68 i != connection_map_.end(); 67 i != connection_map_.end();
69 ++i) { 68 ++i) {
70 i->second->OnViewManagerServiceImplDestroyed(connection->id()); 69 i->second->OnViewManagerServiceImplDestroyed(connection->id());
71 } 70 }
72 } 71 }
73 72
74 void ConnectionManager::EmbedRoot( 73 void ConnectionManager::Embed(
75 const std::string& url, 74 const std::string& url,
76 InterfaceRequest<ServiceProvider> service_provider) { 75 InterfaceRequest<ServiceProvider> service_provider) {
77 if (connection_map_.empty()) { 76 if (connection_map_.empty()) {
77 // TODO(sky): this is unsafe and racy. Need a better way to determine the
78 // window manager.
78 EmbedImpl(kInvalidConnectionId, 79 EmbedImpl(kInvalidConnectionId,
79 String::From(url), 80 String::From(url),
80 RootViewId(), 81 RootViewId(),
81 service_provider.Pass()); 82 service_provider.Pass());
82 return; 83 return;
83 } 84 }
84 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection); 85 wm_client_impl_.client()->Embed(url, service_provider.Pass());
85 connection->client()->Embed(url, service_provider.Pass());
86 } 86 }
87 87
88 void ConnectionManager::Embed( 88 void ConnectionManager::EmbedAtView(
89 ConnectionSpecificId creator_id, 89 ConnectionSpecificId creator_id,
90 const String& url, 90 const String& url,
91 Id transport_view_id, 91 Id transport_view_id,
92 InterfaceRequest<ServiceProvider> service_provider) { 92 InterfaceRequest<ServiceProvider> service_provider) {
93 EmbedImpl(creator_id, 93 EmbedImpl(creator_id,
94 url, 94 url,
95 ViewIdFromTransportId(transport_view_id), 95 ViewIdFromTransportId(transport_view_id),
96 service_provider.Pass())->set_delete_on_connection_error(); 96 service_provider.Pass())->set_delete_on_connection_error();
97 } 97 }
98 98
(...skipping 24 matching lines...) Expand all
123 const ViewId& id) const { 123 const ViewId& id) const {
124 for (ConnectionMap::const_iterator i = connection_map_.begin(); 124 for (ConnectionMap::const_iterator i = connection_map_.begin();
125 i != connection_map_.end(); 125 i != connection_map_.end();
126 ++i) { 126 ++i) {
127 if (i->second->HasRoot(id)) 127 if (i->second->HasRoot(id))
128 return i->second; 128 return i->second;
129 } 129 }
130 return NULL; 130 return NULL;
131 } 131 }
132 132
133 void ConnectionManager::DispatchViewInputEventToWindowManager(EventPtr event) { 133 void ConnectionManager::DispatchViewInputEventToDelegate(EventPtr event) {
134 // Input events are forwarded to the WindowManager. The WindowManager 134 if (wm_client_impl_.client())
135 // eventually calls back to us with DispatchOnViewInputEvent(). 135 wm_client_impl_.client()->OnViewInputEvent(event.Pass());
136 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection);
137 if (!connection)
138 return;
139 connection->client()->DispatchOnViewInputEvent(event.Pass());
140 } 136 }
141 137
142 void ConnectionManager::ProcessViewBoundsChanged(const ServerView* view, 138 void ConnectionManager::ProcessViewBoundsChanged(const ServerView* view,
143 const gfx::Rect& old_bounds, 139 const gfx::Rect& old_bounds,
144 const gfx::Rect& new_bounds) { 140 const gfx::Rect& new_bounds) {
145 for (ConnectionMap::iterator i = connection_map_.begin(); 141 for (ConnectionMap::iterator i = connection_map_.begin();
146 i != connection_map_.end(); 142 i != connection_map_.end();
147 ++i) { 143 ++i) {
148 i->second->ProcessViewBoundsChanged( 144 i->second->ProcessViewBoundsChanged(
149 view, old_bounds, new_bounds, IsChangeSource(i->first)); 145 view, old_bounds, new_bounds, IsChangeSource(i->first));
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 203
208 ViewManagerServiceImpl* ConnectionManager::EmbedImpl( 204 ViewManagerServiceImpl* ConnectionManager::EmbedImpl(
209 const ConnectionSpecificId creator_id, 205 const ConnectionSpecificId creator_id,
210 const String& url, 206 const String& url,
211 const ViewId& root_id, 207 const ViewId& root_id,
212 InterfaceRequest<ServiceProvider> service_provider) { 208 InterfaceRequest<ServiceProvider> service_provider) {
213 MessagePipe pipe; 209 MessagePipe pipe;
214 210
215 ServiceProvider* view_manager_service_provider = 211 ServiceProvider* view_manager_service_provider =
216 app_connection_->ConnectToApplication(url)->GetServiceProvider(); 212 app_connection_->ConnectToApplication(url)->GetServiceProvider();
213
217 view_manager_service_provider->ConnectToService( 214 view_manager_service_provider->ConnectToService(
218 ViewManagerServiceImpl::Client::Name_, pipe.handle1.Pass()); 215 ViewManagerServiceImpl::Client::Name_, pipe.handle1.Pass());
219 216
217 if (root_id == RootViewId()) {
218 MessagePipe wm_pipe;
219 view_manager_service_provider->ConnectToService(
220 WindowManagerClientImpl::Client::Name_, wm_pipe.handle1.Pass());
221 WeakBindToPipe(&wm_client_impl_, wm_pipe.handle0.Pass());
222 }
223
220 std::string creator_url; 224 std::string creator_url;
221 ConnectionMap::const_iterator it = connection_map_.find(creator_id); 225 ConnectionMap::const_iterator it = connection_map_.find(creator_id);
222 if (it != connection_map_.end()) 226 if (it != connection_map_.end())
223 creator_url = it->second->url(); 227 creator_url = it->second->url();
224 228
225 ViewManagerServiceImpl* connection = 229 ViewManagerServiceImpl* connection =
226 new ViewManagerServiceImpl(this, 230 new ViewManagerServiceImpl(this,
227 creator_id, 231 creator_id,
228 creator_url, 232 creator_url,
229 url.To<std::string>(), 233 url.To<std::string>(),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) { 292 void ConnectionManager::OnWillChangeViewVisibility(const ServerView* view) {
289 for (ConnectionMap::iterator i = connection_map_.begin(); 293 for (ConnectionMap::iterator i = connection_map_.begin();
290 i != connection_map_.end(); 294 i != connection_map_.end();
291 ++i) { 295 ++i) {
292 i->second->ProcessWillChangeViewVisibility(view, IsChangeSource(i->first)); 296 i->second->ProcessWillChangeViewVisibility(view, IsChangeSource(i->first));
293 } 297 }
294 } 298 }
295 299
296 } // namespace service 300 } // namespace service
297 } // namespace mojo 301 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/connection_manager.h ('k') | mojo/services/view_manager/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698