Commit c7854141 authored by sky@chromium.org's avatar sky@chromium.org

Nukes change_ids from view manager

change_ids are more trouble then they are worth. I'm going to try
something else for resolving conflicts.

BUG=389339
TEST=covered by tests
R=ben@chromium.org

Review URL: https://codereview.chromium.org/397263004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283830 0039d316-1c4b-4281-b951-d872f2087c98
parent 925eb503
...@@ -133,10 +133,6 @@ class ViewManagerTransaction { ...@@ -133,10 +133,6 @@ class ViewManagerTransaction {
ViewManagerService* service() { return client_->service_; } ViewManagerService* service() { return client_->service_; }
Id GetAndAdvanceNextServerChangeId() {
return client_->next_server_change_id_++;
}
// TODO(sky): nuke this and covert all to new one, then rename // TODO(sky): nuke this and covert all to new one, then rename
// ActionCompletedCallbackWithErrorCode to ActionCompletedCallback. // ActionCompletedCallbackWithErrorCode to ActionCompletedCallback.
base::Callback<void(bool)> ActionCompletedCallback() { base::Callback<void(bool)> ActionCompletedCallback() {
...@@ -246,9 +242,7 @@ class DestroyNodeTransaction : public ViewManagerTransaction { ...@@ -246,9 +242,7 @@ class DestroyNodeTransaction : public ViewManagerTransaction {
private: private:
// Overridden from ViewManagerTransaction: // Overridden from ViewManagerTransaction:
virtual void DoCommit() OVERRIDE { virtual void DoCommit() OVERRIDE {
service()->DeleteNode(node_id_, service()->DeleteNode(node_id_, ActionCompletedCallback());
GetAndAdvanceNextServerChangeId(),
ActionCompletedCallback());
} }
virtual void DoActionCompleted(bool success) OVERRIDE { virtual void DoActionCompleted(bool success) OVERRIDE {
// TODO(beng): recovery? // TODO(beng): recovery?
...@@ -272,10 +266,7 @@ class AddChildTransaction : public ViewManagerTransaction { ...@@ -272,10 +266,7 @@ class AddChildTransaction : public ViewManagerTransaction {
private: private:
// Overridden from ViewManagerTransaction: // Overridden from ViewManagerTransaction:
virtual void DoCommit() OVERRIDE { virtual void DoCommit() OVERRIDE {
service()->AddNode(parent_id_, service()->AddNode(parent_id_, child_id_, ActionCompletedCallback());
child_id_,
GetAndAdvanceNextServerChangeId(),
ActionCompletedCallback());
} }
virtual void DoActionCompleted(bool success) OVERRIDE { virtual void DoActionCompleted(bool success) OVERRIDE {
...@@ -299,10 +290,7 @@ class RemoveChildTransaction : public ViewManagerTransaction { ...@@ -299,10 +290,7 @@ class RemoveChildTransaction : public ViewManagerTransaction {
private: private:
// Overridden from ViewManagerTransaction: // Overridden from ViewManagerTransaction:
virtual void DoCommit() OVERRIDE { virtual void DoCommit() OVERRIDE {
service()->RemoveNodeFromParent( service()->RemoveNodeFromParent(child_id_, ActionCompletedCallback());
child_id_,
GetAndAdvanceNextServerChangeId(),
ActionCompletedCallback());
} }
virtual void DoActionCompleted(bool success) OVERRIDE { virtual void DoActionCompleted(bool success) OVERRIDE {
...@@ -333,7 +321,6 @@ class ReorderNodeTransaction : public ViewManagerTransaction { ...@@ -333,7 +321,6 @@ class ReorderNodeTransaction : public ViewManagerTransaction {
service()->ReorderNode(node_id_, service()->ReorderNode(node_id_,
relative_id_, relative_id_,
direction_, direction_,
GetAndAdvanceNextServerChangeId(),
ActionCompletedCallback()); ActionCompletedCallback());
} }
...@@ -478,7 +465,6 @@ class EmbedTransaction : public ViewManagerTransaction { ...@@ -478,7 +465,6 @@ class EmbedTransaction : public ViewManagerTransaction {
private: private:
// Overridden from ViewManagerTransaction: // Overridden from ViewManagerTransaction:
virtual void DoCommit() OVERRIDE { virtual void DoCommit() OVERRIDE {
GetAndAdvanceNextServerChangeId();
service()->Embed(url_, node_id_, ActionCompletedCallback()); service()->Embed(url_, node_id_, ActionCompletedCallback());
} }
virtual void DoActionCompleted(bool success) OVERRIDE { virtual void DoActionCompleted(bool success) OVERRIDE {
...@@ -542,7 +528,6 @@ ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection, ...@@ -542,7 +528,6 @@ ViewManagerClientImpl::ViewManagerClientImpl(ApplicationConnection* connection,
: connected_(false), : connected_(false),
connection_id_(0), connection_id_(0),
next_id_(1), next_id_(1),
next_server_change_id_(0),
delegate_(delegate), delegate_(delegate),
dispatcher_(NULL) {} dispatcher_(NULL) {}
...@@ -733,12 +718,10 @@ void ViewManagerClientImpl::OnConnectionEstablished() { ...@@ -733,12 +718,10 @@ void ViewManagerClientImpl::OnConnectionEstablished() {
void ViewManagerClientImpl::OnViewManagerConnectionEstablished( void ViewManagerClientImpl::OnViewManagerConnectionEstablished(
ConnectionSpecificId connection_id, ConnectionSpecificId connection_id,
const String& creator_url, const String& creator_url,
Id next_server_change_id,
Array<NodeDataPtr> nodes) { Array<NodeDataPtr> nodes) {
connected_ = true; connected_ = true;
connection_id_ = connection_id; connection_id_ = connection_id;
creator_url_ = TypeConverter<String, std::string>::ConvertFrom(creator_url); creator_url_ = TypeConverter<String, std::string>::ConvertFrom(creator_url);
next_server_change_id_ = next_server_change_id;
DCHECK(pending_transactions_.empty()); DCHECK(pending_transactions_.empty());
AddRoot(BuildNodeTree(this, nodes)); AddRoot(BuildNodeTree(this, nodes));
...@@ -748,11 +731,6 @@ void ViewManagerClientImpl::OnRootAdded(Array<NodeDataPtr> nodes) { ...@@ -748,11 +731,6 @@ void ViewManagerClientImpl::OnRootAdded(Array<NodeDataPtr> nodes) {
AddRoot(BuildNodeTree(this, nodes)); AddRoot(BuildNodeTree(this, nodes));
} }
void ViewManagerClientImpl::OnServerChangeIdAdvanced(
Id next_server_change_id) {
next_server_change_id_ = next_server_change_id;
}
void ViewManagerClientImpl::OnNodeBoundsChanged(Id node_id, void ViewManagerClientImpl::OnNodeBoundsChanged(Id node_id,
RectPtr old_bounds, RectPtr old_bounds,
RectPtr new_bounds) { RectPtr new_bounds) {
...@@ -765,10 +743,7 @@ void ViewManagerClientImpl::OnNodeHierarchyChanged( ...@@ -765,10 +743,7 @@ void ViewManagerClientImpl::OnNodeHierarchyChanged(
Id node_id, Id node_id,
Id new_parent_id, Id new_parent_id,
Id old_parent_id, Id old_parent_id,
Id server_change_id,
mojo::Array<NodeDataPtr> nodes) { mojo::Array<NodeDataPtr> nodes) {
next_server_change_id_ = server_change_id + 1;
BuildNodeTree(this, nodes); BuildNodeTree(this, nodes);
Node* new_parent = GetNodeById(new_parent_id); Node* new_parent = GetNodeById(new_parent_id);
...@@ -782,20 +757,14 @@ void ViewManagerClientImpl::OnNodeHierarchyChanged( ...@@ -782,20 +757,14 @@ void ViewManagerClientImpl::OnNodeHierarchyChanged(
void ViewManagerClientImpl::OnNodeReordered(Id node_id, void ViewManagerClientImpl::OnNodeReordered(Id node_id,
Id relative_node_id, Id relative_node_id,
OrderDirection direction, OrderDirection direction) {
Id server_change_id) {
next_server_change_id_ = server_change_id + 1;
Node* node = GetNodeById(node_id); Node* node = GetNodeById(node_id);
Node* relative_node = GetNodeById(relative_node_id); Node* relative_node = GetNodeById(relative_node_id);
if (node && relative_node) { if (node && relative_node)
NodePrivate(node).LocalReorder(relative_node, direction); NodePrivate(node).LocalReorder(relative_node, direction);
}
} }
void ViewManagerClientImpl::OnNodeDeleted(Id node_id, Id server_change_id) { void ViewManagerClientImpl::OnNodeDeleted(Id node_id) {
next_server_change_id_ = server_change_id + 1;
Node* node = GetNodeById(node_id); Node* node = GetNodeById(node_id);
if (node) if (node)
NodePrivate(node).LocalDestroy(); NodePrivate(node).LocalDestroy();
......
...@@ -102,23 +102,19 @@ class ViewManagerClientImpl : public ViewManager, ...@@ -102,23 +102,19 @@ class ViewManagerClientImpl : public ViewManager,
virtual void OnViewManagerConnectionEstablished( virtual void OnViewManagerConnectionEstablished(
ConnectionSpecificId connection_id, ConnectionSpecificId connection_id,
const String& creator_url, const String& creator_url,
Id next_server_change_id,
Array<NodeDataPtr> nodes) OVERRIDE; Array<NodeDataPtr> nodes) OVERRIDE;
virtual void OnRootAdded(Array<NodeDataPtr> nodes) OVERRIDE; virtual void OnRootAdded(Array<NodeDataPtr> nodes) OVERRIDE;
virtual void OnServerChangeIdAdvanced(Id next_server_change_id) OVERRIDE;
virtual void OnNodeBoundsChanged(Id node_id, virtual void OnNodeBoundsChanged(Id node_id,
RectPtr old_bounds, RectPtr old_bounds,
RectPtr new_bounds) OVERRIDE; RectPtr new_bounds) OVERRIDE;
virtual void OnNodeHierarchyChanged(Id node_id, virtual void OnNodeHierarchyChanged(Id node_id,
Id new_parent_id, Id new_parent_id,
Id old_parent_id, Id old_parent_id,
Id server_change_id,
Array<NodeDataPtr> nodes) OVERRIDE; Array<NodeDataPtr> nodes) OVERRIDE;
virtual void OnNodeReordered(Id node_id, virtual void OnNodeReordered(Id node_id,
Id relative_node_id, Id relative_node_id,
OrderDirection direction, OrderDirection direction) OVERRIDE;
Id server_change_id) OVERRIDE; virtual void OnNodeDeleted(Id node_id) OVERRIDE;
virtual void OnNodeDeleted(Id node_id, Id server_change_id) OVERRIDE;
virtual void OnNodeViewReplaced(Id node, virtual void OnNodeViewReplaced(Id node,
Id new_view_id, Id new_view_id,
Id old_view_id) OVERRIDE; Id old_view_id) OVERRIDE;
...@@ -143,7 +139,6 @@ class ViewManagerClientImpl : public ViewManager, ...@@ -143,7 +139,6 @@ class ViewManagerClientImpl : public ViewManager,
bool connected_; bool connected_;
ConnectionSpecificId connection_id_; ConnectionSpecificId connection_id_;
ConnectionSpecificId next_id_; ConnectionSpecificId next_id_;
Id next_server_change_id_;
std::string creator_url_; std::string creator_url_;
......
...@@ -20,7 +20,6 @@ enum ErrorCode { ...@@ -20,7 +20,6 @@ enum ErrorCode {
NONE, NONE,
VALUE_IN_USE, VALUE_IN_USE,
ILLEGAL_ARGUMENT, ILLEGAL_ARGUMENT,
UNEXPECTED_CHANGE_ID,
}; };
// ViewManagerInitService is responsible for launching the client that controls // ViewManagerInitService is responsible for launching the client that controls
...@@ -30,12 +29,6 @@ interface ViewManagerInitService { ...@@ -30,12 +29,6 @@ interface ViewManagerInitService {
EmbedRoot(string url) => (bool success); EmbedRoot(string url) => (bool success);
}; };
// Functions that mutate the hierarchy take a change id. This is an ever
// increasing integer used to identify the change. Every hierarchy change
// increases this value. The server only accepts changes where the supplied
// |server_change_id| matches the expected next value. This ensures changes are
// made in a well defined order.
//
// Nodes and Views are identified by a uint32. The upper 16 bits are the // Nodes and Views are identified by a uint32. The upper 16 bits are the
// connection id, and the lower 16 the id assigned by the client. // connection id, and the lower 16 the id assigned by the client.
// //
...@@ -55,7 +48,7 @@ interface ViewManagerService { ...@@ -55,7 +48,7 @@ interface ViewManagerService {
// Deletes a node. This does not recurse. No hierarchy change notifications // Deletes a node. This does not recurse. No hierarchy change notifications
// are sent as a result of this. Only the connection that created the node can // are sent as a result of this. Only the connection that created the node can
// delete it. // delete it.
DeleteNode(uint32 node_id, uint32 change_id) => (bool success); DeleteNode(uint32 node_id) => (bool success);
// Sets the specified bounds of the specified node. // Sets the specified bounds of the specified node.
SetNodeBounds(uint32 node_id, mojo.Rect bounds) => (bool success); SetNodeBounds(uint32 node_id, mojo.Rect bounds) => (bool success);
...@@ -65,30 +58,25 @@ interface ViewManagerService { ...@@ -65,30 +58,25 @@ interface ViewManagerService {
// any of their roots. // any of their roots.
SetNodeVisibility(uint32 node_id, bool visible) => (bool success); SetNodeVisibility(uint32 node_id, bool visible) => (bool success);
// Reparents a node. See description above class for details of |change_id|. // Reparents a node.
// This fails for any of the following reasons: // This fails for any of the following reasons:
// . |server_change_id| is not the expected id.
// . |parent| or |child| does not identify a valid node. // . |parent| or |child| does not identify a valid node.
// . |child| is an ancestor of |parent|. // . |child| is an ancestor of |parent|.
// . |child| is already a child of |parent|. // . |child| is already a child of |parent|.
// //
// This may result in a connection getting OnNodeDeleted(). See // This may result in a connection getting OnNodeDeleted(). See
// RemoveNodeFromParent for details. // RemoveNodeFromParent for details.
AddNode(uint32 parent, AddNode(uint32 parent, uint32 child) => (bool success);
uint32 child,
uint32 server_change_id) => (bool success);
// Removes a view from its current parent. See description above class for // Removes a view from its current parent. This fails if the node is not
// details of |change_id|. This fails if the node is not valid, // valid, |server_change_id| doesn't match, or the node already has no parent.
// |server_change_id| doesn't match, or the node already has no parent.
// //
// Removing a node from a parent may result in OnNodeDeleted() being sent to // Removing a node from a parent may result in OnNodeDeleted() being sent to
// other connections. For example, connection A has nodes 1 and 2, with 2 a // other connections. For example, connection A has nodes 1 and 2, with 2 a
// child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
// OnNodeDeleted(). This is done as node 2 is effectively no longer visible to // OnNodeDeleted(). This is done as node 2 is effectively no longer visible to
// connection B. // connection B.
RemoveNodeFromParent(uint32 node_id, RemoveNodeFromParent(uint32 node_id) => (bool success);
uint32 server_change_id) => (bool success);
// Reorders a node in its parent, relative to |relative_node_id| according to // Reorders a node in its parent, relative to |relative_node_id| according to
// |direction|. // |direction|.
...@@ -96,8 +84,7 @@ interface ViewManagerService { ...@@ -96,8 +84,7 @@ interface ViewManagerService {
// children. // children.
ReorderNode(uint32 node_id, ReorderNode(uint32 node_id,
uint32 relative_node_id, uint32 relative_node_id,
OrderDirection direction, OrderDirection direction) => (bool success);
uint32 server_change_id) => (bool success);
// Returns the nodes comprising the tree starting at |node_id|. |node_id| is // Returns the nodes comprising the tree starting at |node_id|. |node_id| is
// the first result in the return value, unless |node_id| is invalid, in which // the first result in the return value, unless |node_id| is invalid, in which
...@@ -155,26 +142,16 @@ interface ViewManagerService { ...@@ -155,26 +142,16 @@ interface ViewManagerService {
[Client=ViewManagerService] [Client=ViewManagerService]
interface ViewManagerClient { interface ViewManagerClient {
// Invoked once the connection has been established. |connection_id| is the id // Invoked once the connection has been established. |connection_id| is the id
// that uniquely identifies this connection. |next_server_change_id| is the // that uniquely identifies this connection. |nodes| are the nodes parented to
// id of the next change the server is expecting. |nodes| are the nodes // the root.
// parented to the root.
OnViewManagerConnectionEstablished(uint16 connection_id, OnViewManagerConnectionEstablished(uint16 connection_id,
string creator_url, string creator_url,
uint32 next_server_change_id,
NodeData[] nodes); NodeData[] nodes);
// See description of ViewManagerService::Embed() for details as to when // See description of ViewManagerService::Embed() for details as to when
// this is invoked. // this is invoked.
OnRootAdded(NodeData[] nodes); OnRootAdded(NodeData[] nodes);
// This is sent to clients when a change is made to the server that results
// in the |server_change_id| changing but the client isn't notified. This is
// not sent if the client receives a callback giving a new
// |server_change_id|. For example, if a client 1 changes the hierarchy in
// some way but client 2 isn't notified of the change, then client 2 gets
// OnServerChangeIdAdvanced().
OnServerChangeIdAdvanced(uint32 next_server_change_id);
// Invoked when a node's bounds have changed. // Invoked when a node's bounds have changed.
OnNodeBoundsChanged(uint32 node, mojo.Rect old_bounds, mojo.Rect new_bounds); OnNodeBoundsChanged(uint32 node, mojo.Rect old_bounds, mojo.Rect new_bounds);
...@@ -187,17 +164,15 @@ interface ViewManagerClient { ...@@ -187,17 +164,15 @@ interface ViewManagerClient {
OnNodeHierarchyChanged(uint32 node, OnNodeHierarchyChanged(uint32 node,
uint32 new_parent, uint32 new_parent,
uint32 old_parent, uint32 old_parent,
uint32 server_change_id,
NodeData[] nodes); NodeData[] nodes);
// Invoked when the order of nodes within a parent changes. // Invoked when the order of nodes within a parent changes.
OnNodeReordered(uint32 node_id, OnNodeReordered(uint32 node_id,
uint32 relative_node_id, uint32 relative_node_id,
OrderDirection direction, OrderDirection direction);
uint32 server_change_id);
// Invoked when a node is deleted. // Invoked when a node is deleted.
OnNodeDeleted(uint32 node, uint32 server_change_id); OnNodeDeleted(uint32 node);
// Invoked when the view associated with a node is replaced by another view. // Invoked when the view associated with a node is replaced by another view.
// 0 is used to identify a null view. // 0 is used to identify a null view.
......
...@@ -20,11 +20,9 @@ namespace service { ...@@ -20,11 +20,9 @@ namespace service {
RootNodeManager::ScopedChange::ScopedChange( RootNodeManager::ScopedChange::ScopedChange(
ViewManagerServiceImpl* connection, ViewManagerServiceImpl* connection,
RootNodeManager* root, RootNodeManager* root,
RootNodeManager::ChangeType change_type,
bool is_delete_node) bool is_delete_node)
: root_(root), : root_(root),
connection_id_(connection->id()), connection_id_(connection->id()),
change_type_(change_type),
is_delete_node_(is_delete_node) { is_delete_node_(is_delete_node) {
root_->PrepareForChange(this); root_->PrepareForChange(this);
} }
...@@ -33,10 +31,6 @@ RootNodeManager::ScopedChange::~ScopedChange() { ...@@ -33,10 +31,6 @@ RootNodeManager::ScopedChange::~ScopedChange() {
root_->FinishChange(); root_->FinishChange();
} }
void RootNodeManager::ScopedChange::SendServerChangeIdAdvanced() {
root_->SendServerChangeIdAdvanced();
}
RootNodeManager::Context::Context() { RootNodeManager::Context::Context() {
// Pass in false as native viewport creates the PlatformEventSource. // Pass in false as native viewport creates the PlatformEventSource.
aura::Env::CreateInstance(false); aura::Env::CreateInstance(false);
...@@ -52,7 +46,6 @@ RootNodeManager::RootNodeManager( ...@@ -52,7 +46,6 @@ RootNodeManager::RootNodeManager(
const Callback<void()>& native_viewport_closed_callback) const Callback<void()>& native_viewport_closed_callback)
: app_connection_(app_connection), : app_connection_(app_connection),
next_connection_id_(1), next_connection_id_(1),
next_server_change_id_(1),
root_view_manager_(app_connection, root_view_manager_(app_connection,
this, this,
view_manager_delegate, view_manager_delegate,
...@@ -184,8 +177,7 @@ void RootNodeManager::ProcessNodeHierarchyChanged(const Node* node, ...@@ -184,8 +177,7 @@ void RootNodeManager::ProcessNodeHierarchyChanged(const Node* node,
for (ConnectionMap::iterator i = connection_map_.begin(); for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) { i != connection_map_.end(); ++i) {
i->second->ProcessNodeHierarchyChanged( i->second->ProcessNodeHierarchyChanged(
node, new_parent, old_parent, next_server_change_id_, node, new_parent, old_parent, IsChangeSource(i->first));
IsChangeSource(i->first));
} }
} }
...@@ -195,8 +187,7 @@ void RootNodeManager::ProcessNodeReorder(const Node* node, ...@@ -195,8 +187,7 @@ void RootNodeManager::ProcessNodeReorder(const Node* node,
for (ConnectionMap::iterator i = connection_map_.begin(); for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) { i != connection_map_.end(); ++i) {
i->second->ProcessNodeReorder( i->second->ProcessNodeReorder(
node, relative_node, direction, next_server_change_id_, node, relative_node, direction, IsChangeSource(i->first));
IsChangeSource(i->first));
} }
} }
...@@ -213,8 +204,7 @@ void RootNodeManager::ProcessNodeViewReplaced(const Node* node, ...@@ -213,8 +204,7 @@ void RootNodeManager::ProcessNodeViewReplaced(const Node* node,
void RootNodeManager::ProcessNodeDeleted(const NodeId& node) { void RootNodeManager::ProcessNodeDeleted(const NodeId& node) {
for (ConnectionMap::iterator i = connection_map_.begin(); for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) { i != connection_map_.end(); ++i) {
i->second->ProcessNodeDeleted(node, next_server_change_id_, i->second->ProcessNodeDeleted(node, IsChangeSource(i->first));
IsChangeSource(i->first));
} }
} }
...@@ -245,20 +235,9 @@ void RootNodeManager::PrepareForChange(ScopedChange* change) { ...@@ -245,20 +235,9 @@ void RootNodeManager::PrepareForChange(ScopedChange* change) {
void RootNodeManager::FinishChange() { void RootNodeManager::FinishChange() {
// PrepareForChange/FinishChange should be balanced. // PrepareForChange/FinishChange should be balanced.
CHECK(current_change_); CHECK(current_change_);
if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
next_server_change_id_++;
current_change_ = NULL; current_change_ = NULL;
} }
void RootNodeManager::SendServerChangeIdAdvanced() {
CHECK(current_change_);
for (ConnectionMap::iterator i = connection_map_.begin();
i != connection_map_.end(); ++i) {
if (!DidConnectionMessageClient(i->first))
i->second->client()->OnServerChangeIdAdvanced(next_server_change_id_ + 1);
}
}
ViewManagerServiceImpl* RootNodeManager::EmbedImpl( ViewManagerServiceImpl* RootNodeManager::EmbedImpl(
const ConnectionSpecificId creator_id, const ConnectionSpecificId creator_id,
const String& url, const String& url,
......
...@@ -38,25 +38,16 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager ...@@ -38,25 +38,16 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager
: public NodeDelegate, : public NodeDelegate,
public aura::client::FocusChangeObserver { public aura::client::FocusChangeObserver {
public: public:
// Used to indicate if the server id should be incremented after notifiying
// clients of the change.
enum ChangeType {
CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID,
CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID,
};
// Create when a ViewManagerServiceImpl is about to make a change. Ensures // Create when a ViewManagerServiceImpl is about to make a change. Ensures
// clients are notified of the correct change id. // clients are notified of the correct change id.
class ScopedChange { class ScopedChange {
public: public:
ScopedChange(ViewManagerServiceImpl* connection, ScopedChange(ViewManagerServiceImpl* connection,
RootNodeManager* root, RootNodeManager* root,
RootNodeManager::ChangeType change_type,
bool is_delete_node); bool is_delete_node);
~ScopedChange(); ~ScopedChange();
ConnectionSpecificId connection_id() const { return connection_id_; } ConnectionSpecificId connection_id() const { return connection_id_; }
ChangeType change_type() const { return change_type_; }
bool is_delete_node() const { return is_delete_node_; } bool is_delete_node() const { return is_delete_node_; }
// Marks the connection with the specified id as having seen a message. // Marks the connection with the specified id as having seen a message.
...@@ -69,14 +60,9 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager ...@@ -69,14 +60,9 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager
return message_ids_.count(connection_id) > 0; return message_ids_.count(connection_id) > 0;
} }
// Sends OnServerChangeIdAdvanced() to all connections that have not yet
// been messaged.
void SendServerChangeIdAdvanced();
private: private:
RootNodeManager* root_; RootNodeManager* root_;
const ConnectionSpecificId connection_id_; const ConnectionSpecificId connection_id_;
const ChangeType change_type_;
const bool is_delete_node_; const bool is_delete_node_;
// See description of MarkConnectionAsMessaged/DidMessageConnection. // See description of MarkConnectionAsMessaged/DidMessageConnection.
...@@ -93,10 +79,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager ...@@ -93,10 +79,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager
// Returns the id for the next ViewManagerServiceImpl. // Returns the id for the next ViewManagerServiceImpl.
ConnectionSpecificId GetAndAdvanceNextConnectionId(); ConnectionSpecificId GetAndAdvanceNextConnectionId();
Id next_server_change_id() const {
return next_server_change_id_;
}
void AddConnection(ViewManagerServiceImpl* connection); void AddConnection(ViewManagerServiceImpl* connection);
void RemoveConnection(ViewManagerServiceImpl* connection); void RemoveConnection(ViewManagerServiceImpl* connection);
...@@ -185,9 +167,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager ...@@ -185,9 +167,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager
// Balances a call to PrepareForChange(). // Balances a call to PrepareForChange().
void FinishChange(); void FinishChange();
// See description in ScopedChange.
void SendServerChangeIdAdvanced();
// Returns true if the specified connection originated the current change. // Returns true if the specified connection originated the current change.
bool IsChangeSource(ConnectionSpecificId connection_id) const { bool IsChangeSource(ConnectionSpecificId connection_id) const {
return current_change_ && current_change_->connection_id() == connection_id; return current_change_ && current_change_->connection_id() == connection_id;
...@@ -219,8 +198,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager ...@@ -219,8 +198,6 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager
// ID to use for next ViewManagerServiceImpl. // ID to use for next ViewManagerServiceImpl.
ConnectionSpecificId next_connection_id_; ConnectionSpecificId next_connection_id_;
Id next_server_change_id_;
// Set of ViewManagerServiceImpls. // Set of ViewManagerServiceImpls.
ConnectionMap connection_map_; ConnectionMap connection_map_;
......
...@@ -39,11 +39,6 @@ std::string ChangeToDescription1(const Change& change) { ...@@ -39,11 +39,6 @@ std::string ChangeToDescription1(const Change& change) {
case CHANGE_TYPE_ROOTS_ADDED: case CHANGE_TYPE_ROOTS_ADDED:
return "OnRootAdded"; return "OnRootAdded";
case CHANGE_TYPE_SERVER_CHANGE_ID_ADVANCED:
return base::StringPrintf(
"ServerChangeIdAdvanced %d", static_cast<int>(change.change_id));
case CHANGE_TYPE_NODE_BOUNDS_CHANGED: case CHANGE_TYPE_NODE_BOUNDS_CHANGED:
return base::StringPrintf( return base::StringPrintf(
"BoundsChanged node=%s old_bounds=%s new_bounds=%s", "BoundsChanged node=%s old_bounds=%s new_bounds=%s",
...@@ -53,23 +48,20 @@ std::string ChangeToDescription1(const Change& change) { ...@@ -53,23 +48,20 @@ std::string ChangeToDescription1(const Change& change) {
case CHANGE_TYPE_NODE_HIERARCHY_CHANGED: case CHANGE_TYPE_NODE_HIERARCHY_CHANGED:
return base::StringPrintf( return base::StringPrintf(
"HierarchyChanged change_id=%d node=%s new_parent=%s old_parent=%s", "HierarchyChanged node=%s new_parent=%s old_parent=%s",
static_cast<int>(change.change_id),
NodeIdToString(change.node_id).c_str(), NodeIdToString(change.node_id).c_str(),
NodeIdToString(change.node_id2).c_str(), NodeIdToString(change.node_id2).c_str(),
NodeIdToString(change.node_id3).c_str()); NodeIdToString(change.node_id3).c_str());
case CHANGE_TYPE_NODE_REORDERED: case CHANGE_TYPE_NODE_REORDERED:
return base::StringPrintf( return base::StringPrintf(
"Reordered change_id=%d node=%s relative=%s direction=%s", "Reordered node=%s relative=%s direction=%s",
static_cast<int>(change.change_id),
NodeIdToString(change.node_id).c_str(), NodeIdToString(change.node_id).c_str(),
NodeIdToString(change.node_id2).c_str(), NodeIdToString(change.node_id2).c_str(),
DirectionToString(change.direction).c_str()); DirectionToString(change.direction).c_str());
case CHANGE_TYPE_NODE_DELETED: case CHANGE_TYPE_NODE_DELETED:
return base::StringPrintf("NodeDeleted change_id=%d node=%s", return base::StringPrintf("NodeDeleted node=%s",
static_cast<int>(change.change_id),
NodeIdToString(change.node_id).c_str()); NodeIdToString(change.node_id).c_str());
case CHANGE_TYPE_VIEW_DELETED: case CHANGE_TYPE_VIEW_DELETED:
...@@ -125,7 +117,6 @@ void NodeDatasToTestNodes(const Array<NodeDataPtr>& data, ...@@ -125,7 +117,6 @@ void NodeDatasToTestNodes(const Array<NodeDataPtr>& data,
Change::Change() Change::Change()
: type(CHANGE_TYPE_CONNECTION_ESTABLISHED), : type(CHANGE_TYPE_CONNECTION_ESTABLISHED),
connection_id(0), connection_id(0),
change_id(0),
node_id(0), node_id(0),
node_id2(0), node_id2(0),
node_id3(0), node_id3(0),
...@@ -148,12 +139,10 @@ TestChangeTracker::~TestChangeTracker() { ...@@ -148,12 +139,10 @@ TestChangeTracker::~TestChangeTracker() {
void TestChangeTracker::OnViewManagerConnectionEstablished( void TestChangeTracker::OnViewManagerConnectionEstablished(
ConnectionSpecificId connection_id, ConnectionSpecificId connection_id,
const String& creator_url, const String& creator_url,
Id next_server_change_id,
Array<NodeDataPtr> nodes) { Array<NodeDataPtr> nodes) {
Change change; Change change;
change.type = CHANGE_TYPE_CONNECTION_ESTABLISHED; change.type = CHANGE_TYPE_CONNECTION_ESTABLISHED;
change.connection_id = connection_id; change.connection_id = connection_id;
change.change_id = next_server_change_id;
change.creator_url = creator_url; change.creator_url = creator_url;
NodeDatasToTestNodes(nodes, &change.nodes); NodeDatasToTestNodes(nodes, &change.nodes);
AddChange(change); AddChange(change);
...@@ -166,13 +155,6 @@ void TestChangeTracker::OnRootAdded(Array<NodeDataPtr> nodes) { ...@@ -166,13 +155,6 @@ void TestChangeTracker::OnRootAdded(Array<NodeDataPtr> nodes) {
AddChange(change); AddChange(change);
} }
void TestChangeTracker::OnServerChangeIdAdvanced(Id change_id) {
Change change;
change.type = CHANGE_TYPE_SERVER_CHANGE_ID_ADVANCED;
change.change_id = change_id;
AddChange(change);
}
void TestChangeTracker::OnNodeBoundsChanged(Id node_id, void TestChangeTracker::OnNodeBoundsChanged(Id node_id,
RectPtr old_bounds, RectPtr old_bounds,
RectPtr new_bounds) { RectPtr new_bounds) {
...@@ -187,36 +169,31 @@ void TestChangeTracker::OnNodeBoundsChanged(Id node_id, ...@@ -187,36 +169,31 @@ void TestChangeTracker::OnNodeBoundsChanged(Id node_id,
void TestChangeTracker::OnNodeHierarchyChanged(Id node_id, void TestChangeTracker::OnNodeHierarchyChanged(Id node_id,
Id new_parent_id, Id new_parent_id,
Id old_parent_id, Id old_parent_id,
Id server_change_id,
Array<NodeDataPtr> nodes) { Array<NodeDataPtr> nodes) {
Change change; Change change;
change.type = CHANGE_TYPE_NODE_HIERARCHY_CHANGED; change.type = CHANGE_TYPE_NODE_HIERARCHY_CHANGED;
change.node_id = node_id; change.node_id = node_id;
change.node_id2 = new_parent_id; change.node_id2 = new_parent_id;
change.node_id3 = old_parent_id; change.node_id3 = old_parent_id;
change.change_id = server_change_id;
NodeDatasToTestNodes(nodes, &change.nodes); NodeDatasToTestNodes(nodes, &change.nodes);
AddChange(change); AddChange(change);
} }
void TestChangeTracker::OnNodeReordered(Id node_id, void TestChangeTracker::OnNodeReordered(Id node_id,
Id relative_node_id, Id relative_node_id,
OrderDirection direction, OrderDirection direction) {
Id server_change_id) {
Change change; Change change;
change.type = CHANGE_TYPE_NODE_REORDERED; change.type = CHANGE_TYPE_NODE_REORDERED;
change.node_id = node_id; change.node_id = node_id;
change.node_id2 = relative_node_id; change.node_id2 = relative_node_id;
change.direction = direction; change.direction = direction;
change.change_id = server_change_id;
AddChange(change); AddChange(change);
} }
void TestChangeTracker::OnNodeDeleted(Id node_id, Id server_change_id) { void TestChangeTracker::OnNodeDeleted(Id node_id) {
Change change; Change change;
change.type = CHANGE_TYPE_NODE_DELETED; change.type = CHANGE_TYPE_NODE_DELETED;
change.node_id = node_id; change.node_id = node_id;
change.change_id = server_change_id;
AddChange(change); AddChange(change);
} }
......
...@@ -20,7 +20,6 @@ namespace service { ...@@ -20,7 +20,6 @@ namespace service {
enum ChangeType { enum ChangeType {
CHANGE_TYPE_CONNECTION_ESTABLISHED, CHANGE_TYPE_CONNECTION_ESTABLISHED,
CHANGE_TYPE_ROOTS_ADDED, CHANGE_TYPE_ROOTS_ADDED,
CHANGE_TYPE_SERVER_CHANGE_ID_ADVANCED,
CHANGE_TYPE_NODE_BOUNDS_CHANGED, CHANGE_TYPE_NODE_BOUNDS_CHANGED,
CHANGE_TYPE_NODE_HIERARCHY_CHANGED, CHANGE_TYPE_NODE_HIERARCHY_CHANGED,
CHANGE_TYPE_NODE_REORDERED, CHANGE_TYPE_NODE_REORDERED,
...@@ -48,7 +47,6 @@ struct Change { ...@@ -48,7 +47,6 @@ struct Change {
ChangeType type; ChangeType type;
ConnectionSpecificId connection_id; ConnectionSpecificId connection_id;
Id change_id;
std::vector<TestNode> nodes; std::vector<TestNode> nodes;
Id node_id; Id node_id;
Id node_id2; Id node_id2;
...@@ -99,21 +97,17 @@ class TestChangeTracker { ...@@ -99,21 +97,17 @@ class TestChangeTracker {
// ViewManagerClient function. // ViewManagerClient function.
void OnViewManagerConnectionEstablished(ConnectionSpecificId connection_id, void OnViewManagerConnectionEstablished(ConnectionSpecificId connection_id,
const String& creator_url, const String& creator_url,
Id next_server_change_id,
Array<NodeDataPtr> nodes); Array<NodeDataPtr> nodes);
void OnRootAdded(Array<NodeDataPtr> nodes); void OnRootAdded(Array<NodeDataPtr> nodes);
void OnServerChangeIdAdvanced(Id change_id);
void OnNodeBoundsChanged(Id node_id, RectPtr old_bounds, RectPtr new_bounds); void OnNodeBoundsChanged(Id node_id, RectPtr old_bounds, RectPtr new_bounds);
void OnNodeHierarchyChanged(Id node_id, void OnNodeHierarchyChanged(Id node_id,
Id new_parent_id, Id new_parent_id,
Id old_parent_id, Id old_parent_id,
Id server_change_id,
Array<NodeDataPtr> nodes); Array<NodeDataPtr> nodes);
void OnNodeReordered(Id node_id, void OnNodeReordered(Id node_id,
Id relative_node_id, Id relative_node_id,
OrderDirection direction, OrderDirection direction);
Id server_change_id); void OnNodeDeleted(Id node_id);
void OnNodeDeleted(Id node_id, Id server_change_id);
void OnViewDeleted(Id view_id); void OnViewDeleted(Id view_id);
void OnNodeViewReplaced(Id node_id, Id new_view_id, Id old_view_id); void OnNodeViewReplaced(Id node_id, Id new_view_id, Id old_view_id);
void OnViewInputEvent(Id view_id, EventPtr event); void OnViewInputEvent(Id view_id, EventPtr event);
......
...@@ -84,20 +84,16 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl ...@@ -84,20 +84,16 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl
void ProcessNodeHierarchyChanged(const Node* node, void ProcessNodeHierarchyChanged(const Node* node,
const Node* new_parent, const Node* new_parent,
const Node* old_parent, const Node* old_parent,
Id server_change_id,
bool originated_change); bool originated_change);
void ProcessNodeReorder(const Node* node, void ProcessNodeReorder(const Node* node,
const Node* relative_node, const Node* relative_node,
OrderDirection direction, OrderDirection direction,
Id server_change_id,
bool originated_change); bool originated_change);
void ProcessNodeViewReplaced(const Node* node, void ProcessNodeViewReplaced(const Node* node,
const View* new_view, const View* new_view,
const View* old_view, const View* old_view,
bool originated_change); bool originated_change);
void ProcessNodeDeleted(const NodeId& node, void ProcessNodeDeleted(const NodeId& node, bool originated_change);
Id server_change_id,
bool originated_change);
void ProcessViewDeleted(const ViewId& view, bool originated_change); void ProcessViewDeleted(const ViewId& view, bool originated_change);
void ProcessFocusChanged(const Node* focused_node, void ProcessFocusChanged(const Node* focused_node,
const Node* blurred_node, const Node* blurred_node,
...@@ -176,20 +172,16 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl ...@@ -176,20 +172,16 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl
virtual void CreateNode(Id transport_node_id, virtual void CreateNode(Id transport_node_id,
const Callback<void(ErrorCode)>& callback) OVERRIDE; const Callback<void(ErrorCode)>& callback) OVERRIDE;
virtual void DeleteNode(Id transport_node_id, virtual void DeleteNode(Id transport_node_id,
Id server_change_id,
const Callback<void(bool)>& callback) OVERRIDE; const Callback<void(bool)>& callback) OVERRIDE;
virtual void AddNode(Id parent_id, virtual void AddNode(Id parent_id,
Id child_id, Id child_id,
Id server_change_id,
const Callback<void(bool)>& callback) OVERRIDE; const Callback<void(bool)>& callback) OVERRIDE;
virtual void RemoveNodeFromParent( virtual void RemoveNodeFromParent(
Id node_id, Id node_id,
Id server_change_id,
const Callback<void(bool)>& callback) OVERRIDE; const Callback<void(bool)>& callback) OVERRIDE;
virtual void ReorderNode(Id node_id, virtual void ReorderNode(Id node_id,
Id relative_node_id, Id relative_node_id,
OrderDirection direction, OrderDirection direction,
Id server_change_id,
const Callback<void(bool)>& callback) OVERRIDE; const Callback<void(bool)>& callback) OVERRIDE;
virtual void GetNodeTree( virtual void GetNodeTree(
Id node_id, Id node_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment