summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mojo/examples/aura_demo/view_manager_init.cc6
-rw-r--r--mojo/examples/demo_launcher/demo_launcher.cc6
-rw-r--r--mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.cc3
-rw-r--r--mojo/services/public/cpp/view_manager/tests/view_manager_unittest.cc15
-rw-r--r--mojo/services/public/interfaces/view_manager/view_manager.mojom11
-rw-r--r--mojo/services/view_manager/root_node_manager.cc14
-rw-r--r--mojo/services/view_manager/root_node_manager.h18
-rw-r--r--mojo/services/view_manager/view_manager_connection.cc12
-rw-r--r--mojo/services/view_manager/view_manager_connection.h8
-rw-r--r--mojo/services/view_manager/view_manager_connection_unittest.cc67
-rw-r--r--mojo/services/view_manager/view_manager_init_connection.cc13
-rw-r--r--mojo/services/view_manager/view_manager_init_connection.h8
12 files changed, 88 insertions, 93 deletions
diff --git a/mojo/examples/aura_demo/view_manager_init.cc b/mojo/examples/aura_demo/view_manager_init.cc
index fd90e1c..4c168f9 100644
--- a/mojo/examples/aura_demo/view_manager_init.cc
+++ b/mojo/examples/aura_demo/view_manager_init.cc
@@ -19,9 +19,9 @@ class ViewManagerInit : public Application {
virtual void Initialize() OVERRIDE {
ConnectTo("mojo:mojo_view_manager", &view_manager_init_);
- view_manager_init_->Connect("mojo:mojo_aura_demo",
- base::Bind(&ViewManagerInit::DidConnect,
- base::Unretained(this)));
+ view_manager_init_->EmbedRoot("mojo:mojo_aura_demo",
+ base::Bind(&ViewManagerInit::DidConnect,
+ base::Unretained(this)));
}
private:
diff --git a/mojo/examples/demo_launcher/demo_launcher.cc b/mojo/examples/demo_launcher/demo_launcher.cc
index def2e4d..134038a 100644
--- a/mojo/examples/demo_launcher/demo_launcher.cc
+++ b/mojo/examples/demo_launcher/demo_launcher.cc
@@ -21,9 +21,9 @@ class DemoLauncher : public Application {
virtual void Initialize() MOJO_OVERRIDE {
ConnectTo<view_manager::IViewManagerInit>("mojo:mojo_view_manager",
&view_manager_init_);
- view_manager_init_->Connect("mojo:mojo_window_manager",
- base::Bind(&DemoLauncher::OnConnect,
- base::Unretained(this)));
+ view_manager_init_->EmbedRoot("mojo:mojo_window_manager",
+ base::Bind(&DemoLauncher::OnConnect,
+ base::Unretained(this)));
}
void OnConnect(bool success) {}
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 df5fa05..baca5a4 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
@@ -425,8 +425,7 @@ class EmbedTransaction : public ViewManagerTransaction {
virtual void DoCommit() OVERRIDE {
std::vector<Id> ids;
ids.push_back(node_id_);
- service()->Connect(url_, Array<Id>::From(ids),
- ActionCompletedCallback());
+ service()->Embed(url_, Array<Id>::From(ids), ActionCompletedCallback());
}
virtual void DoActionCompleted(bool success) OVERRIDE {
// TODO(beng): recovery?
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 4180069..1ce3d0a 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
@@ -345,22 +345,19 @@ class ViewManagerTest : public testing::Test {
ConnectToService(test_helper_.service_provider(),
"mojo:mojo_view_manager",
&view_manager_init_);
- ASSERT_TRUE(ViewManagerInitConnect(view_manager_init_.get(),
- kWindowManagerURL));
+ ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kWindowManagerURL));
}
- void ViewManagerInitConnectCallback(bool* result_cache,
- bool result) {
+ void EmbedRootCallback(bool* result_cache, bool result) {
*result_cache = result;
}
- bool ViewManagerInitConnect(IViewManagerInit* view_manager_init,
- const std::string& url) {
+ bool EmbedRoot(IViewManagerInit* view_manager_init, const std::string& url) {
bool result = false;
- view_manager_init->Connect(
+ view_manager_init->EmbedRoot(
url,
- base::Bind(&ViewManagerTest::ViewManagerInitConnectCallback,
- base::Unretained(this), &result));
+ base::Bind(&ViewManagerTest::EmbedRootCallback, base::Unretained(this),
+ &result));
RunRunLoop();
window_manager_ = GetLoadedViewManager();
return result;
diff --git a/mojo/services/public/interfaces/view_manager/view_manager.mojom b/mojo/services/public/interfaces/view_manager/view_manager.mojom
index 903cbe6..df40def 100644
--- a/mojo/services/public/interfaces/view_manager/view_manager.mojom
+++ b/mojo/services/public/interfaces/view_manager/view_manager.mojom
@@ -18,8 +18,7 @@ struct INode {
// root node. mojo::view_manager returns an instance of this. All other
// connections are established by the client this creates.
interface IViewManagerInit {
- // Connects to |url| creating a connection that has the roots |nodes|.
- Connect(string url) => (bool success);
+ EmbedRoot(string url) => (bool success);
};
// Functions that mutate the hierarchy take a change id. This is an ever
@@ -97,13 +96,15 @@ interface IViewManager {
handle<shared_buffer> buffer,
uint32 buffer_size) => (bool success);
- // Connects to |url| creating a connection that has the roots |nodes|. Fails
+ // 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
// if |nodes| is empty or contains nodes that were not created by this
// connection.
- // If a particular client invokes Connect() multiple times with the same url,
+ // If a particular client invokes Embed() multiple times with the same url,
// the connection is reused. When this happens the IViewManagerClient is
// notified of the additional roots by way of OnRootsAdded().
- Connect(string url, uint32[] nodes) => (bool success);
+ Embed(string url, uint32[] nodes) => (bool success);
};
// Changes to nodes/views are not sent to the connection that originated the
diff --git a/mojo/services/view_manager/root_node_manager.cc b/mojo/services/view_manager/root_node_manager.cc
index c765fce..ea6cb2c 100644
--- a/mojo/services/view_manager/root_node_manager.cc
+++ b/mojo/services/view_manager/root_node_manager.cc
@@ -78,17 +78,17 @@ void RootNodeManager::RemoveConnection(ViewManagerConnection* connection) {
}
}
-void RootNodeManager::InitialConnect(const std::string& url) {
+void RootNodeManager::EmbedRoot(const std::string& url) {
CHECK(connection_map_.empty());
Array<Id> roots(0);
- ConnectImpl(kRootConnection, String::From(url), roots);
+ EmbedImpl(kRootConnection, String::From(url), roots);
}
-void RootNodeManager::Connect(ConnectionSpecificId creator_id,
- const String& url,
- const Array<Id>& node_ids) {
+void RootNodeManager::Embed(ConnectionSpecificId creator_id,
+ const String& url,
+ const Array<Id>& node_ids) {
CHECK_GT(node_ids.size(), 0u);
- ConnectImpl(creator_id, url, node_ids)->set_delete_on_connection_error();
+ EmbedImpl(creator_id, url, node_ids)->set_delete_on_connection_error();
}
ViewManagerConnection* RootNodeManager::GetConnection(
@@ -190,7 +190,7 @@ void RootNodeManager::FinishChange() {
current_change_ = NULL;
}
-ViewManagerConnection* RootNodeManager::ConnectImpl(
+ViewManagerConnection* RootNodeManager::EmbedImpl(
const ConnectionSpecificId creator_id,
const String& url,
const Array<Id>& node_ids) {
diff --git a/mojo/services/view_manager/root_node_manager.h b/mojo/services/view_manager/root_node_manager.h
index ae7994f..93988a5 100644
--- a/mojo/services/view_manager/root_node_manager.h
+++ b/mojo/services/view_manager/root_node_manager.h
@@ -94,13 +94,13 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate {
// Establishes the initial client. Similar to Connect(), but the resulting
// client is allowed to do anything.
- void InitialConnect(const std::string& url);
+ void EmbedRoot(const std::string& url);
- // See description of IViewManager::Connect() for details. This assumes
+ // See description of IViewManager::Embed() for details. This assumes
// |node_ids| has been validated.
- void Connect(ConnectionSpecificId creator_id,
- const String& url,
- const Array<Id>& node_ids);
+ void Embed(ConnectionSpecificId creator_id,
+ const String& url,
+ const Array<Id>& node_ids);
// Returns the connection by id.
ViewManagerConnection* GetConnection(ConnectionSpecificId connection_id);
@@ -168,10 +168,10 @@ class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate {
return current_change_ && current_change_->connection_id() == connection_id;
}
- // Implementation of the two connect variants.
- ViewManagerConnection* ConnectImpl(ConnectionSpecificId creator_id,
- const String& url,
- const Array<Id>& node_ids);
+ // Implementation of the two embed variants.
+ ViewManagerConnection* EmbedImpl(ConnectionSpecificId creator_id,
+ const String& url,
+ const Array<Id>& node_ids);
// Overridden from NodeDelegate:
virtual void OnNodeHierarchyChanged(const Node* node,
diff --git a/mojo/services/view_manager/view_manager_connection.cc b/mojo/services/view_manager/view_manager_connection.cc
index 3bb38c8..8d4d0a6 100644
--- a/mojo/services/view_manager/view_manager_connection.cc
+++ b/mojo/services/view_manager/view_manager_connection.cc
@@ -289,7 +289,7 @@ bool ViewManagerConnection::CanGetNodeTree(const Node* node) const {
(IsNodeDescendantOfRoots(node) || node->id().connection_id == id_);
}
-bool ViewManagerConnection::CanConnect(
+bool ViewManagerConnection::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]));
@@ -648,10 +648,10 @@ void ViewManagerConnection::SetNodeBounds(
callback.Run(true);
}
-void ViewManagerConnection::Connect(const String& url,
- Array<uint32_t> node_ids,
- const Callback<void(bool)>& callback) {
- bool success = CanConnect(node_ids);
+void ViewManagerConnection::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 =
@@ -659,7 +659,7 @@ void ViewManagerConnection::Connect(const String& url,
if (existing_connection)
success = existing_connection->AddRoots(node_ids.storage());
else
- root_node_manager_->Connect(id_, url, node_ids);
+ root_node_manager_->Embed(id_, url, node_ids);
}
callback.Run(success);
}
diff --git a/mojo/services/view_manager/view_manager_connection.h b/mojo/services/view_manager/view_manager_connection.h
index 71355e1..b9eae90 100644
--- a/mojo/services/view_manager/view_manager_connection.h
+++ b/mojo/services/view_manager/view_manager_connection.h
@@ -114,7 +114,7 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
bool CanDeleteView(const ViewId& view_id) const;
bool CanSetView(const Node* node, const ViewId& view_id) const;
bool CanGetNodeTree(const Node* node) const;
- bool CanConnect(const mojo::Array<uint32_t>& node_ids) const;
+ bool CanEmbed(const mojo::Array<uint32_t>& node_ids) const;
// Deletes a node owned by this connection. Returns true on success. |source|
// is the connection that originated the change.
@@ -187,9 +187,9 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection
virtual void SetNodeBounds(Id node_id,
RectPtr bounds,
const Callback<void(bool)>& callback) OVERRIDE;
- virtual void Connect(const mojo::String& url,
- mojo::Array<uint32_t> node_ids,
- const mojo::Callback<void(bool)>& callback) OVERRIDE;
+ virtual void Embed(const mojo::String& url,
+ mojo::Array<uint32_t> node_ids,
+ const mojo::Callback<void(bool)>& callback) OVERRIDE;
// Overridden from NodeDelegate:
virtual void OnNodeHierarchyChanged(const Node* node,
diff --git a/mojo/services/view_manager/view_manager_connection_unittest.cc b/mojo/services/view_manager/view_manager_connection_unittest.cc
index 8dcafec..4f5d1c9 100644
--- a/mojo/services/view_manager/view_manager_connection_unittest.cc
+++ b/mojo/services/view_manager/view_manager_connection_unittest.cc
@@ -137,13 +137,13 @@ class ViewManagerProxy : public TestChangeTracker::Delegate {
base::Unretained(this), nodes));
RunMainLoop();
}
- bool Connect(const std::vector<Id>& nodes) {
+ bool Embed(const std::vector<Id>& nodes) {
changes_.clear();
- base::AutoReset<bool> auto_reset(&in_connect_, true);
+ base::AutoReset<bool> auto_reset(&in_embed_, true);
bool result = false;
- view_manager_->Connect(kTestServiceURL, Array<Id>::From(nodes),
- base::Bind(&ViewManagerProxy::GotResult,
- base::Unretained(this), &result));
+ view_manager_->Embed(kTestServiceURL, Array<Id>::From(nodes),
+ base::Bind(&ViewManagerProxy::GotResult,
+ base::Unretained(this), &result));
RunMainLoop();
return result;
}
@@ -206,11 +206,11 @@ class ViewManagerProxy : public TestChangeTracker::Delegate {
static void SetInstance(ViewManagerProxy* instance) {
DCHECK(!instance_);
instance_ = instance;
- // Connect() runs its own run loop that is quit when the result is
- // received. Connect() also results in a new instance. If we quit here while
- // waiting for a Connect() we would prematurely return before we got the
- // result from Connect().
- if (!in_connect_ && main_run_loop_)
+ // Embed() runs its own run loop that is quit when the result is
+ // received. Embed() also results in a new instance. If we quit here while
+ // waiting for a Embed() we would prematurely return before we got the
+ // result from Embed().
+ if (!in_embed_ && main_run_loop_)
main_run_loop_->Quit();
}
@@ -235,7 +235,7 @@ class ViewManagerProxy : public TestChangeTracker::Delegate {
static ViewManagerProxy* instance_;
static base::RunLoop* main_run_loop_;
- static bool in_connect_;
+ static bool in_embed_;
TestChangeTracker* tracker_;
@@ -261,7 +261,7 @@ ViewManagerProxy* ViewManagerProxy::instance_ = NULL;
base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL;
// static
-bool ViewManagerProxy::in_connect_ = false;
+bool ViewManagerProxy::in_embed_ = false;
class TestViewManagerClientConnection
: public InterfaceImpl<IViewManagerClient> {
@@ -329,12 +329,12 @@ class TestViewManagerClientConnection
DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection);
};
-// Used with IViewManager::Connect(). Creates a TestViewManagerClientConnection,
+// Used with IViewManager::Embed(). Creates a TestViewManagerClientConnection,
// which creates and owns the ViewManagerProxy.
-class ConnectServiceLoader : public ServiceLoader {
+class EmbedServiceLoader : public ServiceLoader {
public:
- ConnectServiceLoader() {}
- virtual ~ConnectServiceLoader() {}
+ EmbedServiceLoader() {}
+ virtual ~EmbedServiceLoader() {}
// ServiceLoader:
virtual void LoadService(ServiceManager* manager,
@@ -351,7 +351,7 @@ class ConnectServiceLoader : public ServiceLoader {
private:
ScopedVector<Application> apps_;
- DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader);
+ DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader);
};
// Creates an id used for transport from the specified parameters.
@@ -366,24 +366,22 @@ Id BuildViewId(ConnectionSpecificId connection_id,
return (connection_id << 16) | view_id;
}
-// Callback from ViewManagerInitConnect(). |result| is the result of the
-// Connect() call and |run_loop| the nested RunLoop.
-void ViewManagerInitConnectCallback(bool* result_cache,
- base::RunLoop* run_loop,
- bool result) {
+// Callback from EmbedRoot(). |result| is the result of the
+// Embed() call and |run_loop| the nested RunLoop.
+void EmbedRootCallback(bool* result_cache,
+ base::RunLoop* run_loop,
+ bool result) {
*result_cache = result;
run_loop->Quit();
}
-// Resposible for establishing connection to the viewmanager. Blocks until get
-// back result.
-bool ViewManagerInitConnect(IViewManagerInit* view_manager_init,
- const std::string& url) {
+// Resposible for establishing the initial IViewManager connection. Blocks until
+// result is determined.
+bool EmbedRoot(IViewManagerInit* view_manager_init, const std::string& url) {
bool result = false;
base::RunLoop run_loop;
- view_manager_init->Connect(url,
- base::Bind(&ViewManagerInitConnectCallback,
- &result, &run_loop));
+ view_manager_init->EmbedRoot(url, base::Bind(&EmbedRootCallback,
+ &result, &run_loop));
run_loop.Run();
return result;
}
@@ -400,14 +398,13 @@ class ViewManagerConnectionTest : public testing::Test {
test_helper_.Init();
test_helper_.SetLoaderForURL(
- scoped_ptr<ServiceLoader>(new ConnectServiceLoader()),
+ scoped_ptr<ServiceLoader>(new EmbedServiceLoader()),
GURL(kTestServiceURL));
ConnectToService(test_helper_.service_provider(),
"mojo:mojo_view_manager",
&view_manager_init_);
- ASSERT_TRUE(ViewManagerInitConnect(view_manager_init_.get(),
- kTestServiceURL));
+ ASSERT_TRUE(EmbedRoot(view_manager_init_.get(), kTestServiceURL));
connection_ = ViewManagerProxy::WaitForInstance();
ASSERT_TRUE(connection_ != NULL);
@@ -427,7 +424,7 @@ class ViewManagerConnectionTest : public testing::Test {
node_ids.push_back(id1);
if (id2 != 0)
node_ids.push_back(id2);
- ASSERT_TRUE(connection_->Connect(node_ids));
+ ASSERT_TRUE(connection_->Embed(node_ids));
connection2_ = ViewManagerProxy::WaitForInstance();
ASSERT_TRUE(connection2_ != NULL);
connection2_->DoRunLoopUntilChangesCount(1);
@@ -1210,14 +1207,14 @@ TEST_F(ViewManagerConnectionTest, ConnectTwice) {
{
std::vector<Id> node_ids;
node_ids.push_back(BuildNodeId(1, 1));
- ASSERT_FALSE(connection_->Connect(node_ids));
+ ASSERT_FALSE(connection_->Embed(node_ids));
}
// Connecting to 1,2 should succeed and end up in connection2.
{
std::vector<Id> node_ids;
node_ids.push_back(BuildNodeId(1, 2));
- ASSERT_TRUE(connection_->Connect(node_ids));
+ ASSERT_TRUE(connection_->Embed(node_ids));
connection2_->DoRunLoopUntilChangesCount(1);
const Changes changes(ChangesToDescription1(connection2_->changes()));
ASSERT_EQ(1u, changes.size());
diff --git a/mojo/services/view_manager/view_manager_init_connection.cc b/mojo/services/view_manager/view_manager_init_connection.cc
index dd201e5..5c529a1 100644
--- a/mojo/services/view_manager/view_manager_init_connection.cc
+++ b/mojo/services/view_manager/view_manager_init_connection.cc
@@ -26,18 +26,19 @@ ViewManagerInitConnection::ViewManagerInitConnection(
ViewManagerInitConnection::~ViewManagerInitConnection() {
}
-void ViewManagerInitConnection::MaybeConnect(
+void ViewManagerInitConnection::MaybeEmbedRoot(
const std::string& url,
const Callback<void(bool)>& callback) {
if (!is_tree_host_ready_)
return;
- root_node_manager_.InitialConnect(url);
+ root_node_manager_.EmbedRoot(url);
callback.Run(true);
}
-void ViewManagerInitConnection::Connect(const String& url,
- const Callback<void(bool)>& callback) {
+void ViewManagerInitConnection::EmbedRoot(
+ const String& url,
+ const Callback<void(bool)>& callback) {
if (connect_params_.get()) {
DVLOG(1) << "Ignoring second connect";
callback.Run(false);
@@ -46,14 +47,14 @@ void ViewManagerInitConnection::Connect(const String& url,
connect_params_.reset(new ConnectParams);
connect_params_->url = url.To<std::string>();
connect_params_->callback = callback;
- MaybeConnect(url.To<std::string>(), callback);
+ MaybeEmbedRoot(url.To<std::string>(), callback);
}
void ViewManagerInitConnection::OnRootViewManagerWindowTreeHostCreated() {
DCHECK(!is_tree_host_ready_);
is_tree_host_ready_ = true;
if (connect_params_.get())
- MaybeConnect(connect_params_->url, connect_params_->callback);
+ MaybeEmbedRoot(connect_params_->url, connect_params_->callback);
}
} // namespace service
diff --git a/mojo/services/view_manager/view_manager_init_connection.h b/mojo/services/view_manager/view_manager_init_connection.h
index 0cedc63..6dce991 100644
--- a/mojo/services/view_manager/view_manager_init_connection.h
+++ b/mojo/services/view_manager/view_manager_init_connection.h
@@ -46,12 +46,12 @@ class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitConnection
Callback<void(bool)> callback;
};
- void MaybeConnect(const std::string& url,
- const Callback<void(bool)>& callback);
+ void MaybeEmbedRoot(const std::string& url,
+ const Callback<void(bool)>& callback);
// IViewManagerInit overrides:
- virtual void Connect(const String& url,
- const Callback<void(bool)>& callback) OVERRIDE;
+ virtual void EmbedRoot(const String& url,
+ const Callback<void(bool)>& callback) OVERRIDE;
// RootViewManagerDelegate overrides:
virtual void OnRootViewManagerWindowTreeHostCreated() OVERRIDE;