| 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" | 9 #include "ui/aura/env.h" |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 i != connection_map_.end(); ++i) { | 102 i != connection_map_.end(); ++i) { |
| 103 const TransportChangeId change_id = | 103 const TransportChangeId change_id = |
| 104 (change_ && i->first == change_->connection_id) ? | 104 (change_ && i->first == change_->connection_id) ? |
| 105 change_->change_id : 0; | 105 change_->change_id : 0; |
| 106 i->second->NotifyNodeViewReplaced(node, new_view_id, old_view_id, | 106 i->second->NotifyNodeViewReplaced(node, new_view_id, old_view_id, |
| 107 change_id); | 107 change_id); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 void RootNodeManager::NotifyNodeDeleted(const NodeId& node) { | 111 void RootNodeManager::NotifyNodeDeleted(const NodeId& node) { |
| 112 // TODO(sky): make a macro for this. |
| 112 for (ConnectionMap::iterator i = connection_map_.begin(); | 113 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 113 i != connection_map_.end(); ++i) { | 114 i != connection_map_.end(); ++i) { |
| 114 const TransportChangeId change_id = | 115 const TransportChangeId change_id = |
| 115 (change_ && i->first == change_->connection_id) ? | 116 (change_ && i->first == change_->connection_id) ? |
| 116 change_->change_id : 0; | 117 change_->change_id : 0; |
| 117 i->second->NotifyNodeDeleted(node, change_id); | 118 i->second->NotifyNodeDeleted(node, change_id); |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 122 void RootNodeManager::NotifyViewDeleted(const ViewId& view) { |
| 123 // TODO(sky): make a macro for this. |
| 124 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 125 i != connection_map_.end(); ++i) { |
| 126 const TransportChangeId change_id = |
| 127 (change_ && i->first == change_->connection_id) ? |
| 128 change_->change_id : 0; |
| 129 i->second->NotifyViewDeleted(view, change_id); |
| 130 } |
| 131 } |
| 132 |
| 121 void RootNodeManager::PrepareForChange(ViewManagerConnection* connection, | 133 void RootNodeManager::PrepareForChange(ViewManagerConnection* connection, |
| 122 TransportChangeId change_id) { | 134 TransportChangeId change_id) { |
| 123 DCHECK(!change_.get()); // Should only ever have one change in flight. | 135 DCHECK(!change_.get()); // Should only ever have one change in flight. |
| 124 change_.reset(new Change(connection->id(), change_id)); | 136 change_.reset(new Change(connection->id(), change_id)); |
| 125 } | 137 } |
| 126 | 138 |
| 127 void RootNodeManager::FinishChange() { | 139 void RootNodeManager::FinishChange() { |
| 128 DCHECK(change_.get()); // PrepareForChange/FinishChange should be balanced. | 140 DCHECK(change_.get()); // PrepareForChange/FinishChange should be balanced. |
| 129 change_.reset(); | 141 change_.reset(); |
| 130 } | 142 } |
| 131 | 143 |
| 132 void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node, | 144 void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node, |
| 133 const NodeId& new_parent, | 145 const NodeId& new_parent, |
| 134 const NodeId& old_parent) { | 146 const NodeId& old_parent) { |
| 135 if (!root_view_manager_.in_setup()) | 147 if (!root_view_manager_.in_setup()) |
| 136 NotifyNodeHierarchyChanged(node, new_parent, old_parent); | 148 NotifyNodeHierarchyChanged(node, new_parent, old_parent); |
| 137 } | 149 } |
| 138 | 150 |
| 139 void RootNodeManager::OnNodeViewReplaced(const NodeId& node, | 151 void RootNodeManager::OnNodeViewReplaced(const NodeId& node, |
| 140 const ViewId& new_view_id, | 152 const ViewId& new_view_id, |
| 141 const ViewId& old_view_id) { | 153 const ViewId& old_view_id) { |
| 142 NotifyNodeViewReplaced(node, new_view_id, old_view_id); | 154 NotifyNodeViewReplaced(node, new_view_id, old_view_id); |
| 143 } | 155 } |
| 144 | 156 |
| 145 } // namespace view_manager | 157 } // namespace view_manager |
| 146 } // namespace services | 158 } // namespace services |
| 147 } // namespace mojo | 159 } // namespace mojo |
| OLD | NEW |