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/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/services/view_manager/view_manager_connection.h" | 8 #include "mojo/services/view_manager/view_manager_connection.h" |
9 #include "ui/aura/env.h" | |
10 | 9 |
11 namespace mojo { | 10 namespace mojo { |
12 namespace services { | 11 namespace services { |
13 namespace view_manager { | 12 namespace view_manager { |
14 namespace { | 13 namespace { |
15 | 14 |
16 // Id for the root node. | 15 // Id for the root node. |
17 const TransportConnectionSpecificNodeId kRootId = 1; | 16 const TransportConnectionSpecificNodeId kRootId = 1; |
18 | 17 |
19 } // namespace | 18 } // namespace |
20 | 19 |
21 RootNodeManager::Context::Context() { | |
22 // Pass in false as native viewport creates the PlatformEventSource. | |
23 aura::Env::CreateInstance(false); | |
24 } | |
25 | |
26 RootNodeManager::Context::~Context() { | |
27 } | |
28 | |
29 RootNodeManager::ScopedChange::ScopedChange(ViewManagerConnection* connection, | 20 RootNodeManager::ScopedChange::ScopedChange(ViewManagerConnection* connection, |
30 RootNodeManager* root, | 21 RootNodeManager* root, |
31 TransportChangeId change_id) | 22 TransportChangeId change_id) |
32 : root_(root) { | 23 : root_(root) { |
33 root_->PrepareForChange(connection, change_id); | 24 root_->PrepareForChange(connection, change_id); |
34 } | 25 } |
35 | 26 |
36 RootNodeManager::ScopedChange::~ScopedChange() { | 27 RootNodeManager::ScopedChange::~ScopedChange() { |
37 root_->FinishChange(); | 28 root_->FinishChange(); |
38 } | 29 } |
39 | 30 |
40 RootNodeManager::RootNodeManager(Shell* shell) | 31 RootNodeManager::RootNodeManager() |
41 : next_connection_id_(1), | 32 : next_connection_id_(1), |
42 root_view_manager_(shell, this), | |
43 root_(this, NodeId(0, kRootId)) { | 33 root_(this, NodeId(0, kRootId)) { |
44 } | 34 } |
45 | 35 |
46 RootNodeManager::~RootNodeManager() { | 36 RootNodeManager::~RootNodeManager() { |
47 // All the connections should have been destroyed. | |
48 DCHECK(connection_map_.empty()); | |
49 } | 37 } |
50 | 38 |
51 TransportConnectionId RootNodeManager::GetAndAdvanceNextConnectionId() { | 39 TransportConnectionId RootNodeManager::GetAndAdvanceNextConnectionId() { |
52 const TransportConnectionId id = next_connection_id_++; | 40 const TransportConnectionId id = next_connection_id_++; |
53 DCHECK_LT(id, next_connection_id_); | 41 DCHECK_LT(id, next_connection_id_); |
54 return id; | 42 return id; |
55 } | 43 } |
56 | 44 |
57 void RootNodeManager::AddConnection(ViewManagerConnection* connection) { | 45 void RootNodeManager::AddConnection(ViewManagerConnection* connection) { |
58 DCHECK_EQ(0u, connection_map_.count(connection->id())); | 46 DCHECK_EQ(0u, connection_map_.count(connection->id())); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 TransportChangeId change_id) { | 100 TransportChangeId change_id) { |
113 DCHECK(!change_.get()); // Should only ever have one change in flight. | 101 DCHECK(!change_.get()); // Should only ever have one change in flight. |
114 change_.reset(new Change(connection->id(), change_id)); | 102 change_.reset(new Change(connection->id(), change_id)); |
115 } | 103 } |
116 | 104 |
117 void RootNodeManager::FinishChange() { | 105 void RootNodeManager::FinishChange() { |
118 DCHECK(change_.get()); // PrepareForChange/FinishChange should be balanced. | 106 DCHECK(change_.get()); // PrepareForChange/FinishChange should be balanced. |
119 change_.reset(); | 107 change_.reset(); |
120 } | 108 } |
121 | 109 |
| 110 void RootNodeManager::OnCreated() { |
| 111 } |
| 112 |
| 113 void RootNodeManager::OnDestroyed() { |
| 114 } |
| 115 |
| 116 void RootNodeManager::OnBoundsChanged(const Rect& bounds) { |
| 117 } |
| 118 |
| 119 void RootNodeManager::OnEvent(const Event& event, |
| 120 const mojo::Callback<void()>& callback) { |
| 121 callback.Run(); |
| 122 } |
| 123 |
122 void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node, | 124 void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node, |
123 const NodeId& new_parent, | 125 const NodeId& new_parent, |
124 const NodeId& old_parent) { | 126 const NodeId& old_parent) { |
125 if (!root_view_manager_.in_setup()) | 127 NotifyNodeHierarchyChanged(node, new_parent, old_parent); |
126 NotifyNodeHierarchyChanged(node, new_parent, old_parent); | |
127 } | 128 } |
128 | 129 |
129 void RootNodeManager::OnNodeViewReplaced(const NodeId& node, | 130 void RootNodeManager::OnNodeViewReplaced(const NodeId& node, |
130 const ViewId& new_view_id, | 131 const ViewId& new_view_id, |
131 const ViewId& old_view_id) { | 132 const ViewId& old_view_id) { |
132 NotifyNodeViewReplaced(node, new_view_id, old_view_id); | 133 NotifyNodeViewReplaced(node, new_view_id, old_view_id); |
133 } | 134 } |
134 | 135 |
135 } // namespace view_manager | 136 } // namespace view_manager |
136 } // namespace services | 137 } // namespace services |
137 } // namespace mojo | 138 } // namespace mojo |
OLD | NEW |