OLD | NEW |
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" | |
9 | 8 |
10 namespace mojo { | 9 namespace mojo { |
11 namespace services { | 10 namespace services { |
12 namespace view_manager { | 11 namespace view_manager { |
13 | 12 |
14 ViewManager::ViewManager(Shell* shell) | 13 ViewManager::ViewManager(Shell* shell) |
15 : shell_(shell) {} | 14 : shell_(shell) {} |
16 | 15 |
17 ViewManager::~ViewManager() { | 16 ViewManager::~ViewManager() {} |
18 while (!nodes_.empty()) { | |
19 IdToNodeMap::iterator it = nodes_.begin(); | |
20 if (synchronizer_->OwnsNode(it->second->id())) | |
21 it->second->Destroy(); | |
22 else | |
23 nodes_.erase(it); | |
24 } | |
25 } | |
26 | 17 |
27 void ViewManager::Init() { | 18 void ViewManager::Init() { |
28 synchronizer_.reset(new ViewManagerSynchronizer(this)); | 19 synchronizer_.reset(new ViewManagerSynchronizer(this)); |
29 } | 20 } |
30 | 21 |
31 ViewTreeNode* ViewManager::GetNodeById(TransportNodeId id) { | |
32 IdToNodeMap::const_iterator it = nodes_.find(id); | |
33 return it != nodes_.end() ? it->second : NULL; | |
34 } | |
35 | |
36 } // namespace view_manager | 22 } // namespace view_manager |
37 } // namespace services | 23 } // namespace services |
38 } // namespace mojo | 24 } // namespace mojo |
OLD | NEW |