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

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

Issue 397263004: Nukes change_ids from view manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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/root_node_manager.h" 5 #include "mojo/services/view_manager/root_node_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" 9 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
11 #include "mojo/services/view_manager/view.h" 11 #include "mojo/services/view_manager/view.h"
12 #include "mojo/services/view_manager/view_manager_service_impl.h" 12 #include "mojo/services/view_manager/view_manager_service_impl.h"
13 #include "ui/aura/client/focus_client.h" 13 #include "ui/aura/client/focus_client.h"
14 #include "ui/aura/env.h" 14 #include "ui/aura/env.h"
15 15
16 namespace mojo { 16 namespace mojo {
17 namespace view_manager { 17 namespace view_manager {
18 namespace service { 18 namespace service {
19 19
20 RootNodeManager::ScopedChange::ScopedChange( 20 RootNodeManager::ScopedChange::ScopedChange(
21 ViewManagerServiceImpl* connection, 21 ViewManagerServiceImpl* connection,
22 RootNodeManager* root, 22 RootNodeManager* root,
23 RootNodeManager::ChangeType change_type,
24 bool is_delete_node) 23 bool is_delete_node)
25 : root_(root), 24 : root_(root),
26 connection_id_(connection->id()), 25 connection_id_(connection->id()),
27 change_type_(change_type),
28 is_delete_node_(is_delete_node) { 26 is_delete_node_(is_delete_node) {
29 root_->PrepareForChange(this); 27 root_->PrepareForChange(this);
30 } 28 }
31 29
32 RootNodeManager::ScopedChange::~ScopedChange() { 30 RootNodeManager::ScopedChange::~ScopedChange() {
33 root_->FinishChange(); 31 root_->FinishChange();
34 } 32 }
35 33
36 void RootNodeManager::ScopedChange::SendServerChangeIdAdvanced() {
37 root_->SendServerChangeIdAdvanced();
38 }
39
40 RootNodeManager::Context::Context() { 34 RootNodeManager::Context::Context() {
41 // Pass in false as native viewport creates the PlatformEventSource. 35 // Pass in false as native viewport creates the PlatformEventSource.
42 aura::Env::CreateInstance(false); 36 aura::Env::CreateInstance(false);
43 } 37 }
44 38
45 RootNodeManager::Context::~Context() { 39 RootNodeManager::Context::~Context() {
46 aura::Env::DeleteInstance(); 40 aura::Env::DeleteInstance();
47 } 41 }
48 42
49 RootNodeManager::RootNodeManager( 43 RootNodeManager::RootNodeManager(
50 ApplicationConnection* app_connection, 44 ApplicationConnection* app_connection,
51 RootViewManagerDelegate* view_manager_delegate, 45 RootViewManagerDelegate* view_manager_delegate,
52 const Callback<void()>& native_viewport_closed_callback) 46 const Callback<void()>& native_viewport_closed_callback)
53 : app_connection_(app_connection), 47 : app_connection_(app_connection),
54 next_connection_id_(1), 48 next_connection_id_(1),
55 next_server_change_id_(1),
56 root_view_manager_(app_connection, 49 root_view_manager_(app_connection,
57 this, 50 this,
58 view_manager_delegate, 51 view_manager_delegate,
59 native_viewport_closed_callback), 52 native_viewport_closed_callback),
60 root_(new Node(this, RootNodeId())), 53 root_(new Node(this, RootNodeId())),
61 current_change_(NULL) { 54 current_change_(NULL) {
62 } 55 }
63 56
64 RootNodeManager::~RootNodeManager() { 57 RootNodeManager::~RootNodeManager() {
65 aura::client::FocusClient* focus_client = 58 aura::client::FocusClient* focus_client =
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 IsChangeSource(i->first)); 170 IsChangeSource(i->first));
178 } 171 }
179 } 172 }
180 173
181 void RootNodeManager::ProcessNodeHierarchyChanged(const Node* node, 174 void RootNodeManager::ProcessNodeHierarchyChanged(const Node* node,
182 const Node* new_parent, 175 const Node* new_parent,
183 const Node* old_parent) { 176 const Node* old_parent) {
184 for (ConnectionMap::iterator i = connection_map_.begin(); 177 for (ConnectionMap::iterator i = connection_map_.begin();
185 i != connection_map_.end(); ++i) { 178 i != connection_map_.end(); ++i) {
186 i->second->ProcessNodeHierarchyChanged( 179 i->second->ProcessNodeHierarchyChanged(
187 node, new_parent, old_parent, next_server_change_id_, 180 node, new_parent, old_parent, IsChangeSource(i->first));
188 IsChangeSource(i->first));
189 } 181 }
190 } 182 }
191 183
192 void RootNodeManager::ProcessNodeReorder(const Node* node, 184 void RootNodeManager::ProcessNodeReorder(const Node* node,
193 const Node* relative_node, 185 const Node* relative_node,
194 const OrderDirection direction) { 186 const OrderDirection direction) {
195 for (ConnectionMap::iterator i = connection_map_.begin(); 187 for (ConnectionMap::iterator i = connection_map_.begin();
196 i != connection_map_.end(); ++i) { 188 i != connection_map_.end(); ++i) {
197 i->second->ProcessNodeReorder( 189 i->second->ProcessNodeReorder(
198 node, relative_node, direction, next_server_change_id_, 190 node, relative_node, direction, IsChangeSource(i->first));
199 IsChangeSource(i->first));
200 } 191 }
201 } 192 }
202 193
203 void RootNodeManager::ProcessNodeViewReplaced(const Node* node, 194 void RootNodeManager::ProcessNodeViewReplaced(const Node* node,
204 const View* new_view, 195 const View* new_view,
205 const View* old_view) { 196 const View* old_view) {
206 for (ConnectionMap::iterator i = connection_map_.begin(); 197 for (ConnectionMap::iterator i = connection_map_.begin();
207 i != connection_map_.end(); ++i) { 198 i != connection_map_.end(); ++i) {
208 i->second->ProcessNodeViewReplaced(node, new_view, old_view, 199 i->second->ProcessNodeViewReplaced(node, new_view, old_view,
209 IsChangeSource(i->first)); 200 IsChangeSource(i->first));
210 } 201 }
211 } 202 }
212 203
213 void RootNodeManager::ProcessNodeDeleted(const NodeId& node) { 204 void RootNodeManager::ProcessNodeDeleted(const NodeId& node) {
214 for (ConnectionMap::iterator i = connection_map_.begin(); 205 for (ConnectionMap::iterator i = connection_map_.begin();
215 i != connection_map_.end(); ++i) { 206 i != connection_map_.end(); ++i) {
216 i->second->ProcessNodeDeleted(node, next_server_change_id_, 207 i->second->ProcessNodeDeleted(node, IsChangeSource(i->first));
217 IsChangeSource(i->first));
218 } 208 }
219 } 209 }
220 210
221 void RootNodeManager::ProcessViewDeleted(const ViewId& view) { 211 void RootNodeManager::ProcessViewDeleted(const ViewId& view) {
222 for (ConnectionMap::iterator i = connection_map_.begin(); 212 for (ConnectionMap::iterator i = connection_map_.begin();
223 i != connection_map_.end(); ++i) { 213 i != connection_map_.end(); ++i) {
224 i->second->ProcessViewDeleted(view, IsChangeSource(i->first)); 214 i->second->ProcessViewDeleted(view, IsChangeSource(i->first));
225 } 215 }
226 } 216 }
227 217
(...skipping 10 matching lines...) Expand all
238 228
239 void RootNodeManager::PrepareForChange(ScopedChange* change) { 229 void RootNodeManager::PrepareForChange(ScopedChange* change) {
240 // Should only ever have one change in flight. 230 // Should only ever have one change in flight.
241 CHECK(!current_change_); 231 CHECK(!current_change_);
242 current_change_ = change; 232 current_change_ = change;
243 } 233 }
244 234
245 void RootNodeManager::FinishChange() { 235 void RootNodeManager::FinishChange() {
246 // PrepareForChange/FinishChange should be balanced. 236 // PrepareForChange/FinishChange should be balanced.
247 CHECK(current_change_); 237 CHECK(current_change_);
248 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
249 next_server_change_id_++;
250 current_change_ = NULL; 238 current_change_ = NULL;
251 } 239 }
252 240
253 void RootNodeManager::SendServerChangeIdAdvanced() {
254 CHECK(current_change_);
255 for (ConnectionMap::iterator i = connection_map_.begin();
256 i != connection_map_.end(); ++i) {
257 if (!DidConnectionMessageClient(i->first))
258 i->second->client()->OnServerChangeIdAdvanced(next_server_change_id_ + 1);
259 }
260 }
261
262 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( 241 ViewManagerServiceImpl* RootNodeManager::EmbedImpl(
263 const ConnectionSpecificId creator_id, 242 const ConnectionSpecificId creator_id,
264 const String& url, 243 const String& url,
265 const NodeId& root_id) { 244 const NodeId& root_id) {
266 MessagePipe pipe; 245 MessagePipe pipe;
267 246
268 ServiceProvider* service_provider = 247 ServiceProvider* service_provider =
269 app_connection_->ConnectToApplication(url)->GetServiceProvider(); 248 app_connection_->ConnectToApplication(url)->GetServiceProvider();
270 service_provider->ConnectToService( 249 service_provider->ConnectToService(
271 ViewManagerServiceImpl::Client::Name_, 250 ViewManagerServiceImpl::Client::Name_,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 291 }
313 292
314 void RootNodeManager::OnViewInputEvent(const View* view, 293 void RootNodeManager::OnViewInputEvent(const View* view,
315 const ui::Event* event) { 294 const ui::Event* event) {
316 DispatchViewInputEventToWindowManager(view, event); 295 DispatchViewInputEventToWindowManager(view, event);
317 } 296 }
318 297
319 } // namespace service 298 } // namespace service
320 } // namespace view_manager 299 } // namespace view_manager
321 } // namespace mojo 300 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.h ('k') | mojo/services/view_manager/test_change_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698