| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return &root_; | 83 return &root_; |
| 84 ConnectionMap::iterator i = connection_map_.find(id.connection_id); | 84 ConnectionMap::iterator i = connection_map_.find(id.connection_id); |
| 85 return i == connection_map_.end() ? NULL : i->second->GetNode(id); | 85 return i == connection_map_.end() ? NULL : i->second->GetNode(id); |
| 86 } | 86 } |
| 87 | 87 |
| 88 View* RootNodeManager::GetView(const ViewId& id) { | 88 View* RootNodeManager::GetView(const ViewId& id) { |
| 89 ConnectionMap::iterator i = connection_map_.find(id.connection_id); | 89 ConnectionMap::iterator i = connection_map_.find(id.connection_id); |
| 90 return i == connection_map_.end() ? NULL : i->second->GetView(id); | 90 return i == connection_map_.end() ? NULL : i->second->GetView(id); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void RootNodeManager::ProcessNodeHierarchyChanged(const NodeId& node, | 93 void RootNodeManager::ProcessNodeHierarchyChanged(const Node* node, |
| 94 const NodeId& new_parent, | 94 const Node* new_parent, |
| 95 const NodeId& old_parent) { | 95 const Node* old_parent) { |
| 96 // TODO(sky): make a macro for this. | |
| 97 for (ConnectionMap::iterator i = connection_map_.begin(); | 96 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 98 i != connection_map_.end(); ++i) { | 97 i != connection_map_.end(); ++i) { |
| 99 i->second->ProcessNodeHierarchyChanged( | 98 i->second->ProcessNodeHierarchyChanged( |
| 100 node, new_parent, old_parent, next_server_change_id_, | 99 node, new_parent, old_parent, next_server_change_id_, |
| 101 IsChangeSource(i->first)); | 100 IsChangeSource(i->first)); |
| 102 } | 101 } |
| 103 } | 102 } |
| 104 | 103 |
| 105 void RootNodeManager::ProcessNodeViewReplaced(const NodeId& node, | 104 void RootNodeManager::ProcessNodeViewReplaced(const Node* node, |
| 106 const ViewId& new_view_id, | 105 const View* new_view, |
| 107 const ViewId& old_view_id) { | 106 const View* old_view) { |
| 108 // TODO(sky): make a macro for this. | |
| 109 for (ConnectionMap::iterator i = connection_map_.begin(); | 107 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 110 i != connection_map_.end(); ++i) { | 108 i != connection_map_.end(); ++i) { |
| 111 i->second->ProcessNodeViewReplaced(node, new_view_id, old_view_id, | 109 i->second->ProcessNodeViewReplaced(node, new_view, old_view, |
| 112 IsChangeSource(i->first)); | 110 IsChangeSource(i->first)); |
| 113 } | 111 } |
| 114 } | 112 } |
| 115 | 113 |
| 116 void RootNodeManager::ProcessNodeDeleted(const NodeId& node) { | 114 void RootNodeManager::ProcessNodeDeleted(const NodeId& node) { |
| 117 // TODO(sky): make a macro for this. | |
| 118 for (ConnectionMap::iterator i = connection_map_.begin(); | 115 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 119 i != connection_map_.end(); ++i) { | 116 i != connection_map_.end(); ++i) { |
| 120 i->second->ProcessNodeDeleted(node, next_server_change_id_, | 117 i->second->ProcessNodeDeleted(node, next_server_change_id_, |
| 121 IsChangeSource(i->first)); | 118 IsChangeSource(i->first)); |
| 122 } | 119 } |
| 123 } | 120 } |
| 124 | 121 |
| 125 void RootNodeManager::ProcessViewDeleted(const ViewId& view) { | 122 void RootNodeManager::ProcessViewDeleted(const ViewId& view) { |
| 126 // TODO(sky): make a macro for this. | |
| 127 for (ConnectionMap::iterator i = connection_map_.begin(); | 123 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 128 i != connection_map_.end(); ++i) { | 124 i != connection_map_.end(); ++i) { |
| 129 i->second->ProcessViewDeleted(view, IsChangeSource(i->first)); | 125 i->second->ProcessViewDeleted(view, IsChangeSource(i->first)); |
| 130 } | 126 } |
| 131 } | 127 } |
| 132 | 128 |
| 133 void RootNodeManager::PrepareForChange(ViewManagerConnection* connection, | 129 void RootNodeManager::PrepareForChange(ViewManagerConnection* connection, |
| 134 bool is_delete_node) { | 130 bool is_delete_node) { |
| 135 // Should only ever have one change in flight. | 131 // Should only ever have one change in flight. |
| 136 DCHECK_EQ(kNoConnection, change_source_); | 132 DCHECK_EQ(kNoConnection, change_source_); |
| 137 change_source_ = connection->id(); | 133 change_source_ = connection->id(); |
| 138 is_processing_delete_node_ = is_delete_node; | 134 is_processing_delete_node_ = is_delete_node; |
| 139 } | 135 } |
| 140 | 136 |
| 141 void RootNodeManager::FinishChange(ChangeType change_type) { | 137 void RootNodeManager::FinishChange(ChangeType change_type) { |
| 142 // PrepareForChange/FinishChange should be balanced. | 138 // PrepareForChange/FinishChange should be balanced. |
| 143 DCHECK_NE(kNoConnection, change_source_); | 139 DCHECK_NE(kNoConnection, change_source_); |
| 144 change_source_ = 0; | 140 change_source_ = 0; |
| 145 is_processing_delete_node_ = false; | 141 is_processing_delete_node_ = false; |
| 146 if (change_type == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) | 142 if (change_type == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) |
| 147 next_server_change_id_++; | 143 next_server_change_id_++; |
| 148 } | 144 } |
| 149 | 145 |
| 150 void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node, | 146 void RootNodeManager::OnNodeHierarchyChanged(const Node* node, |
| 151 const NodeId& new_parent, | 147 const Node* new_parent, |
| 152 const NodeId& old_parent) { | 148 const Node* old_parent) { |
| 153 if (!root_view_manager_.in_setup()) | 149 if (!root_view_manager_.in_setup()) |
| 154 ProcessNodeHierarchyChanged(node, new_parent, old_parent); | 150 ProcessNodeHierarchyChanged(node, new_parent, old_parent); |
| 155 } | 151 } |
| 156 | 152 |
| 157 void RootNodeManager::OnNodeViewReplaced(const NodeId& node, | 153 void RootNodeManager::OnNodeViewReplaced(const Node* node, |
| 158 const ViewId& new_view_id, | 154 const View* new_view, |
| 159 const ViewId& old_view_id) { | 155 const View* old_view) { |
| 160 ProcessNodeViewReplaced(node, new_view_id, old_view_id); | 156 ProcessNodeViewReplaced(node, new_view, old_view); |
| 161 } | 157 } |
| 162 | 158 |
| 163 } // namespace service | 159 } // namespace service |
| 164 } // namespace view_manager | 160 } // namespace view_manager |
| 165 } // namespace mojo | 161 } // namespace mojo |
| OLD | NEW |