summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 20:10:26 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 20:10:26 +0000
commit3b167405adca5fc8cc69f07f55517fe4950bf039 (patch)
treec20d45feda8b40a32be982bc3e21fa54f5d772a2
parent20b214459fa989221db03f6fc96e4f13633c1e6a (diff)
downloadchromium_src-3b167405adca5fc8cc69f07f55517fe4950bf039.zip
chromium_src-3b167405adca5fc8cc69f07f55517fe4950bf039.tar.gz
chromium_src-3b167405adca5fc8cc69f07f55517fe4950bf039.tar.bz2
Revert 266940 "First step at synchronizing client model changes ..."
> First step at synchronizing client model changes with service. > > R=sky@chromium.org > http://crbug.com/365012 > > Review URL: https://codereview.chromium.org/258623005 TBR=ben@chromium.org Review URL: https://codereview.chromium.org/261513002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266944 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--mojo/examples/sample_view_manager_app/sample_view_manager_app.cc55
-rw-r--r--mojo/mojo_examples.gypi6
-rw-r--r--mojo/mojo_services.gypi39
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager.cc20
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_private.cc17
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_private.h37
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc261
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h82
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_tree_node.cc16
-rw-r--r--mojo/services/public/cpp/view_manager/view_manager.h17
-rw-r--r--mojo/services/public/cpp/view_manager/view_tree_node.h7
-rw-r--r--mojo/services/public/interfaces/view_manager/view_manager.mojom8
-rw-r--r--mojo/services/view_manager/view_manager_connection.cc2
-rw-r--r--mojo/services/view_manager/view_manager_connection.h6
-rw-r--r--mojo/services/view_manager/view_manager_connection_unittest.cc24
15 files changed, 77 insertions, 520 deletions
diff --git a/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc b/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc
index 43ee7f2..946b57a 100644
--- a/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc
+++ b/mojo/examples/sample_view_manager_app/sample_view_manager_app.cc
@@ -2,17 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/at_exit.h"
#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/message_loop/message_loop.h"
+#include "mojo/public/cpp/bindings/allocation_scope.h"
+#include "mojo/public/cpp/bindings/remote_ptr.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/shell/application.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/macros.h"
#include "mojo/public/cpp/utility/run_loop.h"
-#include "mojo/services/public/cpp/view_manager/view_manager.h"
-#include "mojo/services/public/cpp/view_manager/view_tree_node.h"
+#include "mojo/public/interfaces/shell/shell.mojom.h"
+#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
#if defined(WIN32)
#if !defined(CDECL)
@@ -27,28 +26,43 @@
namespace mojo {
namespace examples {
-class SampleApp : public Application {
+class SampleApp : public Application,
+ public services::view_manager::ViewManagerClient {
public:
- explicit SampleApp(MojoHandle shell_handle)
- : Application(shell_handle) {
- view_manager_.reset(new services::view_manager::ViewManager(shell()));
- node_1_.reset(
- new services::view_manager::ViewTreeNode(view_manager_.get()));
- node_11_.reset(
- new services::view_manager::ViewTreeNode(view_manager_.get()));
- node_1_->AddChild(node_11_.get());
+ explicit SampleApp(MojoHandle shell_handle) : Application(shell_handle) {
+ InterfacePipe<services::view_manager::ViewManager, AnyInterface>
+ view_manager_pipe;
+ AllocationScope scope;
+ shell()->Connect("mojo:mojo_view_manager",
+ view_manager_pipe.handle_to_peer.Pass());
+ view_manager_.reset(view_manager_pipe.handle_to_self.Pass(), this);
+ view_manager_->CreateNode(1, base::Bind(&SampleApp::OnCreatedView,
+ base::Unretained(this)));
}
virtual ~SampleApp() {
}
+ // ViewManagerClient::
+ virtual void OnConnectionEstablished(uint16_t connection_id) OVERRIDE {
+ }
+ virtual void OnNodeHierarchyChanged(uint32_t node,
+ uint32_t new_parent,
+ uint32_t old_parent,
+ uint32_t change_id) OVERRIDE {
+ }
+ virtual void OnNodeViewReplaced(uint32_t node,
+ uint32_t old_view_id,
+ uint32_t new_view_id,
+ uint32_t change_id) OVERRIDE {
+ }
+
private:
- // SampleApp creates a ViewManager and a trivial node hierarchy.
- scoped_ptr<services::view_manager::ViewManager> view_manager_;
- scoped_ptr<services::view_manager::ViewTreeNode> node_1_;
- scoped_ptr<services::view_manager::ViewTreeNode> node_11_;
+ void OnCreatedView(bool success) {
+ DCHECK(success);
+ }
- DISALLOW_COPY_AND_ASSIGN(SampleApp);
+ RemotePtr<services::view_manager::ViewManager> view_manager_;
};
} // namespace examples
@@ -56,7 +70,8 @@ class SampleApp : public Application {
extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain(
MojoHandle shell_handle) {
- base::MessageLoop loop;
+ mojo::Environment env;
+ mojo::RunLoop loop;
mojo::examples::SampleApp app(shell_handle);
loop.Run();
diff --git a/mojo/mojo_examples.gypi b/mojo/mojo_examples.gypi
index 69099939..5bece9b 100644
--- a/mojo/mojo_examples.gypi
+++ b/mojo/mojo_examples.gypi
@@ -284,11 +284,11 @@
'../ui/gfx/gfx.gyp:gfx_geometry',
'../ui/gl/gl.gyp:gl',
'mojo_bindings',
- 'mojo_environment_chromium',
+ 'mojo_environment_standalone',
'mojo_gles2',
- 'mojo_view_manager_lib',
+ 'mojo_view_manager_bindings',
'mojo_shell_client',
- 'mojo_system_impl',
+ 'mojo_system',
'mojo_utility',
],
'sources': [
diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi
index adb5f7f4..3cec1d1 100644
--- a/mojo/mojo_services.gypi
+++ b/mojo/mojo_services.gypi
@@ -119,36 +119,14 @@
],
},
{
- 'target_name': 'mojo_view_manager_bindings',
- 'type': 'static_library',
- 'sources': [
- 'services/public/interfaces/view_manager/view_manager.mojom',
- ],
- 'variables': {
- 'mojom_base_output_dir': 'mojo',
- },
- 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ],
- 'export_dependent_settings': [
- 'mojo_bindings',
- ],
- 'dependencies': [
- 'mojo_bindings',
- ],
- },
- {
'target_name': 'mojo_view_manager_lib',
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base',
- 'mojo_view_manager_bindings',
],
'sources': [
'services/public/cpp/view_manager/lib/view.cc',
'services/public/cpp/view_manager/lib/view_manager.cc',
- 'services/public/cpp/view_manager/lib/view_manager_private.cc',
- 'services/public/cpp/view_manager/lib/view_manager_private.h',
- 'services/public/cpp/view_manager/lib/view_manager_synchronizer.cc',
- 'services/public/cpp/view_manager/lib/view_manager_synchronizer.h',
'services/public/cpp/view_manager/lib/view_tree_host.cc',
'services/public/cpp/view_manager/lib/view_tree_node.cc',
'services/public/cpp/view_manager/lib/view_tree_node_observer.cc',
@@ -183,6 +161,23 @@
['use_aura==1', {
'targets': [
{
+ 'target_name': 'mojo_view_manager_bindings',
+ 'type': 'static_library',
+ 'sources': [
+ 'services/public/interfaces/view_manager/view_manager.mojom',
+ ],
+ 'variables': {
+ 'mojom_base_output_dir': 'mojo',
+ },
+ 'includes': [ 'public/tools/bindings/mojom_bindings_generator.gypi' ],
+ 'export_dependent_settings': [
+ 'mojo_bindings',
+ ],
+ 'dependencies': [
+ 'mojo_bindings',
+ ],
+ },
+ {
'target_name': 'mojo_view_manager',
'type': '<(component)',
'dependencies': [
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager.cc b/mojo/services/public/cpp/view_manager/lib/view_manager.cc
index 7fd82e76..e69de29 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_manager.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_manager.cc
@@ -1,20 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/public/cpp/view_manager/view_manager.h"
-
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-ViewManager::ViewManager(Shell* shell)
- : shell_(shell),
- synchronizer_(new ViewManagerSynchronizer(this)) {}
-ViewManager::~ViewManager() {}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_private.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_private.cc
deleted file mode 100644
index e3272c3..0000000
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_private.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-ViewManagerPrivate::ViewManagerPrivate(ViewManager* manager)
- : manager_(manager) {}
-ViewManagerPrivate::~ViewManagerPrivate() {}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_private.h b/mojo/services/public/cpp/view_manager/lib/view_manager_private.h
deleted file mode 100644
index 071404b..0000000
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_private.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_PRIVATE_H_
-#define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_PRIVATE_H_
-
-#include "base/basictypes.h"
-#include "mojo/services/public/cpp/view_manager/view_manager.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class ViewManagerSynchronizer;
-
-class ViewManagerPrivate {
- public:
- explicit ViewManagerPrivate(ViewManager* manager);
- ~ViewManagerPrivate();
-
- ViewManagerSynchronizer* synchronizer() {
- return manager_->synchronizer_.get();
- }
- Shell* shell() { return manager_->shell_; }
-
- private:
- ViewManager* manager_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerPrivate);
-};
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
-
-#endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_PRIVATE_H_
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
deleted file mode 100644
index a3196be..0000000
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc
+++ /dev/null
@@ -1,261 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "mojo/public/cpp/bindings/allocation_scope.h"
-#include "mojo/public/interfaces/shell/shell.mojom.h"
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class ViewManagerTransaction {
- public:
- virtual ~ViewManagerTransaction() {}
-
- void Commit() {
- DCHECK(!committed_);
- DoCommit();
- committed_ = true;
- }
-
- bool committed() const { return committed_; }
- uint32_t change_id() const { return change_id_; }
-
- // General callback to be used for commits to the service.
- void OnActionCompleted(bool success) {
- DCHECK(success);
- DoActionCompleted(success);
- synchronizer_->RemoveFromPendingQueue(this);
- }
-
- protected:
- enum TransactionType {
- // Node creation.
- TYPE_CREATE_VIEW_TREE_NODE,
- // Modifications to the hierarchy (addition of or removal of nodes from a
- // parent.)
- TYPE_HIERARCHY
- };
-
- ViewManagerTransaction(TransactionType transaction_type,
- ViewManagerSynchronizer* synchronizer)
- : transaction_type_(transaction_type),
- change_id_(synchronizer->GetNextChangeId()),
- committed_(false),
- synchronizer_(synchronizer) {
- }
-
- // Overridden to perform transaction-specific commit actions.
- virtual void DoCommit() = 0;
-
- // Overridden to perform transaction-specific cleanup on commit ack from the
- // service.
- virtual void DoActionCompleted(bool success) = 0;
-
- IViewManager* service() { return synchronizer_->service_.get(); }
-
- uint32_t MakeTransportId(uint16_t id) {
- return (synchronizer_->connection_id_ << 16) | id;
- }
-
- private:
- const TransactionType transaction_type_;
- const uint32_t change_id_;
- bool committed_;
- ViewManagerSynchronizer* synchronizer_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerTransaction);
-};
-
-class CreateViewTreeNodeTransaction
- : public ViewManagerTransaction {
- public:
- CreateViewTreeNodeTransaction(uint16_t node_id,
- ViewManagerSynchronizer* synchronizer)
- : ViewManagerTransaction(TYPE_CREATE_VIEW_TREE_NODE, synchronizer),
- node_id_(node_id) {}
- virtual ~CreateViewTreeNodeTransaction() {}
-
- private:
- // Overridden from ViewManagerTransaction:
- virtual void DoCommit() OVERRIDE {
- service()->CreateNode(
- node_id_,
- base::Bind(&ViewManagerTransaction::OnActionCompleted,
- base::Unretained(this)));
- }
-
- void DoActionCompleted(bool success) {
- // TODO(beng): Failure means we tried to create with an extant id for this
- // connection. Figure out what to do.
- }
-
- const uint16_t node_id_;
-
- DISALLOW_COPY_AND_ASSIGN(CreateViewTreeNodeTransaction);
-};
-
-class HierarchyTransaction : public ViewManagerTransaction {
- public:
- enum HierarchyChangeType {
- TYPE_ADD,
- TYPE_REMOVE
- };
- HierarchyTransaction(HierarchyChangeType hierarchy_change_type,
- uint16_t child_id,
- uint16_t parent_id,
- ViewManagerSynchronizer* synchronizer)
- : ViewManagerTransaction(TYPE_HIERARCHY, synchronizer),
- hierarchy_change_type_(hierarchy_change_type),
- child_id_(child_id),
- parent_id_(parent_id) {}
- virtual ~HierarchyTransaction() {}
-
- private:
- // Overridden from ViewManagerTransaction:
- virtual void DoCommit() OVERRIDE {
- switch (hierarchy_change_type_) {
- case TYPE_ADD:
- service()->AddNode(
- MakeTransportId(parent_id_),
- MakeTransportId(child_id_),
- change_id(),
- base::Bind(&ViewManagerTransaction::OnActionCompleted,
- base::Unretained(this)));
- break;
- case TYPE_REMOVE:
- service()->RemoveNodeFromParent(
- MakeTransportId(child_id_),
- change_id(),
- base::Bind(&ViewManagerTransaction::OnActionCompleted,
- base::Unretained(this)));
- break;
- }
- }
-
- void DoActionCompleted(bool success) {
- // TODO(beng): Failure means either one of the nodes specified didn't exist,
- // or we passed the same node id for both params. Roll back?
- }
-
- const HierarchyChangeType hierarchy_change_type_;
- const uint16_t child_id_;
- const uint16_t parent_id_;
-
- DISALLOW_COPY_AND_ASSIGN(HierarchyTransaction);
-};
-
-ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager)
- : view_manager_(view_manager),
- connected_(false),
- connection_id_(0),
- next_id_(0),
- next_change_id_(0) {
- InterfacePipe<services::view_manager::IViewManager, AnyInterface>
- view_manager_pipe;
- AllocationScope scope;
- ViewManagerPrivate(view_manager_).shell()->Connect(
- "mojo:mojo_view_manager", view_manager_pipe.handle_to_peer.Pass());
- service_.reset(view_manager_pipe.handle_to_self.Pass(), this);
-}
-
-ViewManagerSynchronizer::~ViewManagerSynchronizer() {
-}
-
-uint16_t ViewManagerSynchronizer::CreateViewTreeNode() {
- uint16_t id = next_id_++;
- pending_transactions_.push_back(new CreateViewTreeNodeTransaction(id, this));
- ScheduleSync();
- return id;
-}
-
-void ViewManagerSynchronizer::AddChild(uint16_t child_id, uint16_t parent_id) {
- pending_transactions_.push_back(
- new HierarchyTransaction(HierarchyTransaction::TYPE_ADD,
- child_id,
- parent_id,
- this));
- ScheduleSync();
-}
-
-void ViewManagerSynchronizer::RemoveChild(uint16_t child_id,
- uint16_t parent_id) {
- pending_transactions_.push_back(
- new HierarchyTransaction(HierarchyTransaction::TYPE_REMOVE,
- child_id,
- parent_id,
- this));
- ScheduleSync();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerSynchronizer, IViewManagerClient implementation:
-
-void ViewManagerSynchronizer::OnConnectionEstablished(uint16 connection_id) {
- connected_ = true;
- connection_id_ = connection_id;
- ScheduleSync();
-}
-
-void ViewManagerSynchronizer::OnNodeHierarchyChanged(uint32_t node,
- uint32_t new_parent,
- uint32_t old_parent,
- uint32_t change_id) {
- if (change_id == 0) {
- // TODO(beng): Apply changes from another client.
- }
-}
-
-void ViewManagerSynchronizer::OnNodeViewReplaced(uint32_t node,
- uint32_t new_view_id,
- uint32_t old_view_id,
- uint32_t change_id) {
- // ..
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerSynchronizer, private:
-
-void ViewManagerSynchronizer::ScheduleSync() {
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&ViewManagerSynchronizer::DoSync, base::Unretained(this)));
-}
-
-void ViewManagerSynchronizer::DoSync() {
- // The service connection may not be set up yet. OnConnectionEstablished()
- // will schedule another sync when it is.
- if (!connected_)
- return;
-
- Transactions::const_iterator it = pending_transactions_.begin();
- for (; it != pending_transactions_.end(); ++it) {
- if (!(*it)->committed())
- (*it)->Commit();
- }
-}
-
-uint32_t ViewManagerSynchronizer::GetNextChangeId() {
- // TODO(beng): deal with change id collisions? Important in the "never ack'ed
- // change" case mentioned in OnNodeHierarchyChanged().
- // "0" is a special value passed to other connected clients, so we can't use
- // it.
- next_change_id_ = std::max(1u, ++next_change_id_);
- return next_change_id_;
-}
-
-void ViewManagerSynchronizer::RemoveFromPendingQueue(
- ViewManagerTransaction* transaction) {
- DCHECK_EQ(transaction, pending_transactions_.front());
- pending_transactions_.erase(pending_transactions_.begin());
-}
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
diff --git a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h
deleted file mode 100644
index 54da430..0000000
--- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_
-#define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_vector.h"
-#include "mojo/public/cpp/bindings/remote_ptr.h"
-#include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h"
-
-namespace mojo {
-namespace services {
-namespace view_manager {
-
-class ViewManager;
-class ViewManagerTransaction;
-
-// Manages the connection with the View Manager service.
-class ViewManagerSynchronizer : public IViewManagerClient {
- public:
- explicit ViewManagerSynchronizer(ViewManager* view_manager);
- virtual ~ViewManagerSynchronizer();
-
- // API exposed to the node implementation that pushes local changes to the
- // service.
- uint16_t CreateViewTreeNode();
- void AddChild(uint16_t child_id, uint16_t parent_id);
- void RemoveChild(uint16_t child_id, uint16_t parent_id);
-
- private:
- friend class ViewManagerTransaction;
- typedef ScopedVector<ViewManagerTransaction> Transactions;
-
- // Overridden from IViewManagerClient:
- virtual void OnConnectionEstablished(uint16 connection_id) OVERRIDE;
- virtual void OnNodeHierarchyChanged(uint32 node,
- uint32 new_parent,
- uint32 old_parent,
- uint32 change_id) OVERRIDE;
- virtual void OnNodeViewReplaced(uint32_t node,
- uint32_t new_view_id,
- uint32_t old_view_id,
- uint32_t change_id) OVERRIDE;
-
- // Called to schedule a sync of the client model with the service after a
- // return to the message loop.
- void ScheduleSync();
-
- // Sync the client model with the service by enumerating the pending
- // transaction queue and applying them in order.
- void DoSync();
-
- // Used by individual transactions to generate a connection-specific change
- // id.
- // TODO(beng): What happens when there are more than sizeof(int) changes in
- // the queue?
- uint32_t GetNextChangeId();
-
- // Removes |transaction| from the pending queue. |transaction| must be at the
- // front of the queue.
- void RemoveFromPendingQueue(ViewManagerTransaction* transaction);
-
- ViewManager* view_manager_;
- bool connected_;
- uint16_t connection_id_;
- uint16_t next_id_;
- uint32_t next_change_id_;
-
- Transactions pending_transactions_;
-
- RemotePtr<IViewManager> service_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer);
-};
-
-} // namespace view_manager
-} // namespace services
-} // namespace mojo
-
-#endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_
diff --git a/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc b/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc
index d695ed4..9194dc4 100644
--- a/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc
+++ b/mojo/services/public/cpp/view_manager/lib/view_tree_node.cc
@@ -4,8 +4,6 @@
#include "mojo/services/public/cpp/view_manager/view_tree_node.h"
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
-#include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h"
#include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h"
#include "mojo/services/public/cpp/view_manager/view_tree_node_observer.h"
@@ -90,17 +88,7 @@ void RemoveChildImpl(ViewTreeNode* child, ViewTreeNode::Children* children) {
////////////////////////////////////////////////////////////////////////////////
// ViewTreeNode, public:
-ViewTreeNode::ViewTreeNode()
- : manager_(NULL),
- id_(-1),
- owned_by_parent_(true),
- parent_(NULL) {}
-
-ViewTreeNode::ViewTreeNode(ViewManager* manager)
- : manager_(manager),
- id_(ViewManagerPrivate(manager).synchronizer()->CreateViewTreeNode()),
- owned_by_parent_(true),
- parent_(NULL) {}
+ViewTreeNode::ViewTreeNode() : owned_by_parent_(true), parent_(NULL) {}
ViewTreeNode::~ViewTreeNode() {
while (!children_.empty()) {
@@ -134,14 +122,12 @@ void ViewTreeNode::AddChild(ViewTreeNode* child) {
RemoveChildImpl(child, &child->parent_->children_);
children_.push_back(child);
child->parent_ = this;
- ViewManagerPrivate(manager_).synchronizer()->AddChild(child->id(), id_);
}
void ViewTreeNode::RemoveChild(ViewTreeNode* child) {
DCHECK_EQ(this, child->parent());
ScopedTreeNotifier(child, this, NULL);
RemoveChildImpl(child, &children_);
- ViewManagerPrivate(manager_).synchronizer()->RemoveChild(child->id(), id_);
}
bool ViewTreeNode::Contains(ViewTreeNode* child) const {
diff --git a/mojo/services/public/cpp/view_manager/view_manager.h b/mojo/services/public/cpp/view_manager/view_manager.h
index fb492ec..45ab0e2 100644
--- a/mojo/services/public/cpp/view_manager/view_manager.h
+++ b/mojo/services/public/cpp/view_manager/view_manager.h
@@ -6,31 +6,14 @@
#define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_VIEW_MANAGER_H_
#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
namespace mojo {
-class Shell;
namespace services {
namespace view_manager {
-class ViewManagerSynchronizer;
-
-// Approximately encapsulates the View Manager service.
-// Owns a synchronizer that keeps a client model in sync with the service.
-// Owned by the creator.
-//
-// TODO: displays
class ViewManager {
public:
- explicit ViewManager(Shell* shell);
- ~ViewManager();
-
private:
- friend class ViewManagerPrivate;
-
- Shell* shell_;
- scoped_ptr<ViewManagerSynchronizer> synchronizer_;
-
DISALLOW_COPY_AND_ASSIGN(ViewManager);
};
diff --git a/mojo/services/public/cpp/view_manager/view_tree_node.h b/mojo/services/public/cpp/view_manager/view_tree_node.h
index d187c66..42f27e7 100644
--- a/mojo/services/public/cpp/view_manager/view_tree_node.h
+++ b/mojo/services/public/cpp/view_manager/view_tree_node.h
@@ -14,19 +14,16 @@ namespace mojo {
namespace services {
namespace view_manager {
-class ViewManager;
class ViewTreeNodeObserver;
class ViewTreeNode {
public:
typedef std::vector<ViewTreeNode*> Children;
- explicit ViewTreeNode(ViewManager* manager);
- ViewTreeNode(); // Used for tests.
+ ViewTreeNode();
~ViewTreeNode();
// Configuration.
- uint16_t id() const { return id_; }
void set_owned_by_parent(bool owned_by_parent) {
owned_by_parent_ = owned_by_parent;
}
@@ -48,8 +45,6 @@ class ViewTreeNode {
private:
friend class ViewTreeNodePrivate;
- ViewManager* manager_;
- uint16_t id_;
bool owned_by_parent_;
ViewTreeNode* parent_;
Children children_;
diff --git a/mojo/services/public/interfaces/view_manager/view_manager.mojom b/mojo/services/public/interfaces/view_manager/view_manager.mojom
index 78e1542..c5a96a5 100644
--- a/mojo/services/public/interfaces/view_manager/view_manager.mojom
+++ b/mojo/services/public/interfaces/view_manager/view_manager.mojom
@@ -15,8 +15,8 @@ module mojo.services.view_manager {
// uint16 as the connection id of the originating connection is used.
//
// The root node is identified with a connection id of 0, and value of 1.
-[Peer=IViewManagerClient]
-interface IViewManager {
+[Peer=ViewManagerClient]
+interface ViewManager {
// Creates a new node with the specified id. It is up to the client to ensure
// the id is unique to the connection (the id need not be globally unique).
CreateNode(uint16 node_id) => (bool success);
@@ -43,8 +43,8 @@ interface IViewManager {
SetView(uint32 node_id, uint32 view_id, uint32 change_id) => (bool success);
};
-[Peer=IViewManager]
-interface IViewManagerClient {
+[Peer=ViewManager]
+interface ViewManagerClient {
// Invoked once the connection has been established. |connection_id| is the id
// used to uniquely identify the connection.
OnConnectionEstablished(uint16 connection_id);
diff --git a/mojo/services/view_manager/view_manager_connection.cc b/mojo/services/view_manager/view_manager_connection.cc
index 824df43..7bdf0c4 100644
--- a/mojo/services/view_manager/view_manager_connection.cc
+++ b/mojo/services/view_manager/view_manager_connection.cc
@@ -39,7 +39,7 @@ void ViewManagerConnection::Initialize(
ServiceConnector<ViewManagerConnection, RootNodeManager>* service_factory,
ScopedMessagePipeHandle client_handle) {
DCHECK_EQ(0, id_); // Should only get Initialize() once.
- ServiceConnection<IViewManager, ViewManagerConnection, RootNodeManager>::
+ ServiceConnection<ViewManager, ViewManagerConnection, RootNodeManager>::
Initialize(service_factory, client_handle.Pass());
id_ = context()->GetAndAdvanceNextConnectionId();
context()->AddConnection(this);
diff --git a/mojo/services/view_manager/view_manager_connection.h b/mojo/services/view_manager/view_manager_connection.h
index 73f92f8..02bfa52 100644
--- a/mojo/services/view_manager/view_manager_connection.h
+++ b/mojo/services/view_manager/view_manager_connection.h
@@ -24,7 +24,7 @@ class View;
// Manages a connection from the client.
class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
- : public ServiceConnection<IViewManager, ViewManagerConnection,
+ : public ServiceConnection<ViewManager, ViewManagerConnection,
RootNodeManager>,
public NodeDelegate {
public:
@@ -75,7 +75,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
const ViewId& view_id,
ChangeId change_id);
- // Overridden from IViewManager:
+ // Overridden from ViewManager:
virtual void CreateNode(uint16_t node_id,
const Callback<void(bool)>& callback) OVERRIDE;
virtual void DeleteNode(uint32_t transport_node_id,
@@ -99,7 +99,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
ChangeId change_id,
const mojo::Callback<void(bool)>& callback) OVERRIDE;
- // Overridden from NodeDelegate:
+ // Overriden from NodeDelegate:
virtual void OnNodeHierarchyChanged(const NodeId& node,
const NodeId& new_parent,
const NodeId& old_parent) OVERRIDE;
diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc
index e03c5e0..87db93a 100644
--- a/mojo/services/view_manager/view_manager_connection_unittest.cc
+++ b/mojo/services/view_manager/view_manager_connection_unittest.cc
@@ -70,7 +70,7 @@ uint32_t CreateViewId(uint16_t connection_id, uint16_t view_id) {
// Creates a node with the specified id. Returns true on success. Blocks until
// we get back result from server.
-bool CreateNode(IViewManager* view_manager, uint16_t id) {
+bool CreateNode(ViewManager* view_manager, uint16_t id) {
bool result = false;
view_manager->CreateNode(id, base::Bind(&BooleanCallback, &result));
DoRunLoop();
@@ -80,7 +80,7 @@ bool CreateNode(IViewManager* view_manager, uint16_t id) {
// TODO(sky): make a macro for these functions, they are all the same.
// Deletes a node, blocking until done.
-bool DeleteNode(IViewManager* view_manager,
+bool DeleteNode(ViewManager* view_manager,
uint32_t node_id,
ChangeId change_id) {
bool result = false;
@@ -91,7 +91,7 @@ bool DeleteNode(IViewManager* view_manager,
}
// Adds a node, blocking until done.
-bool AddNode(IViewManager* view_manager,
+bool AddNode(ViewManager* view_manager,
uint32_t parent,
uint32_t child,
ChangeId change_id) {
@@ -103,7 +103,7 @@ bool AddNode(IViewManager* view_manager,
}
// Removes a node, blocking until done.
-bool RemoveNodeFromParent(IViewManager* view_manager,
+bool RemoveNodeFromParent(ViewManager* view_manager,
uint32_t node_id,
ChangeId change_id) {
bool result = false;
@@ -115,7 +115,7 @@ bool RemoveNodeFromParent(IViewManager* view_manager,
// Creates a view with the specified id. Returns true on success. Blocks until
// we get back result from server.
-bool CreateView(IViewManager* view_manager, uint16_t id) {
+bool CreateView(ViewManager* view_manager, uint16_t id) {
bool result = false;
view_manager->CreateView(id, base::Bind(&BooleanCallback, &result));
DoRunLoop();
@@ -124,7 +124,7 @@ bool CreateView(IViewManager* view_manager, uint16_t id) {
// Sets a view on the specified node. Returns true on success. Blocks until we
// get back result from server.
-bool SetView(IViewManager* view_manager,
+bool SetView(ViewManager* view_manager,
uint32_t node_id,
uint32_t view_id,
ChangeId change_id) {
@@ -139,7 +139,7 @@ bool SetView(IViewManager* view_manager,
typedef std::vector<std::string> Changes;
-class ViewManagerClientImpl : public IViewManagerClient {
+class ViewManagerClientImpl : public ViewManagerClient {
public:
ViewManagerClientImpl() : id_(0), quit_count_(0) {}
@@ -164,7 +164,7 @@ class ViewManagerClientImpl : public IViewManagerClient {
}
private:
- // IViewManagerClient overrides:
+ // ViewManagerClient overrides:
virtual void OnConnectionEstablished(uint16_t connection_id) OVERRIDE {
id_ = connection_id;
if (current_run_loop)
@@ -219,7 +219,7 @@ class ViewManagerConnectionTest : public testing::Test {
test_helper_.Init();
- InterfacePipe<IViewManager, AnyInterface> pipe;
+ InterfacePipe<ViewManager, AnyInterface> pipe;
test_helper_.shell()->Connect("mojo:mojo_view_manager",
pipe.handle_to_peer.Pass());
view_manager_.reset(pipe.handle_to_self.Pass(), &client_);
@@ -231,7 +231,7 @@ class ViewManagerConnectionTest : public testing::Test {
// Creates a second connection to the viewmanager.
void EstablishSecondConnection() {
AllocationScope allocation_scope;
- InterfacePipe<IViewManager, AnyInterface> pipe;
+ InterfacePipe<ViewManager, AnyInterface> pipe;
test_helper_.shell()->Connect("mojo:mojo_view_manager",
pipe.handle_to_peer.Pass());
view_manager2_.reset(pipe.handle_to_self.Pass(), &client2_);
@@ -247,10 +247,10 @@ class ViewManagerConnectionTest : public testing::Test {
shell::ShellTestHelper test_helper_;
ViewManagerClientImpl client_;
- RemotePtr<IViewManager> view_manager_;
+ RemotePtr<ViewManager> view_manager_;
ViewManagerClientImpl client2_;
- RemotePtr<IViewManager> view_manager2_;
+ RemotePtr<ViewManager> view_manager2_;
DISALLOW_COPY_AND_ASSIGN(ViewManagerConnectionTest);
};