diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 00:47:33 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-17 00:47:33 +0000 |
commit | e6a1635b22a381997f3557a0b18437160731bdf1 (patch) | |
tree | 2c737f388ec084ae3894aecbbcf3da7a784d18f4 /mojo | |
parent | 3615989732561d148032aeb74475d79948f4e000 (diff) | |
download | chromium_src-e6a1635b22a381997f3557a0b18437160731bdf1.zip chromium_src-e6a1635b22a381997f3557a0b18437160731bdf1.tar.gz chromium_src-e6a1635b22a381997f3557a0b18437160731bdf1.tar.bz2 |
Rename ViewManager types
INode->NodeData
IViewManager->ViewManagerService
IViewManagerInit->ViewManagerInitService
IViewManagerClient->ViewManagerClient
ViewManagerConnection->ViewManagerServiceImpl
ViewManagerInitConnection->ViewManagerInitServiceImpl
BUG=384443
TEST=none
R=ben@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/339743003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
20 files changed, 304 insertions, 298 deletions
diff --git a/mojo/examples/aura_demo/aura_demo.cc b/mojo/examples/aura_demo/aura_demo.cc index c0fad68..ba8c48e 100644 --- a/mojo/examples/aura_demo/aura_demo.cc +++ b/mojo/examples/aura_demo/aura_demo.cc @@ -130,28 +130,28 @@ class DemoWindowTreeClient : public aura::client::WindowTreeClient { class AuraDemo; -// Trivial IViewManagerClient implementation. Forwards to AuraDemo when +// Trivial ViewManagerClient implementation. Forwards to AuraDemo when // connection established. -class IViewManagerClientImpl - : public InterfaceImpl<view_manager::IViewManagerClient> { +class ViewManagerClientImpl + : public InterfaceImpl<view_manager::ViewManagerClient> { public: - explicit IViewManagerClientImpl(AuraDemo* aura_demo) + explicit ViewManagerClientImpl(AuraDemo* aura_demo) : aura_demo_(aura_demo) {} - virtual ~IViewManagerClientImpl() {} + virtual ~ViewManagerClientImpl() {} private: void OnResult(bool result) { - VLOG(1) << "IViewManagerClientImpl::::OnResult result=" << result; + VLOG(1) << "ViewManagerClientImpl::::OnResult result=" << result; DCHECK(result); } - // IViewManagerClient: + // ViewManagerClient: virtual void OnViewManagerConnectionEstablished( uint16_t connection_id, const String& creator_url, uint32_t next_server_change_id, - mojo::Array<view_manager::INodePtr> nodes) OVERRIDE; - virtual void OnRootsAdded(Array<view_manager::INodePtr> nodes) OVERRIDE { + mojo::Array<view_manager::NodeDataPtr> nodes) OVERRIDE; + virtual void OnRootsAdded(Array<view_manager::NodeDataPtr> nodes) OVERRIDE { NOTREACHED(); } virtual void OnServerChangeIdAdvanced( @@ -166,7 +166,7 @@ class IViewManagerClientImpl uint32_t new_parent, uint32_t old_parent, uint32_t server_change_id, - mojo::Array<view_manager::INodePtr> nodes) OVERRIDE { + mojo::Array<view_manager::NodeDataPtr> nodes) OVERRIDE { } virtual void OnNodeReordered( uint32_t node_id, @@ -190,7 +190,7 @@ class IViewManagerClientImpl AuraDemo* aura_demo_; - DISALLOW_COPY_AND_ASSIGN(IViewManagerClientImpl); + DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); }; class AuraDemo : public Application, public WindowTreeHostMojoDelegate { @@ -201,11 +201,12 @@ class AuraDemo : public Application, public WindowTreeHostMojoDelegate { window2_(NULL), window21_(NULL), view_id_(0) { - AddService<IViewManagerClientImpl>(this); + AddService<ViewManagerClientImpl>(this); } virtual ~AuraDemo() {} - void SetRoot(view_manager::IViewManager* view_manager, uint32_t view_id) { + void SetRoot(view_manager::ViewManagerService* view_manager, + uint32_t view_id) { aura::Env::CreateInstance(true); view_manager_ = view_manager; view_id_ = view_id; @@ -278,7 +279,7 @@ class AuraDemo : public Application, public WindowTreeHostMojoDelegate { scoped_ptr<DemoWindowDelegate> delegate2_; scoped_ptr<DemoWindowDelegate> delegate21_; - view_manager::IViewManager* view_manager_; + view_manager::ViewManagerService* view_manager_; aura::Window* window1_; aura::Window* window2_; @@ -293,16 +294,16 @@ class AuraDemo : public Application, public WindowTreeHostMojoDelegate { DISALLOW_COPY_AND_ASSIGN(AuraDemo); }; -void IViewManagerClientImpl::OnViewManagerConnectionEstablished( +void ViewManagerClientImpl::OnViewManagerConnectionEstablished( uint16_t connection_id, const String& creator_url, uint32_t next_server_change_id, - mojo::Array<view_manager::INodePtr> nodes) { + mojo::Array<view_manager::NodeDataPtr> nodes) { const uint32_t view_id = connection_id << 16 | 1; - client()->CreateView(view_id, base::Bind(&IViewManagerClientImpl::OnResult, + client()->CreateView(view_id, base::Bind(&ViewManagerClientImpl::OnResult, base::Unretained(this))); client()->SetView(nodes[0]->node_id, view_id, - base::Bind(&IViewManagerClientImpl::OnResult, + base::Bind(&ViewManagerClientImpl::OnResult, base::Unretained(this))); aura_demo_->SetRoot(client(), view_id); diff --git a/mojo/examples/aura_demo/view_manager_init.cc b/mojo/examples/aura_demo/view_manager_init.cc index 2f42bbf..7a558d3 100644 --- a/mojo/examples/aura_demo/view_manager_init.cc +++ b/mojo/examples/aura_demo/view_manager_init.cc @@ -30,7 +30,7 @@ class ViewManagerInit : public Application { VLOG(1) << "ViewManagerInit::DidConnection result=" << result; } - view_manager::IViewManagerInitPtr view_manager_init_; + view_manager::ViewManagerInitServicePtr view_manager_init_; DISALLOW_COPY_AND_ASSIGN(ViewManagerInit); }; diff --git a/mojo/examples/demo_launcher/demo_launcher.cc b/mojo/examples/demo_launcher/demo_launcher.cc index 134038a..141a49a 100644 --- a/mojo/examples/demo_launcher/demo_launcher.cc +++ b/mojo/examples/demo_launcher/demo_launcher.cc @@ -19,8 +19,8 @@ class DemoLauncher : public Application { private: // Overridden from Application: virtual void Initialize() MOJO_OVERRIDE { - ConnectTo<view_manager::IViewManagerInit>("mojo:mojo_view_manager", - &view_manager_init_); + ConnectTo<view_manager::ViewManagerInitService>("mojo:mojo_view_manager", + &view_manager_init_); view_manager_init_->EmbedRoot("mojo:mojo_window_manager", base::Bind(&DemoLauncher::OnConnect, base::Unretained(this))); @@ -28,7 +28,7 @@ class DemoLauncher : public Application { void OnConnect(bool success) {} - view_manager::IViewManagerInitPtr view_manager_init_; + view_manager::ViewManagerInitServicePtr view_manager_init_; DISALLOW_COPY_AND_ASSIGN(DemoLauncher); }; diff --git a/mojo/mojo_services.gypi b/mojo/mojo_services.gypi index 9c407ac..a0bd0a5 100644 --- a/mojo/mojo_services.gypi +++ b/mojo/mojo_services.gypi @@ -444,11 +444,11 @@ 'services/view_manager/root_view_manager_delegate.h', 'services/view_manager/view.cc', 'services/view_manager/view.h', - 'services/view_manager/view_manager_connection.cc', - 'services/view_manager/view_manager_connection.h', - 'services/view_manager/view_manager_init_connection.cc', - 'services/view_manager/view_manager_init_connection.h', 'services/view_manager/view_manager_export.h', + 'services/view_manager/view_manager_init_service_impl.cc', + 'services/view_manager/view_manager_init_service_impl.h', + 'services/view_manager/view_manager_service_impl.cc', + 'services/view_manager/view_manager_service_impl.h', 'services/view_manager/context_factory_impl.cc', 'services/view_manager/context_factory_impl.h', 'services/view_manager/window_tree_host_impl.cc', @@ -499,7 +499,7 @@ 'sources': [ 'services/view_manager/test_change_tracker.cc', 'services/view_manager/test_change_tracker.h', - 'services/view_manager/view_manager_connection_unittest.cc', + 'services/view_manager/view_manager_unittest.cc', ], }, { 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 index 3568ae5..49c03aa 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc @@ -59,7 +59,7 @@ ViewTreeNode* AddNodeToViewManager(ViewManagerSynchronizer* synchronizer, } ViewTreeNode* BuildNodeTree(ViewManagerSynchronizer* synchronizer, - const Array<INodePtr>& nodes) { + const Array<NodeDataPtr>& nodes) { std::vector<ViewTreeNode*> parents; ViewTreeNode* root = NULL; ViewTreeNode* last_node = NULL; @@ -132,7 +132,7 @@ class ViewManagerTransaction { // service. virtual void DoActionCompleted(bool success) = 0; - IViewManager* service() { return synchronizer_->service_; } + ViewManagerService* service() { return synchronizer_->service_; } Id GetAndAdvanceNextServerChangeId() { return synchronizer_->next_server_change_id_++; @@ -669,13 +669,13 @@ void ViewManagerSynchronizer::OnConnectionEstablished() { } //////////////////////////////////////////////////////////////////////////////// -// ViewManagerSynchronizer, IViewManagerClient implementation: +// ViewManagerSynchronizer, ViewManagerClient implementation: void ViewManagerSynchronizer::OnViewManagerConnectionEstablished( ConnectionSpecificId connection_id, const String& creator_url, Id next_server_change_id, - Array<INodePtr> nodes) { + Array<NodeDataPtr> nodes) { connected_ = true; connection_id_ = connection_id; creator_url_ = TypeConverter<String, std::string>::ConvertFrom(creator_url); @@ -685,7 +685,7 @@ void ViewManagerSynchronizer::OnViewManagerConnectionEstablished( AddRoot(BuildNodeTree(this, nodes)); } -void ViewManagerSynchronizer::OnRootsAdded(Array<INodePtr> nodes) { +void ViewManagerSynchronizer::OnRootsAdded(Array<NodeDataPtr> nodes) { AddRoot(BuildNodeTree(this, nodes)); } @@ -707,7 +707,7 @@ void ViewManagerSynchronizer::OnNodeHierarchyChanged( Id new_parent_id, Id old_parent_id, Id server_change_id, - mojo::Array<INodePtr> nodes) { + mojo::Array<NodeDataPtr> nodes) { next_server_change_id_ = server_change_id + 1; BuildNodeTree(this, nodes); 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 index e9a90f4..4de6b6c 100644 --- a/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h +++ b/mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h @@ -25,7 +25,7 @@ class ViewManagerTransaction; // Manages the connection with the View Manager service. class ViewManagerSynchronizer : public ViewManager, - public InterfaceImpl<IViewManagerClient> { + public InterfaceImpl<ViewManagerClient> { public: explicit ViewManagerSynchronizer(ViewManagerDelegate* delegate); virtual ~ViewManagerSynchronizer(); @@ -94,13 +94,13 @@ class ViewManagerSynchronizer : public ViewManager, // Overridden from InterfaceImpl: virtual void OnConnectionEstablished() OVERRIDE; - // Overridden from IViewManagerClient: + // Overridden from ViewManagerClient: virtual void OnViewManagerConnectionEstablished( ConnectionSpecificId connection_id, const String& creator_url, Id next_server_change_id, - Array<INodePtr> nodes) OVERRIDE; - virtual void OnRootsAdded(Array<INodePtr> nodes) OVERRIDE; + Array<NodeDataPtr> nodes) OVERRIDE; + virtual void OnRootsAdded(Array<NodeDataPtr> nodes) OVERRIDE; virtual void OnServerChangeIdAdvanced(Id next_server_change_id) OVERRIDE; virtual void OnNodeBoundsChanged(Id node_id, RectPtr old_bounds, @@ -109,7 +109,7 @@ class ViewManagerSynchronizer : public ViewManager, Id new_parent_id, Id old_parent_id, Id server_change_id, - Array<INodePtr> nodes) OVERRIDE; + Array<NodeDataPtr> nodes) OVERRIDE; virtual void OnNodeReordered(Id node_id, Id relative_node_id, OrderDirection direction, @@ -152,7 +152,7 @@ class ViewManagerSynchronizer : public ViewManager, IdToNodeMap nodes_; IdToViewMap views_; - IViewManager* service_; + ViewManagerService* service_; DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer); }; diff --git a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc index 1527cd5..f526879 100644 --- a/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc +++ b/mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc @@ -385,7 +385,8 @@ class ViewManagerTest : public testing::Test { *result_cache = result; } - bool EmbedRoot(IViewManagerInit* view_manager_init, const std::string& url) { + bool EmbedRoot(ViewManagerInitService* view_manager_init, + const std::string& url) { bool result = false; view_manager_init->EmbedRoot( url, @@ -411,7 +412,7 @@ class ViewManagerTest : public testing::Test { base::MessageLoop loop_; base::RunLoop* connect_loop_; shell::ShellTestHelper test_helper_; - IViewManagerInitPtr view_manager_init_; + ViewManagerInitServicePtr view_manager_init_; // Used to receive the most recent view manager loaded by an embed action. ViewManager* loaded_view_manager_; // The View Manager connection held by the window manager (app running at the diff --git a/mojo/services/public/interfaces/view_manager/view_manager.mojom b/mojo/services/public/interfaces/view_manager/view_manager.mojom index 303fb03..2440dc6 100644 --- a/mojo/services/public/interfaces/view_manager/view_manager.mojom +++ b/mojo/services/public/interfaces/view_manager/view_manager.mojom @@ -8,17 +8,17 @@ import "view_manager_constants.mojom" module mojo.view_manager { -struct INode { +struct NodeData { uint32 parent_id; uint32 node_id; uint32 view_id; mojo.Rect bounds; }; -// IViewManagerInit is responsible for launching the client that controls the -// root node. mojo::view_manager returns an instance of this. All other +// ViewManagerInitService is responsible for launching the client that controls +// the root node. mojo::view_manager returns an instance of this. All other // connections are established by the client this creates. -interface IViewManagerInit { +interface ViewManagerInitService { EmbedRoot(string url) => (bool success); }; @@ -32,8 +32,8 @@ interface IViewManagerInit { // connection id, and the lower 16 the id assigned by the client. // // The root node is identified with a connection id of 0, and value of 1. -[Client=IViewManagerClient] -interface IViewManager { +[Client=ViewManagerClient] +interface ViewManagerService { // 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). // Additionally the connection id (embedded in |node_id|) must match that of @@ -86,7 +86,7 @@ interface IViewManager { // the first result in the return value, unless |node_id| is invalid, in which // case an empty vector is returned. The nodes are visited using a depth first // search (pre-order). - GetNodeTree(uint32 node_id) => (INode[] nodes); + GetNodeTree(uint32 node_id) => (NodeData[] nodes); // Creates a new view 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). @@ -111,11 +111,11 @@ interface IViewManager { // Embeds the app at |url| in the specified nodes. More specifically this // creates a new connection to the specified url, expecting to get an - // IViewManagerClient and configures it with the root nodes |nodes|. Fails + // ViewManagerClient and configures it with the root nodes |nodes|. Fails // if |nodes| is empty or contains nodes that were not created by this // connection. // If a particular client invokes Embed() multiple times with the same url, - // the connection is reused. When this happens the IViewManagerClient is + // the connection is reused. When this happens the ViewManagerClient is // notified of the additional roots by way of OnRootsAdded(). Embed(string url, uint32[] nodes) => (bool success); }; @@ -123,8 +123,8 @@ interface IViewManager { // Changes to nodes/views are not sent to the connection that originated the // change. For example, if connection 1 attaches a view to a node (SetView()) // connection 1 does not receive OnNodeViewReplaced(). -[Client=IViewManager] -interface IViewManagerClient { +[Client=ViewManagerService] +interface ViewManagerClient { // Invoked once the connection has been established. |connection_id| is the id // that uniquely identifies this connection. |next_server_change_id| is the // id of the next change the server is expecting. |nodes| are the nodes @@ -132,11 +132,11 @@ interface IViewManagerClient { OnViewManagerConnectionEstablished(uint16 connection_id, string creator_url, uint32 next_server_change_id, - INode[] nodes); + NodeData[] nodes); - // See description of IViewManager::Connect() for details as to when this is - // invoked. - OnRootsAdded(INode[] nodes); + // See description of ViewManagerService::Connect() for details as to when + // this is invoked. + OnRootsAdded(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 @@ -159,7 +159,7 @@ interface IViewManagerClient { uint32 new_parent, uint32 old_parent, uint32 server_change_id, - INode[] nodes); + NodeData[] nodes); // Invoked when the order of nodes within a parent changes. OnNodeReordered(uint32 node_id, diff --git a/mojo/services/view_manager/DEPS b/mojo/services/view_manager/DEPS index e900e00..e6f1501 100644 --- a/mojo/services/view_manager/DEPS +++ b/mojo/services/view_manager/DEPS @@ -16,7 +16,7 @@ include_rules = [ ] specific_include_rules = { - "view_manager_connection_unittest.cc": [ + "view_manager_unittest.cc": [ "+mojo/service_manager/service_manager.h", ], } diff --git a/mojo/services/view_manager/main.cc b/mojo/services/view_manager/main.cc index baa8d82..de0a768 100644 --- a/mojo/services/view_manager/main.cc +++ b/mojo/services/view_manager/main.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "mojo/public/cpp/application/application.h" -#include "mojo/services/view_manager/view_manager_init_connection.h" +#include "mojo/services/view_manager/view_manager_init_service_impl.h" namespace mojo { namespace view_manager { @@ -17,7 +17,7 @@ class ViewManagerApp : public Application { virtual void Initialize() MOJO_OVERRIDE { // TODO(sky): this needs some sort of authentication as well as making sure // we only ever have one active at a time. - AddService<ViewManagerInitConnection>(service_provider()); + AddService<ViewManagerInitServiceImpl>(service_provider()); } private: diff --git a/mojo/services/view_manager/root_node_manager.cc b/mojo/services/view_manager/root_node_manager.cc index 0d87d38..a3cb62a 100644 --- a/mojo/services/view_manager/root_node_manager.cc +++ b/mojo/services/view_manager/root_node_manager.cc @@ -7,7 +7,7 @@ #include "base/logging.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/view_manager/view.h" -#include "mojo/services/view_manager/view_manager_connection.h" +#include "mojo/services/view_manager/view_manager_service_impl.h" #include "ui/aura/env.h" namespace mojo { @@ -15,7 +15,7 @@ namespace view_manager { namespace service { RootNodeManager::ScopedChange::ScopedChange( - ViewManagerConnection* connection, + ViewManagerServiceImpl* connection, RootNodeManager* root, RootNodeManager::ChangeType change_type, bool is_delete_node) @@ -62,19 +62,19 @@ ConnectionSpecificId RootNodeManager::GetAndAdvanceNextConnectionId() { return id; } -void RootNodeManager::AddConnection(ViewManagerConnection* connection) { +void RootNodeManager::AddConnection(ViewManagerServiceImpl* connection) { DCHECK_EQ(0u, connection_map_.count(connection->id())); connection_map_[connection->id()] = connection; } -void RootNodeManager::RemoveConnection(ViewManagerConnection* connection) { +void RootNodeManager::RemoveConnection(ViewManagerServiceImpl* connection) { connection_map_.erase(connection->id()); connections_created_by_connect_.erase(connection); // Notify remaining connections so that they can cleanup. for (ConnectionMap::const_iterator i = connection_map_.begin(); i != connection_map_.end(); ++i) { - i->second->OnViewManagerConnectionDestroyed(connection->id()); + i->second->OnViewManagerServiceImplDestroyed(connection->id()); } } @@ -91,7 +91,7 @@ void RootNodeManager::Embed(ConnectionSpecificId creator_id, EmbedImpl(creator_id, url, node_ids)->set_delete_on_connection_error(); } -ViewManagerConnection* RootNodeManager::GetConnection( +ViewManagerServiceImpl* RootNodeManager::GetConnection( ConnectionSpecificId connection_id) { ConnectionMap::iterator i = connection_map_.find(connection_id); return i == connection_map_.end() ? NULL : i->second; @@ -119,7 +119,7 @@ bool RootNodeManager::DidConnectionMessageClient( return current_change_ && current_change_->DidMessageConnection(id); } -ViewManagerConnection* RootNodeManager::GetConnectionByCreator( +ViewManagerServiceImpl* RootNodeManager::GetConnectionByCreator( ConnectionSpecificId creator_id, const std::string& url) const { for (ConnectionMap::const_iterator i = connection_map_.begin(); @@ -201,14 +201,14 @@ void RootNodeManager::FinishChange() { current_change_ = NULL; } -ViewManagerConnection* RootNodeManager::EmbedImpl( +ViewManagerServiceImpl* RootNodeManager::EmbedImpl( const ConnectionSpecificId creator_id, const String& url, const Array<Id>& node_ids) { MessagePipe pipe; service_provider_->ConnectToService( url, - ViewManagerConnection::Client::Name_, + ViewManagerServiceImpl::Client::Name_, pipe.handle1.Pass(), String()); @@ -217,8 +217,8 @@ ViewManagerConnection* RootNodeManager::EmbedImpl( if (it != connection_map_.end()) creator_url = it->second->url(); - ViewManagerConnection* connection = - new ViewManagerConnection(this, + ViewManagerServiceImpl* connection = + new ViewManagerServiceImpl(this, creator_id, creator_url, url.To<std::string>()); diff --git a/mojo/services/view_manager/root_node_manager.h b/mojo/services/view_manager/root_node_manager.h index 5ade95a..35415bb 100644 --- a/mojo/services/view_manager/root_node_manager.h +++ b/mojo/services/view_manager/root_node_manager.h @@ -29,10 +29,10 @@ namespace service { class RootViewManagerDelegate; class View; -class ViewManagerConnection; +class ViewManagerServiceImpl; -// RootNodeManager is responsible for managing the set of ViewManagerConnections -// as well as providing the root of the node hierarchy. +// RootNodeManager is responsible for managing the set of +// ViewManagerServiceImpls as well as providing the root of the node hierarchy. class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { public: // Used to indicate if the server id should be incremented after notifiying @@ -42,11 +42,11 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, }; - // Create when a ViewManagerConnection 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. class ScopedChange { public: - ScopedChange(ViewManagerConnection* connection, + ScopedChange(ViewManagerServiceImpl* connection, RootNodeManager* root, RootNodeManager::ChangeType change_type, bool is_delete_node); @@ -82,28 +82,28 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { RootViewManagerDelegate* view_manager_delegate); virtual ~RootNodeManager(); - // Returns the id for the next ViewManagerConnection. + // Returns the id for the next ViewManagerServiceImpl. ConnectionSpecificId GetAndAdvanceNextConnectionId(); Id next_server_change_id() const { return next_server_change_id_; } - void AddConnection(ViewManagerConnection* connection); - void RemoveConnection(ViewManagerConnection* connection); + void AddConnection(ViewManagerServiceImpl* connection); + void RemoveConnection(ViewManagerServiceImpl* connection); // Establishes the initial client. Similar to Connect(), but the resulting // client is allowed to do anything. void EmbedRoot(const std::string& url); - // See description of IViewManager::Embed() for details. This assumes + // See description of ViewManagerService::Embed() for details. This assumes // |node_ids| has been validated. void Embed(ConnectionSpecificId creator_id, const String& url, const Array<Id>& node_ids); // Returns the connection by id. - ViewManagerConnection* GetConnection(ConnectionSpecificId connection_id); + ViewManagerServiceImpl* GetConnection(ConnectionSpecificId connection_id); // Returns the Node identified by |id|. Node* GetNode(const NodeId& id); @@ -125,11 +125,11 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { // Returns true if OnConnectionMessagedClient() was invoked for id. bool DidConnectionMessageClient(ConnectionSpecificId id) const; - ViewManagerConnection* GetConnectionByCreator( + ViewManagerServiceImpl* GetConnectionByCreator( ConnectionSpecificId creator_id, const std::string& url) const; - // These functions trivially delegate to all ViewManagerConnections, which in + // These functions trivially delegate to all ViewManagerServiceImpls, which in // term notify their clients. void ProcessNodeBoundsChanged(const Node* node, const gfx::Rect& old_bounds, @@ -153,7 +153,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { ~Context(); }; - typedef std::map<ConnectionSpecificId, ViewManagerConnection*> ConnectionMap; + typedef std::map<ConnectionSpecificId, ViewManagerServiceImpl*> ConnectionMap; // Invoked when a connection is about to make a change. Subsequently followed // by FinishChange() once the change is done. @@ -172,7 +172,7 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { } // Implementation of the two embed variants. - ViewManagerConnection* EmbedImpl(ConnectionSpecificId creator_id, + ViewManagerServiceImpl* EmbedImpl(ConnectionSpecificId creator_id, const String& url, const Array<Id>& node_ids); @@ -190,12 +190,12 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { ServiceProvider* service_provider_; - // ID to use for next ViewManagerConnection. + // ID to use for next ViewManagerServiceImpl. ConnectionSpecificId next_connection_id_; Id next_server_change_id_; - // Set of ViewManagerConnections. + // Set of ViewManagerServiceImpls. ConnectionMap connection_map_; RootViewManager root_view_manager_; @@ -203,12 +203,12 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { // Root node. Node root_; - // Set of ViewManagerConnections created by way of Connect(). These have to be - // explicitly destroyed. - std::set<ViewManagerConnection*> connections_created_by_connect_; + // Set of ViewManagerServiceImpls created by way of Connect(). These have to + // be explicitly destroyed. + std::set<ViewManagerServiceImpl*> connections_created_by_connect_; // If non-null we're processing a change. The ScopedChange is not owned by us - // (it's created on the stack by ViewManagerConnection). + // (it's created on the stack by ViewManagerServiceImpl). ScopedChange* current_change_; DISALLOW_COPY_AND_ASSIGN(RootNodeManager); diff --git a/mojo/services/view_manager/test_change_tracker.cc b/mojo/services/view_manager/test_change_tracker.cc index 4260edd..192e093 100644 --- a/mojo/services/view_manager/test_change_tracker.cc +++ b/mojo/services/view_manager/test_change_tracker.cc @@ -111,8 +111,8 @@ std::string ChangeNodeDescription(const std::vector<Change>& changes) { return JoinString(node_strings, ','); } -void INodesToTestNodes(const Array<INodePtr>& data, - std::vector<TestNode>* test_nodes) { +void NodeDatasToTestNodes(const Array<NodeDataPtr>& data, + std::vector<TestNode>* test_nodes) { for (size_t i = 0; i < data.size(); ++i) { TestNode node; node.parent_id = data[i]->parent_id; @@ -148,20 +148,20 @@ void TestChangeTracker::OnViewManagerConnectionEstablished( ConnectionSpecificId connection_id, const String& creator_url, Id next_server_change_id, - Array<INodePtr> nodes) { + Array<NodeDataPtr> nodes) { Change change; change.type = CHANGE_TYPE_CONNECTION_ESTABLISHED; change.connection_id = connection_id; change.change_id = next_server_change_id; change.creator_url = creator_url; - INodesToTestNodes(nodes, &change.nodes); + NodeDatasToTestNodes(nodes, &change.nodes); AddChange(change); } -void TestChangeTracker::OnRootsAdded(Array<INodePtr> nodes) { +void TestChangeTracker::OnRootsAdded(Array<NodeDataPtr> nodes) { Change change; change.type = CHANGE_TYPE_ROOTS_ADDED; - INodesToTestNodes(nodes, &change.nodes); + NodeDatasToTestNodes(nodes, &change.nodes); AddChange(change); } @@ -187,14 +187,14 @@ void TestChangeTracker::OnNodeHierarchyChanged(Id node_id, Id new_parent_id, Id old_parent_id, Id server_change_id, - Array<INodePtr> nodes) { + Array<NodeDataPtr> nodes) { Change change; change.type = CHANGE_TYPE_NODE_HIERARCHY_CHANGED; change.node_id = node_id; change.node_id2 = new_parent_id; change.node_id3 = old_parent_id; change.change_id = server_change_id; - INodesToTestNodes(nodes, &change.nodes); + NodeDatasToTestNodes(nodes, &change.nodes); AddChange(change); } diff --git a/mojo/services/view_manager/test_change_tracker.h b/mojo/services/view_manager/test_change_tracker.h index fbea61d..4896f84 100644 --- a/mojo/services/view_manager/test_change_tracker.h +++ b/mojo/services/view_manager/test_change_tracker.h @@ -30,6 +30,7 @@ enum ChangeType { CHANGE_TYPE_INPUT_EVENT, }; +// TODO(sky): consider nuking and converting directly to NodeData. struct TestNode { // Returns a string description of this. std::string ToString() const; @@ -39,7 +40,7 @@ struct TestNode { Id view_id; }; -// Tracks a call to IViewManagerClient. See the individual functions for the +// Tracks a call to ViewManagerClient. See the individual functions for the // fields that are used. struct Change { Change(); @@ -69,16 +70,16 @@ std::vector<std::string> ChangesToDescription1( // if change.size() != 1. std::string ChangeNodeDescription(const std::vector<Change>& changes); -// Converts INodes to TestNodes. -void INodesToTestNodes(const Array<INodePtr>& data, - std::vector<TestNode>* test_nodes); +// Converts NodeDatas to TestNodes. +void NodeDatasToTestNodes(const Array<NodeDataPtr>& data, + std::vector<TestNode>* test_nodes); -// TestChangeTracker is used to record IViewManagerClient functions. It notifies +// TestChangeTracker is used to record ViewManagerClient functions. It notifies // a delegate any time a change is added. class TestChangeTracker { public: // Used to notify the delegate when a change is added. A change corresponds to - // a single IViewManagerClient function. + // a single ViewManagerClient function. class Delegate { public: virtual void OnChangeAdded() = 0; @@ -95,19 +96,19 @@ class TestChangeTracker { std::vector<Change>* changes() { return &changes_; } // Each of these functions generate a Change. There is one per - // IViewManagerClient function. + // ViewManagerClient function. void OnViewManagerConnectionEstablished(ConnectionSpecificId connection_id, const String& creator_url, Id next_server_change_id, - Array<INodePtr> nodes); - void OnRootsAdded(Array<INodePtr> nodes); + Array<NodeDataPtr> nodes); + void OnRootsAdded(Array<NodeDataPtr> nodes); void OnServerChangeIdAdvanced(Id change_id); void OnNodeBoundsChanged(Id node_id, RectPtr old_bounds, RectPtr new_bounds); void OnNodeHierarchyChanged(Id node_id, Id new_parent_id, Id old_parent_id, Id server_change_id, - Array<INodePtr> nodes); + Array<NodeDataPtr> nodes); void OnNodeReordered(Id node_id, Id relative_node_id, OrderDirection direction, diff --git a/mojo/services/view_manager/view_manager_init_connection.cc b/mojo/services/view_manager/view_manager_init_service_impl.cc index 5c529a1..be2ce15 100644 --- a/mojo/services/view_manager/view_manager_init_connection.cc +++ b/mojo/services/view_manager/view_manager_init_service_impl.cc @@ -2,31 +2,31 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/services/view_manager/view_manager_init_connection.h" +#include "mojo/services/view_manager/view_manager_init_service_impl.h" #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" #include "mojo/services/view_manager/ids.h" -#include "mojo/services/view_manager/view_manager_connection.h" +#include "mojo/services/view_manager/view_manager_service_impl.h" namespace mojo { namespace view_manager { namespace service { -ViewManagerInitConnection::ConnectParams::ConnectParams() {} +ViewManagerInitServiceImpl::ConnectParams::ConnectParams() {} -ViewManagerInitConnection::ConnectParams::~ConnectParams() {} +ViewManagerInitServiceImpl::ConnectParams::~ConnectParams() {} -ViewManagerInitConnection::ViewManagerInitConnection( +ViewManagerInitServiceImpl::ViewManagerInitServiceImpl( ServiceProvider* service_provider) : service_provider_(service_provider), root_node_manager_(service_provider, this), is_tree_host_ready_(false) { } -ViewManagerInitConnection::~ViewManagerInitConnection() { +ViewManagerInitServiceImpl::~ViewManagerInitServiceImpl() { } -void ViewManagerInitConnection::MaybeEmbedRoot( +void ViewManagerInitServiceImpl::MaybeEmbedRoot( const std::string& url, const Callback<void(bool)>& callback) { if (!is_tree_host_ready_) @@ -36,7 +36,7 @@ void ViewManagerInitConnection::MaybeEmbedRoot( callback.Run(true); } -void ViewManagerInitConnection::EmbedRoot( +void ViewManagerInitServiceImpl::EmbedRoot( const String& url, const Callback<void(bool)>& callback) { if (connect_params_.get()) { @@ -50,7 +50,7 @@ void ViewManagerInitConnection::EmbedRoot( MaybeEmbedRoot(url.To<std::string>(), callback); } -void ViewManagerInitConnection::OnRootViewManagerWindowTreeHostCreated() { +void ViewManagerInitServiceImpl::OnRootViewManagerWindowTreeHostCreated() { DCHECK(!is_tree_host_ready_); is_tree_host_ready_ = true; if (connect_params_.get()) diff --git a/mojo/services/view_manager/view_manager_init_connection.h b/mojo/services/view_manager/view_manager_init_service_impl.h index 6dce991..59d438e 100644 --- a/mojo/services/view_manager/view_manager_init_connection.h +++ b/mojo/services/view_manager/view_manager_init_service_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_CONNECTION_H_ -#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_CONNECTION_H_ +#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_IMPL_H_ +#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_IMPL_H_ #include <string> @@ -28,14 +28,14 @@ namespace service { #pragma warning(disable : 4275) #endif -// Used to create the initial IViewManagerClient. Doesn't initiate the Connect() +// Used to create the initial ViewManagerClient. Doesn't initiate the Connect() // until the WindowTreeHost has been created. -class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitConnection - : public InterfaceImpl<IViewManagerInit>, +class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceImpl + : public InterfaceImpl<ViewManagerInitService>, public RootViewManagerDelegate { public: - explicit ViewManagerInitConnection(ServiceProvider* service_provider); - virtual ~ViewManagerInitConnection(); + explicit ViewManagerInitServiceImpl(ServiceProvider* service_provider); + virtual ~ViewManagerInitServiceImpl(); private: struct ConnectParams { @@ -49,7 +49,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitConnection void MaybeEmbedRoot(const std::string& url, const Callback<void(bool)>& callback); - // IViewManagerInit overrides: + // ViewManagerInitService overrides: virtual void EmbedRoot(const String& url, const Callback<void(bool)>& callback) OVERRIDE; @@ -65,7 +65,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitConnection bool is_tree_host_ready_; - DISALLOW_COPY_AND_ASSIGN(ViewManagerInitConnection); + DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceImpl); }; #if defined(OS_WIN) @@ -76,4 +76,4 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitConnection } // namespace view_manager } // namespace mojo -#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_CONNECTION_H_ +#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_IMPL_H_ diff --git a/mojo/services/view_manager/view_manager_connection.cc b/mojo/services/view_manager/view_manager_service_impl.cc index 0d717ab..f98a9e5 100644 --- a/mojo/services/view_manager/view_manager_connection.cc +++ b/mojo/services/view_manager/view_manager_service_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "mojo/services/view_manager/view_manager_connection.h" +#include "mojo/services/view_manager/view_manager_service_impl.h" #include "base/bind.h" #include "base/stl_util.h" @@ -34,10 +34,11 @@ void GetDescendants(const Node* node, std::vector<const Node*>* nodes) { } // namespace -ViewManagerConnection::ViewManagerConnection(RootNodeManager* root_node_manager, - ConnectionSpecificId creator_id, - const std::string& creator_url, - const std::string& url) +ViewManagerServiceImpl::ViewManagerServiceImpl( + RootNodeManager* root_node_manager, + ConnectionSpecificId creator_id, + const std::string& creator_url, + const std::string& url) : root_node_manager_(root_node_manager), id_(root_node_manager_->GetAndAdvanceNextConnectionId()), url_(url), @@ -46,7 +47,7 @@ ViewManagerConnection::ViewManagerConnection(RootNodeManager* root_node_manager, delete_on_connection_error_(false) { } -ViewManagerConnection::~ViewManagerConnection() { +ViewManagerServiceImpl::~ViewManagerServiceImpl() { // Delete any views we own. while (!view_map_.empty()) { bool result = DeleteViewImpl(this, view_map_.begin()->second->id()); @@ -79,7 +80,7 @@ ViewManagerConnection::~ViewManagerConnection() { root_node_manager_->RemoveConnection(this); } -const Node* ViewManagerConnection::GetNode(const NodeId& id) const { +const Node* ViewManagerServiceImpl::GetNode(const NodeId& id) const { if (id_ == id.connection_id) { NodeMap::const_iterator i = node_map_.find(id.node_id); return i == node_map_.end() ? NULL : i->second; @@ -87,7 +88,7 @@ const Node* ViewManagerConnection::GetNode(const NodeId& id) const { return root_node_manager_->GetNode(id); } -const View* ViewManagerConnection::GetView(const ViewId& id) const { +const View* ViewManagerServiceImpl::GetView(const ViewId& id) const { if (id_ == id.connection_id) { ViewMap::const_iterator i = view_map_.find(id.view_id); return i == view_map_.end() ? NULL : i->second; @@ -95,7 +96,7 @@ const View* ViewManagerConnection::GetView(const ViewId& id) const { return root_node_manager_->GetView(id); } -void ViewManagerConnection::SetRoots(const Array<Id>& node_ids) { +void ViewManagerServiceImpl::SetRoots(const Array<Id>& node_ids) { DCHECK(roots_.empty()); NodeIdSet roots; for (size_t i = 0; i < node_ids.size(); ++i) { @@ -105,13 +106,13 @@ void ViewManagerConnection::SetRoots(const Array<Id>& node_ids) { roots_.swap(roots); } -void ViewManagerConnection::OnViewManagerConnectionDestroyed( +void ViewManagerServiceImpl::OnViewManagerServiceImplDestroyed( ConnectionSpecificId id) { if (creator_id_ == id) creator_id_ = kRootConnection; } -void ViewManagerConnection::ProcessNodeBoundsChanged( +void ViewManagerServiceImpl::ProcessNodeBoundsChanged( const Node* node, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds, @@ -126,7 +127,7 @@ void ViewManagerConnection::ProcessNodeBoundsChanged( } } -void ViewManagerConnection::ProcessNodeHierarchyChanged( +void ViewManagerServiceImpl::ProcessNodeHierarchyChanged( const Node* node, const Node* new_parent, const Node* old_parent, @@ -167,14 +168,14 @@ void ViewManagerConnection::ProcessNodeHierarchyChanged( NodeIdToTransportId(new_parent_id), NodeIdToTransportId(old_parent_id), server_change_id, - NodesToINodes(to_send)); + NodesToNodeDatas(to_send)); } -void ViewManagerConnection::ProcessNodeReorder(const Node* node, - const Node* relative_node, - OrderDirection direction, - Id server_change_id, - bool originated_change) { +void ViewManagerServiceImpl::ProcessNodeReorder(const Node* node, + const Node* relative_node, + OrderDirection direction, + Id server_change_id, + bool originated_change) { if (originated_change || !known_nodes_.count(NodeIdToTransportId(node->id())) || !known_nodes_.count(NodeIdToTransportId(relative_node->id()))) { @@ -187,7 +188,7 @@ void ViewManagerConnection::ProcessNodeReorder(const Node* node, server_change_id); } -void ViewManagerConnection::ProcessNodeViewReplaced( +void ViewManagerServiceImpl::ProcessNodeViewReplaced( const Node* node, const View* new_view, const View* old_view, @@ -202,9 +203,9 @@ void ViewManagerConnection::ProcessNodeViewReplaced( new_view_id, old_view_id); } -void ViewManagerConnection::ProcessNodeDeleted(const NodeId& node, - Id server_change_id, - bool originated_change) { +void ViewManagerServiceImpl::ProcessNodeDeleted(const NodeId& node, + Id server_change_id, + bool originated_change) { const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0; const bool in_roots = roots_.erase(NodeIdToTransportId(node)) > 0; @@ -225,15 +226,15 @@ void ViewManagerConnection::ProcessNodeDeleted(const NodeId& node, } } -void ViewManagerConnection::ProcessViewDeleted(const ViewId& view, - bool originated_change) { +void ViewManagerServiceImpl::ProcessViewDeleted(const ViewId& view, + bool originated_change) { if (originated_change) return; client()->OnViewDeleted(ViewIdToTransportId(view)); } -void ViewManagerConnection::ProcessViewInputEvent(const View* view, - const ui::Event* event) { +void ViewManagerServiceImpl::ProcessViewInputEvent(const View* view, + const ui::Event* event) { DCHECK_EQ(id_, view->id().connection_id); client()->OnViewInputEvent( ViewIdToTransportId(view->id()), @@ -241,12 +242,12 @@ void ViewManagerConnection::ProcessViewInputEvent(const View* view, base::Bind(&base::DoNothing)); } -void ViewManagerConnection::OnConnectionError() { +void ViewManagerServiceImpl::OnConnectionError() { if (delete_on_connection_error_) delete this; } -bool ViewManagerConnection::CanRemoveNodeFromParent(const Node* node) const { +bool ViewManagerServiceImpl::CanRemoveNodeFromParent(const Node* node) const { if (!node) return false; @@ -265,8 +266,8 @@ bool ViewManagerConnection::CanRemoveNodeFromParent(const Node* node) const { parent->id().connection_id == id_))); } -bool ViewManagerConnection::CanAddNode(const Node* parent, - const Node* child) const { +bool ViewManagerServiceImpl::CanAddNode(const Node* parent, + const Node* child) const { if (!parent || !child) return false; // Both nodes must be valid. @@ -284,9 +285,9 @@ bool ViewManagerConnection::CanAddNode(const Node* parent, return (IsNodeDescendantOfRoots(child) || child->id().connection_id == id_); } -bool ViewManagerConnection::CanReorderNode(const Node* node, - const Node* relative_node, - OrderDirection direction) const { +bool ViewManagerServiceImpl::CanReorderNode(const Node* node, + const Node* relative_node, + OrderDirection direction) const { if (!node || !relative_node) return false; @@ -314,16 +315,16 @@ bool ViewManagerConnection::CanReorderNode(const Node* node, return true; } -bool ViewManagerConnection::CanDeleteNode(const NodeId& node_id) const { +bool ViewManagerServiceImpl::CanDeleteNode(const NodeId& node_id) const { return node_id.connection_id == id_; } -bool ViewManagerConnection::CanDeleteView(const ViewId& view_id) const { +bool ViewManagerServiceImpl::CanDeleteView(const ViewId& view_id) const { return view_id.connection_id == id_; } -bool ViewManagerConnection::CanSetView(const Node* node, - const ViewId& view_id) const { +bool ViewManagerServiceImpl::CanSetView(const Node* node, + const ViewId& view_id) const { if (!node || !IsNodeDescendantOfRoots(node)) return false; @@ -331,17 +332,17 @@ bool ViewManagerConnection::CanSetView(const Node* node, return (view && view_id.connection_id == id_) || view_id == ViewId(); } -bool ViewManagerConnection::CanSetFocus(const Node* node) const { +bool ViewManagerServiceImpl::CanSetFocus(const Node* node) const { // TODO(beng): security. return true; } -bool ViewManagerConnection::CanGetNodeTree(const Node* node) const { +bool ViewManagerServiceImpl::CanGetNodeTree(const Node* node) const { return node && (IsNodeDescendantOfRoots(node) || node->id().connection_id == id_); } -bool ViewManagerConnection::CanEmbed( +bool ViewManagerServiceImpl::CanEmbed( const mojo::Array<uint32_t>& node_ids) const { for (size_t i = 0; i < node_ids.size(); ++i) { const Node* node = GetNode(NodeIdFromTransportId(node_ids[i])); @@ -351,8 +352,8 @@ bool ViewManagerConnection::CanEmbed( return node_ids.size() > 0; } -bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source, - const NodeId& node_id) { +bool ViewManagerServiceImpl::DeleteNodeImpl(ViewManagerServiceImpl* source, + const NodeId& node_id) { DCHECK_EQ(node_id.connection_id, id_); Node* node = GetNode(node_id); if (!node) @@ -373,8 +374,8 @@ bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source, return true; } -bool ViewManagerConnection::DeleteViewImpl(ViewManagerConnection* source, - const ViewId& view_id) { +bool ViewManagerServiceImpl::DeleteViewImpl(ViewManagerServiceImpl* source, + const ViewId& view_id) { DCHECK_EQ(view_id.connection_id, id_); View* view = GetView(view_id); if (!view) @@ -393,7 +394,7 @@ bool ViewManagerConnection::DeleteViewImpl(ViewManagerConnection* source, return true; } -bool ViewManagerConnection::SetViewImpl(Node* node, const ViewId& view_id) { +bool ViewManagerServiceImpl::SetViewImpl(Node* node, const ViewId& view_id) { DCHECK(node); // CanSetView() should have verified node exists. View* view = GetView(view_id); RootNodeManager::ScopedChange change( @@ -408,7 +409,7 @@ bool ViewManagerConnection::SetViewImpl(Node* node, const ViewId& view_id) { return true; } -void ViewManagerConnection::GetUnknownNodesFrom( +void ViewManagerServiceImpl::GetUnknownNodesFrom( const Node* node, std::vector<const Node*>* nodes) { const Id transport_id = NodeIdToTransportId(node->id()); @@ -421,7 +422,7 @@ void ViewManagerConnection::GetUnknownNodesFrom( GetUnknownNodesFrom(children[i], nodes); } -void ViewManagerConnection::RemoveFromKnown(const Node* node) { +void ViewManagerServiceImpl::RemoveFromKnown(const Node* node) { if (node->id().connection_id == id_) return; known_nodes_.erase(NodeIdToTransportId(node->id())); @@ -430,7 +431,7 @@ void ViewManagerConnection::RemoveFromKnown(const Node* node) { RemoveFromKnown(children[i]); } -bool ViewManagerConnection::AddRoots( +bool ViewManagerServiceImpl::AddRoots( const std::vector<Id>& node_ids) { std::vector<const Node*> to_send; bool did_add_root = false; @@ -455,11 +456,11 @@ bool ViewManagerConnection::AddRoots( if (!did_add_root) return false; - client()->OnRootsAdded(NodesToINodes(to_send)); + client()->OnRootsAdded(NodesToNodeDatas(to_send)); return true; } -bool ViewManagerConnection::IsNodeDescendantOfRoots(const Node* node) const { +bool ViewManagerServiceImpl::IsNodeDescendantOfRoots(const Node* node) const { if (roots_.empty()) return true; if (!node) @@ -477,7 +478,7 @@ bool ViewManagerConnection::IsNodeDescendantOfRoots(const Node* node) const { return false; } -bool ViewManagerConnection::ShouldNotifyOnHierarchyChange( +bool ViewManagerServiceImpl::ShouldNotifyOnHierarchyChange( const Node* node, const Node** new_parent, const Node** old_parent, @@ -522,9 +523,9 @@ bool ViewManagerConnection::ShouldNotifyOnHierarchyChange( return known_nodes_.count(NodeIdToTransportId(node->id())) > 0; } -Array<INodePtr> ViewManagerConnection::NodesToINodes( +Array<NodeDataPtr> ViewManagerServiceImpl::NodesToNodeDatas( const std::vector<const Node*>& nodes) { - Array<INodePtr> array(nodes.size()); + Array<NodeDataPtr> array(nodes.size()); for (size_t i = 0; i < nodes.size(); ++i) { const Node* node = nodes[i]; DCHECK(known_nodes_.count(NodeIdToTransportId(node->id())) > 0); @@ -533,7 +534,7 @@ Array<INodePtr> ViewManagerConnection::NodesToINodes( // in roots), and should not be sent over. if (parent && known_nodes_.count(NodeIdToTransportId(parent->id())) == 0) parent = NULL; - INodePtr inode(INode::New()); + NodeDataPtr inode(NodeData::New()); inode->parent_id = NodeIdToTransportId(parent ? parent->id() : NodeId()); inode->node_id = NodeIdToTransportId(node->id()); inode->view_id = @@ -544,7 +545,7 @@ Array<INodePtr> ViewManagerConnection::NodesToINodes( return array.Pass(); } -void ViewManagerConnection::CreateNode( +void ViewManagerServiceImpl::CreateNode( Id transport_node_id, const Callback<void(bool)>& callback) { const NodeId node_id(NodeIdFromTransportId(transport_node_id)); @@ -558,20 +559,20 @@ void ViewManagerConnection::CreateNode( callback.Run(true); } -void ViewManagerConnection::DeleteNode( +void ViewManagerServiceImpl::DeleteNode( Id transport_node_id, const Callback<void(bool)>& callback) { const NodeId node_id(NodeIdFromTransportId(transport_node_id)); bool did_delete = CanDeleteNode(node_id); if (did_delete) { - ViewManagerConnection* connection = root_node_manager_->GetConnection( + ViewManagerServiceImpl* connection = root_node_manager_->GetConnection( node_id.connection_id); did_delete = connection && connection->DeleteNodeImpl(this, node_id); } callback.Run(did_delete); } -void ViewManagerConnection::AddNode( +void ViewManagerServiceImpl::AddNode( Id parent_id, Id child_id, Id server_change_id, @@ -591,7 +592,7 @@ void ViewManagerConnection::AddNode( callback.Run(success); } -void ViewManagerConnection::RemoveNodeFromParent( +void ViewManagerServiceImpl::RemoveNodeFromParent( Id node_id, Id server_change_id, const Callback<void(bool)>& callback) { @@ -609,11 +610,11 @@ void ViewManagerConnection::RemoveNodeFromParent( callback.Run(success); } -void ViewManagerConnection::ReorderNode(Id node_id, - Id relative_node_id, - OrderDirection direction, - Id server_change_id, - const Callback<void(bool)>& callback) { +void ViewManagerServiceImpl::ReorderNode(Id node_id, + Id relative_node_id, + OrderDirection direction, + Id server_change_id, + const Callback<void(bool)>& callback) { bool success = false; if (server_change_id == root_node_manager_->next_server_change_id()) { Node* node = GetNode(NodeIdFromTransportId(node_id)); @@ -630,9 +631,9 @@ void ViewManagerConnection::ReorderNode(Id node_id, callback.Run(success); } -void ViewManagerConnection::GetNodeTree( +void ViewManagerServiceImpl::GetNodeTree( Id node_id, - const Callback<void(Array<INodePtr>)>& callback) { + const Callback<void(Array<NodeDataPtr>)>& callback) { Node* node = GetNode(NodeIdFromTransportId(node_id)); std::vector<const Node*> nodes; if (CanGetNodeTree(node)) { @@ -640,10 +641,10 @@ void ViewManagerConnection::GetNodeTree( for (size_t i = 0; i < nodes.size(); ++i) known_nodes_.insert(NodeIdToTransportId(nodes[i]->id())); } - callback.Run(NodesToINodes(nodes)); + callback.Run(NodesToNodeDatas(nodes)); } -void ViewManagerConnection::CreateView( +void ViewManagerServiceImpl::CreateView( Id transport_view_id, const Callback<void(bool)>& callback) { const ViewId view_id(ViewIdFromTransportId(transport_view_id)); @@ -655,28 +656,28 @@ void ViewManagerConnection::CreateView( callback.Run(true); } -void ViewManagerConnection::DeleteView( +void ViewManagerServiceImpl::DeleteView( Id transport_view_id, const Callback<void(bool)>& callback) { const ViewId view_id(ViewIdFromTransportId(transport_view_id)); bool did_delete = CanDeleteView(view_id); if (did_delete) { - ViewManagerConnection* connection = root_node_manager_->GetConnection( + ViewManagerServiceImpl* connection = root_node_manager_->GetConnection( view_id.connection_id); did_delete = (connection && connection->DeleteViewImpl(this, view_id)); } callback.Run(did_delete); } -void ViewManagerConnection::SetView(Id transport_node_id, - Id transport_view_id, - const Callback<void(bool)>& callback) { +void ViewManagerServiceImpl::SetView(Id transport_node_id, + Id transport_view_id, + const Callback<void(bool)>& callback) { Node* node = GetNode(NodeIdFromTransportId(transport_node_id)); const ViewId view_id(ViewIdFromTransportId(transport_view_id)); callback.Run(CanSetView(node, view_id) && SetViewImpl(node, view_id)); } -void ViewManagerConnection::SetViewContents( +void ViewManagerServiceImpl::SetViewContents( Id view_id, ScopedSharedBufferHandle buffer, uint32_t buffer_size, @@ -700,8 +701,8 @@ void ViewManagerConnection::SetViewContents( callback.Run(true); } -void ViewManagerConnection::SetFocus(Id node_id, - const Callback<void(bool)> & callback) { +void ViewManagerServiceImpl::SetFocus(Id node_id, + const Callback<void(bool)> & callback) { bool success = false; Node* node = GetNode(NodeIdFromTransportId(node_id)); if (CanSetFocus(node)) { @@ -711,7 +712,7 @@ void ViewManagerConnection::SetFocus(Id node_id, callback.Run(success); } -void ViewManagerConnection::SetNodeBounds( +void ViewManagerServiceImpl::SetNodeBounds( Id node_id, RectPtr bounds, const Callback<void(bool)>& callback) { @@ -736,13 +737,13 @@ void ViewManagerConnection::SetNodeBounds( callback.Run(true); } -void ViewManagerConnection::Embed(const String& url, - Array<uint32_t> node_ids, - const Callback<void(bool)>& callback) { +void ViewManagerServiceImpl::Embed(const String& url, + Array<uint32_t> node_ids, + const Callback<void(bool)>& callback) { bool success = CanEmbed(node_ids); if (success) { // We may already have this connection, if so reuse it. - ViewManagerConnection* existing_connection = + ViewManagerServiceImpl* existing_connection = root_node_manager_->GetConnectionByCreator(id_, url.To<std::string>()); if (existing_connection) success = existing_connection->AddRoots(node_ids.storage()); @@ -752,27 +753,27 @@ void ViewManagerConnection::Embed(const String& url, callback.Run(success); } -void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node, - const Node* new_parent, - const Node* old_parent) { +void ViewManagerServiceImpl::OnNodeHierarchyChanged(const Node* node, + const Node* new_parent, + const Node* old_parent) { root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); } -void ViewManagerConnection::OnNodeViewReplaced(const Node* node, - const View* new_view, - const View* old_view) { +void ViewManagerServiceImpl::OnNodeViewReplaced(const Node* node, + const View* new_view, + const View* old_view) { root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); } -void ViewManagerConnection::OnViewInputEvent(const View* view, - const ui::Event* event) { - ViewManagerConnection* connection = root_node_manager_->GetConnection( +void ViewManagerServiceImpl::OnViewInputEvent(const View* view, + const ui::Event* event) { + ViewManagerServiceImpl* connection = root_node_manager_->GetConnection( view->id().connection_id); DCHECK(connection); connection->ProcessViewInputEvent(view, event); } -void ViewManagerConnection::OnConnectionEstablished() { +void ViewManagerServiceImpl::OnConnectionEstablished() { root_node_manager_->AddConnection(this); std::vector<const Node*> to_send; @@ -787,7 +788,7 @@ void ViewManagerConnection::OnConnectionEstablished() { id_, creator_url_, root_node_manager_->next_server_change_id(), - NodesToINodes(to_send)); + NodesToNodeDatas(to_send)); } } // namespace service diff --git a/mojo/services/view_manager/view_manager_connection.h b/mojo/services/view_manager/view_manager_service_impl.h index 01c8f35..140b87a 100644 --- a/mojo/services/view_manager/view_manager_connection.h +++ b/mojo/services/view_manager/view_manager_service_impl.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ -#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ +#ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ +#define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ #include <set> #include <string> @@ -37,18 +37,18 @@ class View; #endif // Manages a connection from the client. -class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection - : public InterfaceImpl<IViewManager>, +class MOJO_VIEW_MANAGER_EXPORT ViewManagerServiceImpl + : public InterfaceImpl<ViewManagerService>, public NodeDelegate { public: - ViewManagerConnection(RootNodeManager* root_node_manager, - ConnectionSpecificId creator_id, - const std::string& creator_url, - const std::string& url); - virtual ~ViewManagerConnection(); + ViewManagerServiceImpl(RootNodeManager* root_node_manager, + ConnectionSpecificId creator_id, + const std::string& creator_url, + const std::string& url); + virtual ~ViewManagerServiceImpl(); // Used to mark this connection as originating from a call to - // IViewManager::Connect(). When set OnConnectionError() deletes |this|. + // ViewManagerService::Connect(). When set OnConnectionError() deletes |this|. void set_delete_on_connection_error() { delete_on_connection_error_ = true; } ConnectionSpecificId id() const { return id_; } @@ -58,21 +58,21 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection // Returns the Node with the specified id. Node* GetNode(const NodeId& id) { return const_cast<Node*>( - const_cast<const ViewManagerConnection*>(this)->GetNode(id)); + const_cast<const ViewManagerServiceImpl*>(this)->GetNode(id)); } const Node* GetNode(const NodeId& id) const; // Returns the View with the specified id. View* GetView(const ViewId& id) { return const_cast<View*>( - const_cast<const ViewManagerConnection*>(this)->GetView(id)); + const_cast<const ViewManagerServiceImpl*>(this)->GetView(id)); } const View* GetView(const ViewId& id) const; void SetRoots(const Array<Id>& node_ids); // Invoked when a connection is destroyed. - void OnViewManagerConnectionDestroyed(ConnectionSpecificId id); + void OnViewManagerServiceImplDestroyed(ConnectionSpecificId id); // The following methods are invoked after the corresponding change has been // processed. They do the appropriate bookkeeping and update the client as @@ -127,11 +127,11 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection // Deletes a node owned by this connection. Returns true on success. |source| // is the connection that originated the change. - bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); + bool DeleteNodeImpl(ViewManagerServiceImpl* source, const NodeId& node_id); // Deletes a view owned by this connection. Returns true on success. |source| // is the connection that originated the change. - bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); + bool DeleteViewImpl(ViewManagerServiceImpl* source, const ViewId& view_id); // Sets the view associated with a node. bool SetViewImpl(Node* node, const ViewId& view_id); @@ -161,12 +161,12 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection const Node** old_parent, std::vector<const Node*>* to_send); - // Converts an array of Nodes to INodes. This assumes all the nodes are valid - // for the client. The parent of nodes the client is not allowed to see are - // set to NULL (in the returned INodes). - Array<INodePtr> NodesToINodes(const std::vector<const Node*>& nodes); + // Converts an array of Nodes to NodeDatas. This assumes all the nodes are + // valid for the client. The parent of nodes the client is not allowed to see + // are set to NULL (in the returned NodeDatas). + Array<NodeDataPtr> NodesToNodeDatas(const std::vector<const Node*>& nodes); - // Overridden from IViewManager: + // Overridden from ViewManagerService: virtual void CreateNode(Id transport_node_id, const Callback<void(bool)>& callback) OVERRIDE; virtual void DeleteNode(Id transport_node_id, @@ -186,7 +186,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection const Callback<void(bool)>& callback) OVERRIDE; virtual void GetNodeTree( Id node_id, - const Callback<void(Array<INodePtr>)>& callback) OVERRIDE; + const Callback<void(Array<NodeDataPtr>)>& callback) OVERRIDE; virtual void CreateView(Id transport_view_id, const Callback<void(bool)>& callback) OVERRIDE; virtual void DeleteView(Id transport_view_id, @@ -253,7 +253,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection // See description above setter. bool delete_on_connection_error_; - DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); + DISALLOW_COPY_AND_ASSIGN(ViewManagerServiceImpl); }; #if defined(OS_WIN) @@ -264,4 +264,4 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection } // namespace view_manager } // namespace mojo -#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ +#endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_SERVICE_IMPL_H_ diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_unittest.cc index e15fa06..7fe5234 100644 --- a/mojo/services/view_manager/view_manager_connection_unittest.cc +++ b/mojo/services/view_manager/view_manager_unittest.cc @@ -36,12 +36,13 @@ namespace { const char kTestServiceURL[] = "mojo:test_url"; -// ViewManagerProxy is a proxy to an IViewManager. It handles invoking -// IViewManager functions on the right thread in a synchronous manner (each -// IViewManager cover function blocks until the response from the IViewManager -// is returned). In addition it tracks the set of IViewManagerClient messages -// received by way of a vector of Changes. Use DoRunLoopUntilChangesCount() to -// wait for a certain number of messages to be received. +// ViewManagerProxy is a proxy to an ViewManagerService. It handles invoking +// ViewManagerService functions on the right thread in a synchronous manner +// (each ViewManagerService cover function blocks until the response from the +// ViewManagerService is returned). In addition it tracks the set of +// ViewManagerClient messages received by way of a vector of Changes. Use +// DoRunLoopUntilChangesCount() to wait for a certain number of messages to be +// received. class ViewManagerProxy : public TestChangeTracker::Delegate { public: explicit ViewManagerProxy(TestChangeTracker* tracker) @@ -84,8 +85,8 @@ class ViewManagerProxy : public TestChangeTracker::Delegate { router_->CloseMessagePipe(); } - // The following functions are cover methods for IViewManager. They block - // until the result is received. + // The following functions are cover methods for ViewManagerService. They + // block until the result is received. bool CreateNode(Id node_id) { changes_.clear(); bool result = false; @@ -194,7 +195,7 @@ class ViewManagerProxy : public TestChangeTracker::Delegate { void set_router(mojo::internal::Router* router) { router_ = router; } - void set_view_manager(IViewManager* view_manager) { + void set_view_manager(ViewManagerService* view_manager) { view_manager_ = view_manager; } @@ -228,15 +229,15 @@ class ViewManagerProxy : public TestChangeTracker::Delegate { main_run_loop_->Quit(); } - // Callbacks from the various IViewManager functions. + // Callbacks from the various ViewManagerService functions. void GotResult(bool* result_cache, bool result) { *result_cache = result; DCHECK(main_run_loop_); main_run_loop_->Quit(); } - void GotNodeTree(std::vector<TestNode>* nodes, Array<INodePtr> results) { - INodesToTestNodes(results, nodes); + void GotNodeTree(std::vector<TestNode>* nodes, Array<NodeDataPtr> results) { + NodeDatasToTestNodes(results, nodes); DCHECK(main_run_loop_); main_run_loop_->Quit(); } @@ -256,7 +257,7 @@ class ViewManagerProxy : public TestChangeTracker::Delegate { // MessageLoop of the test. base::MessageLoop* main_loop_; - IViewManager* view_manager_; + ViewManagerService* view_manager_; // Number of changes we're waiting on until we quit the current loop. size_t quit_count_; @@ -278,7 +279,7 @@ base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; bool ViewManagerProxy::in_embed_ = false; class TestViewManagerClientConnection - : public InterfaceImpl<IViewManagerClient> { + : public InterfaceImpl<ViewManagerClient> { public: TestViewManagerClientConnection() : connection_(&tracker_) { tracker_.set_delegate(&connection_); @@ -295,11 +296,11 @@ class TestViewManagerClientConnection ConnectionSpecificId connection_id, const String& creator_url, Id next_server_change_id, - Array<INodePtr> nodes) OVERRIDE { + Array<NodeDataPtr> nodes) OVERRIDE { tracker_.OnViewManagerConnectionEstablished( connection_id, creator_url, next_server_change_id, nodes.Pass()); } - virtual void OnRootsAdded(Array<INodePtr> nodes) OVERRIDE { + virtual void OnRootsAdded(Array<NodeDataPtr> nodes) OVERRIDE { tracker_.OnRootsAdded(nodes.Pass()); } virtual void OnServerChangeIdAdvanced( @@ -315,7 +316,7 @@ class TestViewManagerClientConnection Id new_parent, Id old_parent, Id server_change_id, - Array<INodePtr> nodes) OVERRIDE { + Array<NodeDataPtr> nodes) OVERRIDE { tracker_.OnNodeHierarchyChanged(node, new_parent, old_parent, server_change_id, nodes.Pass()); } @@ -350,8 +351,8 @@ class TestViewManagerClientConnection DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); }; -// Used with IViewManager::Embed(). Creates a TestViewManagerClientConnection, -// which creates and owns the ViewManagerProxy. +// Used with ViewManagerService::Embed(). Creates a +// TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. class EmbedServiceLoader : public ServiceLoader { public: EmbedServiceLoader() {} @@ -396,9 +397,10 @@ void EmbedRootCallback(bool* result_cache, run_loop->Quit(); } -// Resposible for establishing the initial IViewManager connection. Blocks until -// result is determined. -bool EmbedRoot(IViewManagerInit* view_manager_init, const std::string& url) { +// Resposible for establishing the initial ViewManagerService connection. Blocks +// until result is determined. +bool EmbedRoot(ViewManagerInitService* view_manager_init, + const std::string& url) { bool result = false; base::RunLoop run_loop; view_manager_init->EmbedRoot(url, base::Bind(&EmbedRootCallback, @@ -411,9 +413,9 @@ bool EmbedRoot(IViewManagerInit* view_manager_init, const std::string& url) { typedef std::vector<std::string> Changes; -class ViewManagerConnectionTest : public testing::Test { +class ViewManagerTest : public testing::Test { public: - ViewManagerConnectionTest() : connection_(NULL), connection2_(NULL) {} + ViewManagerTest() : connection_(NULL), connection2_(NULL) {} virtual void SetUp() OVERRIDE { test_helper_.Init(); @@ -477,16 +479,16 @@ class ViewManagerConnectionTest : public testing::Test { base::MessageLoop loop_; shell::ShellTestHelper test_helper_; - IViewManagerInitPtr view_manager_init_; + ViewManagerInitServicePtr view_manager_init_; ViewManagerProxy* connection_; ViewManagerProxy* connection2_; - DISALLOW_COPY_AND_ASSIGN(ViewManagerConnectionTest); + DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); }; // Verifies client gets a valid id. -TEST_F(ViewManagerConnectionTest, ValidId) { +TEST_F(ViewManagerTest, ValidId) { // TODO(beng): this should really have the URL of the application that // connected to ViewManagerInit. EXPECT_EQ("OnConnectionEstablished creator=", @@ -501,7 +503,7 @@ TEST_F(ViewManagerConnectionTest, ValidId) { } // Verifies two clients/connections get different ids. -TEST_F(ViewManagerConnectionTest, TwoClientsGetDifferentConnectionIds) { +TEST_F(ViewManagerTest, TwoClientsGetDifferentConnectionIds) { ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); EXPECT_EQ("OnConnectionEstablished creator=mojo:test_url", ChangesToDescription1(connection2_->changes())[0]); @@ -516,7 +518,7 @@ TEST_F(ViewManagerConnectionTest, TwoClientsGetDifferentConnectionIds) { } // Verifies client gets a valid id. -TEST_F(ViewManagerConnectionTest, CreateNode) { +TEST_F(ViewManagerTest, CreateNode) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); EXPECT_TRUE(connection_->changes().empty()); @@ -529,13 +531,13 @@ TEST_F(ViewManagerConnectionTest, CreateNode) { EXPECT_TRUE(connection_->changes().empty()); } -TEST_F(ViewManagerConnectionTest, CreateViewFailsWithBogusConnectionId) { +TEST_F(ViewManagerTest, CreateViewFailsWithBogusConnectionId) { EXPECT_FALSE(connection_->CreateView(BuildViewId(2, 1))); EXPECT_TRUE(connection_->changes().empty()); } // Verifies hierarchy changes. -TEST_F(ViewManagerConnectionTest, AddRemoveNotify) { +TEST_F(ViewManagerTest, AddRemoveNotify) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); @@ -565,7 +567,7 @@ TEST_F(ViewManagerConnectionTest, AddRemoveNotify) { } // Verifies AddNode fails when node is already in position. -TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) { +TEST_F(ViewManagerTest, AddNodeWithNoChange) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); @@ -588,7 +590,7 @@ TEST_F(ViewManagerConnectionTest, AddNodeWithNoChange) { } // Verifies AddNode fails when node is already in position. -TEST_F(ViewManagerConnectionTest, AddAncestorFails) { +TEST_F(ViewManagerTest, AddAncestorFails) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); @@ -610,7 +612,7 @@ TEST_F(ViewManagerConnectionTest, AddAncestorFails) { } // Verifies adding with an invalid id fails. -TEST_F(ViewManagerConnectionTest, AddWithInvalidServerId) { +TEST_F(ViewManagerTest, AddWithInvalidServerId) { // Create two nodes. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -620,7 +622,7 @@ TEST_F(ViewManagerConnectionTest, AddWithInvalidServerId) { } // Verifies adding to root sends right notifications. -TEST_F(ViewManagerConnectionTest, AddToRoot) { +TEST_F(ViewManagerTest, AddToRoot) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 21))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); @@ -650,7 +652,7 @@ TEST_F(ViewManagerConnectionTest, AddToRoot) { } // Verifies HierarchyChanged is correctly sent for various adds/removes. -TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) { +TEST_F(ViewManagerTest, NodeHierarchyChangedNodes) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 11))); // Make 11 a child of 2. @@ -733,7 +735,7 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedNodes) { } } -TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) { +TEST_F(ViewManagerTest, NodeHierarchyChangedAddingKnownToUnknown) { // Create the following structure: root -> 1 -> 11 and 2->21 (2 has no // parent). ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); @@ -780,7 +782,7 @@ TEST_F(ViewManagerConnectionTest, NodeHierarchyChangedAddingKnownToUnknown) { } } -TEST_F(ViewManagerConnectionTest, ReorderNode) { +TEST_F(ViewManagerTest, ReorderNode) { Id node1_id = BuildNodeId(1, 1); Id node2_id = BuildNodeId(1, 2); Id node3_id = BuildNodeId(1, 3); @@ -859,7 +861,7 @@ TEST_F(ViewManagerConnectionTest, ReorderNode) { } // Verifies DeleteNode works. -TEST_F(ViewManagerConnectionTest, DeleteNode) { +TEST_F(ViewManagerTest, DeleteNode) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); @@ -887,13 +889,13 @@ TEST_F(ViewManagerConnectionTest, DeleteNode) { } // Verifies DeleteNode isn't allowed from a separate connection. -TEST_F(ViewManagerConnectionTest, DeleteNodeFromAnotherConnectionDisallowed) { +TEST_F(ViewManagerTest, DeleteNodeFromAnotherConnectionDisallowed) { ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); EXPECT_FALSE(connection2_->DeleteNode(BuildNodeId(1, 1))); } // Verifies DeleteView isn't allowed from a separate connection. -TEST_F(ViewManagerConnectionTest, DeleteViewFromAnotherConnectionDisallowed) { +TEST_F(ViewManagerTest, DeleteViewFromAnotherConnectionDisallowed) { ASSERT_TRUE(connection_->CreateView(BuildViewId(1, 1))); ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); EXPECT_FALSE(connection2_->DeleteView(BuildViewId(1, 1))); @@ -901,7 +903,7 @@ TEST_F(ViewManagerConnectionTest, DeleteViewFromAnotherConnectionDisallowed) { // Verifies if a node was deleted and then reused that other clients are // properly notified. -TEST_F(ViewManagerConnectionTest, ReuseDeletedNodeId) { +TEST_F(ViewManagerTest, ReuseDeletedNodeId) { ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -944,7 +946,7 @@ TEST_F(ViewManagerConnectionTest, ReuseDeletedNodeId) { } // Assertions around setting a view. -TEST_F(ViewManagerConnectionTest, SetView) { +TEST_F(ViewManagerTest, SetView) { // Create nodes 1, 2 and 3 and the view 11. Nodes 2 and 3 are parented to 1. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -982,7 +984,7 @@ TEST_F(ViewManagerConnectionTest, SetView) { } // Verifies deleting a node with a view sends correct notifications. -TEST_F(ViewManagerConnectionTest, DeleteNodeWithView) { +TEST_F(ViewManagerTest, DeleteNodeWithView) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 3))); @@ -1030,7 +1032,7 @@ TEST_F(ViewManagerConnectionTest, DeleteNodeWithView) { } // Sets view from one connection on another. -TEST_F(ViewManagerConnectionTest, SetViewFromSecondConnection) { +TEST_F(ViewManagerTest, SetViewFromSecondConnection) { ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1059,7 +1061,7 @@ TEST_F(ViewManagerConnectionTest, SetViewFromSecondConnection) { } // Assertions for GetNodeTree. -TEST_F(ViewManagerConnectionTest, GetNodeTree) { +TEST_F(ViewManagerTest, GetNodeTree) { ASSERT_NO_FATAL_FAILURE(EstablishSecondConnection(true)); // Create 11 in first connection and make it a child of 1. @@ -1108,7 +1110,7 @@ TEST_F(ViewManagerConnectionTest, GetNodeTree) { } } -TEST_F(ViewManagerConnectionTest, SetNodeBounds) { +TEST_F(ViewManagerTest, SetNodeBounds) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->AddNode(BuildNodeId(0, 1), BuildNodeId(1, 1), 1)); @@ -1130,7 +1132,7 @@ TEST_F(ViewManagerConnectionTest, SetNodeBounds) { } // Various assertions around SetRoots. -TEST_F(ViewManagerConnectionTest, SetRoots) { +TEST_F(ViewManagerTest, SetRoots) { // Create 1, 2, and 3 in the first connection. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1197,7 +1199,7 @@ TEST_F(ViewManagerConnectionTest, SetRoots) { } // Verify AddNode fails when trying to manipulate nodes in other roots. -TEST_F(ViewManagerConnectionTest, CantMoveNodesFromOtherRoot) { +TEST_F(ViewManagerTest, CantMoveNodesFromOtherRoot) { // Create 1 and 2 in the first connection. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1215,7 +1217,7 @@ TEST_F(ViewManagerConnectionTest, CantMoveNodesFromOtherRoot) { // Verify RemoveNodeFromParent fails for nodes that are descendants of the // roots. -TEST_F(ViewManagerConnectionTest, CantRemoveNodesInOtherRoots) { +TEST_F(ViewManagerTest, CantRemoveNodesInOtherRoots) { // Create 1 and 2 in the first connection and parent both to the root. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1251,7 +1253,7 @@ TEST_F(ViewManagerConnectionTest, CantRemoveNodesInOtherRoots) { } // Verify SetView fails for nodes that are not descendants of the roots. -TEST_F(ViewManagerConnectionTest, CantRemoveSetViewInOtherRoots) { +TEST_F(ViewManagerTest, CantRemoveSetViewInOtherRoots) { // Create 1 and 2 in the first connection and parent both to the root. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1271,7 +1273,7 @@ TEST_F(ViewManagerConnectionTest, CantRemoveSetViewInOtherRoots) { } // Verify GetNodeTree fails for nodes that are not descendants of the roots. -TEST_F(ViewManagerConnectionTest, CantGetNodeTreeOfOtherRoots) { +TEST_F(ViewManagerTest, CantGetNodeTreeOfOtherRoots) { // Create 1 and 2 in the first connection and parent both to the root. ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); @@ -1297,7 +1299,7 @@ TEST_F(ViewManagerConnectionTest, CantGetNodeTreeOfOtherRoots) { EXPECT_EQ("node=1,1 parent=null view=null", nodes[0].ToString()); } -TEST_F(ViewManagerConnectionTest, ConnectTwice) { +TEST_F(ViewManagerTest, ConnectTwice) { ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 1))); ASSERT_TRUE(connection_->CreateNode(BuildNodeId(1, 2))); diff --git a/mojo/shell/view_manager_loader.cc b/mojo/shell/view_manager_loader.cc index 936d7fb..278ab81 100644 --- a/mojo/shell/view_manager_loader.cc +++ b/mojo/shell/view_manager_loader.cc @@ -5,7 +5,7 @@ #include "mojo/shell/view_manager_loader.h" #include "mojo/public/cpp/application/application.h" -#include "mojo/services/view_manager/view_manager_init_connection.h" +#include "mojo/services/view_manager/view_manager_init_service_impl.h" namespace mojo { namespace shell { @@ -23,7 +23,7 @@ void ViewManagerLoader::LoadService( // TODO(sky): this needs some sort of authentication as well as making sure // we only ever have one active at a time. scoped_ptr<Application> app(new Application(service_provider_handle.Pass())); - app->AddService<view_manager::service::ViewManagerInitConnection>( + app->AddService<view_manager::service::ViewManagerInitServiceImpl>( app->service_provider()); apps_.push_back(app.release()); } |