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

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager.cc

Issue 272833002: View synchronization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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/public/cpp/view_manager/view_manager.h" 5 #include "mojo/services/public/cpp/view_manager/view_manager.h"
6 6
7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" 7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
8 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" 8 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h"
9 #include "mojo/services/public/cpp/view_manager/view.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 namespace services { 12 namespace services {
12 namespace view_manager { 13 namespace view_manager {
13 14
14 ViewManager::ViewManager(Shell* shell) 15 ViewManager::ViewManager(Shell* shell)
15 : shell_(shell) {} 16 : shell_(shell) {}
16 17
17 ViewManager::~ViewManager() { 18 ViewManager::~ViewManager() {
18 while (!nodes_.empty()) { 19 while (!nodes_.empty()) {
19 IdToNodeMap::iterator it = nodes_.begin(); 20 IdToNodeMap::iterator it = nodes_.begin();
20 if (synchronizer_->OwnsNode(it->second->id())) 21 if (synchronizer_->OwnsNode(it->second->id()))
21 it->second->Destroy(); 22 it->second->Destroy();
22 else 23 else
23 nodes_.erase(it); 24 nodes_.erase(it);
24 } 25 }
26 while (!views_.empty()) {
27 IdToViewMap::iterator it = views_.begin();
28 if (synchronizer_->OwnsView(it->second->id()))
29 it->second->Destroy();
30 else
31 views_.erase(it);
32 }
25 } 33 }
26 34
27 void ViewManager::Init() { 35 void ViewManager::Init() {
28 synchronizer_.reset(new ViewManagerSynchronizer(this)); 36 synchronizer_.reset(new ViewManagerSynchronizer(this));
29 } 37 }
30 38
31 ViewTreeNode* ViewManager::GetNodeById(TransportNodeId id) { 39 ViewTreeNode* ViewManager::GetNodeById(TransportNodeId id) {
32 IdToNodeMap::const_iterator it = nodes_.find(id); 40 IdToNodeMap::const_iterator it = nodes_.find(id);
33 return it != nodes_.end() ? it->second : NULL; 41 return it != nodes_.end() ? it->second : NULL;
34 } 42 }
35 43
44 View* ViewManager::GetViewById(TransportViewId id) {
45 IdToViewMap::const_iterator it = views_.find(id);
46 return it != views_.end() ? it->second : NULL;
47 }
48
36 } // namespace view_manager 49 } // namespace view_manager
37 } // namespace services 50 } // namespace services
38 } // namespace mojo 51 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/public/cpp/view_manager/lib/view.cc ('k') | mojo/services/public/cpp/view_manager/lib/view_manager_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698