| Index: mojo/services/view_manager/root_node_manager.cc
|
| diff --git a/mojo/services/view_manager/root_node_manager.cc b/mojo/services/view_manager/root_node_manager.cc
|
| index 80a27f97dc89b9f8ee237e55f2169d9fec6610dc..9366d76b5ab48ce11aee1684c4d2ae2ed12cec0c 100644
|
| --- a/mojo/services/view_manager/root_node_manager.cc
|
| +++ b/mojo/services/view_manager/root_node_manager.cc
|
| @@ -24,10 +24,11 @@ const TransportConnectionId kNoConnection = 0;
|
| RootNodeManager::ScopedChange::ScopedChange(
|
| ViewManagerConnection* connection,
|
| RootNodeManager* root,
|
| - RootNodeManager::ChangeType change_type)
|
| + RootNodeManager::ChangeType change_type,
|
| + bool is_delete_node)
|
| : root_(root),
|
| change_type_(change_type) {
|
| - root_->PrepareForChange(connection);
|
| + root_->PrepareForChange(connection, is_delete_node);
|
| }
|
|
|
| RootNodeManager::ScopedChange::~ScopedChange() {
|
| @@ -46,6 +47,7 @@ RootNodeManager::RootNodeManager(Shell* shell)
|
| : next_connection_id_(1),
|
| next_server_change_id_(1),
|
| change_source_(kNoConnection),
|
| + is_processing_delete_node_(false),
|
| root_view_manager_(shell, this),
|
| root_(this, NodeId(0, kRootId)) {
|
| }
|
| @@ -88,79 +90,74 @@ View* RootNodeManager::GetView(const ViewId& id) {
|
| return i == connection_map_.end() ? NULL : i->second->GetView(id);
|
| }
|
|
|
| -void RootNodeManager::NotifyNodeHierarchyChanged(const NodeId& node,
|
| - const NodeId& new_parent,
|
| - const NodeId& old_parent) {
|
| +void RootNodeManager::ProcessNodeHierarchyChanged(const NodeId& node,
|
| + const NodeId& new_parent,
|
| + const NodeId& old_parent) {
|
| // TODO(sky): make a macro for this.
|
| for (ConnectionMap::iterator i = connection_map_.begin();
|
| i != connection_map_.end(); ++i) {
|
| - if (ShouldNotifyConnection(i->first)) {
|
| - i->second->NotifyNodeHierarchyChanged(
|
| - node, new_parent, old_parent, next_server_change_id_);
|
| - }
|
| + i->second->ProcessNodeHierarchyChanged(
|
| + node, new_parent, old_parent, next_server_change_id_,
|
| + IsChangeSource(i->first));
|
| }
|
| }
|
|
|
| -void RootNodeManager::NotifyNodeViewReplaced(const NodeId& node,
|
| - const ViewId& new_view_id,
|
| - const ViewId& old_view_id) {
|
| +void RootNodeManager::ProcessNodeViewReplaced(const NodeId& node,
|
| + const ViewId& new_view_id,
|
| + const ViewId& old_view_id) {
|
| // TODO(sky): make a macro for this.
|
| for (ConnectionMap::iterator i = connection_map_.begin();
|
| i != connection_map_.end(); ++i) {
|
| - if (ShouldNotifyConnection(i->first))
|
| - i->second->NotifyNodeViewReplaced(node, new_view_id, old_view_id);
|
| + i->second->ProcessNodeViewReplaced(node, new_view_id, old_view_id,
|
| + IsChangeSource(i->first));
|
| }
|
| }
|
|
|
| -void RootNodeManager::NotifyNodeDeleted(const NodeId& node) {
|
| +void RootNodeManager::ProcessNodeDeleted(const NodeId& node) {
|
| // TODO(sky): make a macro for this.
|
| for (ConnectionMap::iterator i = connection_map_.begin();
|
| i != connection_map_.end(); ++i) {
|
| - if (ShouldNotifyConnection(i->first))
|
| - i->second->NotifyNodeDeleted(node, next_server_change_id_);
|
| + i->second->ProcessNodeDeleted(node, next_server_change_id_,
|
| + IsChangeSource(i->first));
|
| }
|
| }
|
|
|
| -void RootNodeManager::NotifyViewDeleted(const ViewId& view) {
|
| +void RootNodeManager::ProcessViewDeleted(const ViewId& view) {
|
| // TODO(sky): make a macro for this.
|
| for (ConnectionMap::iterator i = connection_map_.begin();
|
| i != connection_map_.end(); ++i) {
|
| - if (ShouldNotifyConnection(i->first))
|
| - i->second->NotifyViewDeleted(view);
|
| + i->second->ProcessViewDeleted(view, IsChangeSource(i->first));
|
| }
|
| }
|
|
|
| -void RootNodeManager::PrepareForChange(ViewManagerConnection* connection) {
|
| +void RootNodeManager::PrepareForChange(ViewManagerConnection* connection,
|
| + bool is_delete_node) {
|
| // Should only ever have one change in flight.
|
| DCHECK_EQ(kNoConnection, change_source_);
|
| change_source_ = connection->id();
|
| + is_processing_delete_node_ = is_delete_node;
|
| }
|
|
|
| void RootNodeManager::FinishChange(ChangeType change_type) {
|
| // PrepareForChange/FinishChange should be balanced.
|
| DCHECK_NE(kNoConnection, change_source_);
|
| change_source_ = 0;
|
| + is_processing_delete_node_ = false;
|
| if (change_type == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
|
| next_server_change_id_++;
|
| }
|
|
|
| -bool RootNodeManager::ShouldNotifyConnection(
|
| - TransportConnectionId connection_id) const {
|
| - // Don't notify the source that originated the change.
|
| - return connection_id != change_source_;
|
| -}
|
| -
|
| void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node,
|
| const NodeId& new_parent,
|
| const NodeId& old_parent) {
|
| if (!root_view_manager_.in_setup())
|
| - NotifyNodeHierarchyChanged(node, new_parent, old_parent);
|
| + ProcessNodeHierarchyChanged(node, new_parent, old_parent);
|
| }
|
|
|
| void RootNodeManager::OnNodeViewReplaced(const NodeId& node,
|
| const ViewId& new_view_id,
|
| const ViewId& old_view_id) {
|
| - NotifyNodeViewReplaced(node, new_view_id, old_view_id);
|
| + ProcessNodeViewReplaced(node, new_view_id, old_view_id);
|
| }
|
|
|
| } // namespace service
|
|
|