Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: mojo/services/view_manager/root_node_manager.cc

Issue 277563006: Introduces another change id to hierarchy mutations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6517b326c99e4bd68b1d6cd81384f946ef34efea..77ebfcfc149670426fa0d091f1ec463deb2c1039 100644
--- a/mojo/services/view_manager/root_node_manager.cc
+++ b/mojo/services/view_manager/root_node_manager.cc
@@ -18,27 +18,31 @@ const TransportConnectionSpecificNodeId kRootId = 1;
} // namespace
-RootNodeManager::Context::Context() {
- // Pass in false as native viewport creates the PlatformEventSource.
- aura::Env::CreateInstance(false);
+RootNodeManager::ScopedChange::ScopedChange(
+ ViewManagerConnection* connection,
+ RootNodeManager* root,
+ TransportChangeId change_id,
+ RootNodeManager::ChangeType change_type)
+ : root_(root),
+ change_type_(change_type) {
+ root_->PrepareForChange(connection, change_id);
}
-RootNodeManager::Context::~Context() {
+RootNodeManager::ScopedChange::~ScopedChange() {
+ root_->FinishChange(change_type_);
}
-RootNodeManager::ScopedChange::ScopedChange(ViewManagerConnection* connection,
- RootNodeManager* root,
- TransportChangeId change_id)
- : root_(root) {
- root_->PrepareForChange(connection, change_id);
+RootNodeManager::Context::Context() {
+ // Pass in false as native viewport creates the PlatformEventSource.
+ aura::Env::CreateInstance(false);
}
-RootNodeManager::ScopedChange::~ScopedChange() {
- root_->FinishChange();
+RootNodeManager::Context::~Context() {
}
RootNodeManager::RootNodeManager(Shell* shell)
: next_connection_id_(1),
+ next_server_change_id_(1),
root_view_manager_(shell, this),
root_(this, NodeId(0, kRootId)) {
}
@@ -86,11 +90,9 @@ void RootNodeManager::NotifyNodeHierarchyChanged(const NodeId& node,
const NodeId& old_parent) {
for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) {
- const TransportChangeId change_id =
- (change_ && i->first == change_->connection_id) ?
- change_->change_id : 0;
i->second->NotifyNodeHierarchyChanged(
- node, new_parent, old_parent, change_id);
+ node, new_parent, old_parent, next_server_change_id_,
+ GetClientChangeId(i->first));
}
}
@@ -100,21 +102,17 @@ void RootNodeManager::NotifyNodeViewReplaced(const NodeId& node,
// TODO(sky): make a macro for this.
for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) {
- const TransportChangeId change_id =
- (change_ && i->first == change_->connection_id) ?
- change_->change_id : 0;
i->second->NotifyNodeViewReplaced(node, new_view_id, old_view_id,
- change_id);
+ GetClientChangeId(i->first));
}
}
void RootNodeManager::NotifyNodeDeleted(const NodeId& node) {
+ // TODO(sky): make a macro for this.
for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) {
- const TransportChangeId change_id =
- (change_ && i->first == change_->connection_id) ?
- change_->change_id : 0;
- i->second->NotifyNodeDeleted(node, change_id);
+ i->second->NotifyNodeDeleted(node, next_server_change_id_,
+ GetClientChangeId(i->first));
}
}
@@ -124,9 +122,17 @@ void RootNodeManager::PrepareForChange(ViewManagerConnection* connection,
change_.reset(new Change(connection->id(), change_id));
}
-void RootNodeManager::FinishChange() {
+void RootNodeManager::FinishChange(ChangeType change_type) {
DCHECK(change_.get()); // PrepareForChange/FinishChange should be balanced.
change_.reset();
+ if (change_type == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
+ next_server_change_id_++;
+}
+
+TransportChangeId RootNodeManager::GetClientChangeId(
+ TransportConnectionId connection_id) const {
+ return (change_ && connection_id == change_->connection_id) ?
+ change_->client_change_id : 0;
}
void RootNodeManager::OnNodeHierarchyChanged(const NodeId& node,
« no previous file with comments | « mojo/services/view_manager/root_node_manager.h ('k') | mojo/services/view_manager/view_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698