summaryrefslogtreecommitdiffstats
path: root/mojo/shell/public/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/shell/public/cpp')
-rw-r--r--mojo/shell/public/cpp/BUILD.gn6
-rw-r--r--mojo/shell/public/cpp/application_impl.h17
-rw-r--r--mojo/shell/public/cpp/application_runner.h6
-rw-r--r--mojo/shell/public/cpp/application_test_base.h12
-rw-r--r--mojo/shell/public/cpp/connection.h (renamed from mojo/shell/public/cpp/application_connection.h)52
-rw-r--r--mojo/shell/public/cpp/content_handler_factory.h2
-rw-r--r--mojo/shell/public/cpp/interface_factory.h4
-rw-r--r--mojo/shell/public/cpp/interface_factory_impl.h4
-rw-r--r--mojo/shell/public/cpp/lib/application_delegate.cc29
-rw-r--r--mojo/shell/public/cpp/lib/application_impl.cc28
-rw-r--r--mojo/shell/public/cpp/lib/application_runner.cc18
-rw-r--r--mojo/shell/public/cpp/lib/application_test_base.cc10
-rw-r--r--mojo/shell/public/cpp/lib/content_handler_factory.cc4
-rw-r--r--mojo/shell/public/cpp/lib/interface_factory_connector.h4
-rw-r--r--mojo/shell/public/cpp/lib/service_connector_registry.cc6
-rw-r--r--mojo/shell/public/cpp/lib/service_connector_registry.h4
-rw-r--r--mojo/shell/public/cpp/lib/service_provider_impl.cc2
-rw-r--r--mojo/shell/public/cpp/lib/service_registry.cc4
-rw-r--r--mojo/shell/public/cpp/lib/service_registry.h8
-rw-r--r--mojo/shell/public/cpp/lib/shell_client.cc26
-rw-r--r--mojo/shell/public/cpp/service_connector.h4
-rw-r--r--mojo/shell/public/cpp/shell.h8
-rw-r--r--mojo/shell/public/cpp/shell_client.h (renamed from mojo/shell/public/cpp/application_delegate.h)29
-rw-r--r--mojo/shell/public/cpp/tests/service_registry_unittest.cc2
24 files changed, 141 insertions, 148 deletions
diff --git a/mojo/shell/public/cpp/BUILD.gn b/mojo/shell/public/cpp/BUILD.gn
index 81da818..1d8ad18 100644
--- a/mojo/shell/public/cpp/BUILD.gn
+++ b/mojo/shell/public/cpp/BUILD.gn
@@ -21,16 +21,14 @@ source_set("cpp_for_chromium") {
source_set("sources") {
sources = [
"app_lifetime_helper.h",
- "application_connection.h",
- "application_delegate.h",
"application_impl.h",
"application_runner.h",
"connect.h",
+ "connection.h",
"initialize_base_and_icu.cc",
"interface_factory.h",
"interface_factory_impl.h",
"lib/app_lifetime_helper.cc",
- "lib/application_delegate.cc",
"lib/application_impl.cc",
"lib/application_runner.cc",
"lib/interface_factory_connector.h",
@@ -39,9 +37,11 @@ source_set("sources") {
"lib/service_provider_impl.cc",
"lib/service_registry.cc",
"lib/service_registry.h",
+ "lib/shell_client.cc",
"service_connector.h",
"service_provider_impl.h",
"shell.h",
+ "shell_client.h",
]
deps = [
diff --git a/mojo/shell/public/cpp/application_impl.h b/mojo/shell/public/cpp/application_impl.h
index 18d82d4..5ade99f 100644
--- a/mojo/shell/public/cpp/application_impl.h
+++ b/mojo/shell/public/cpp/application_impl.h
@@ -15,10 +15,9 @@
#include "mojo/public/cpp/bindings/callback.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/shell/public/cpp/app_lifetime_helper.h"
-#include "mojo/shell/public/cpp/application_connection.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
#include "mojo/shell/public/cpp/lib/service_registry.h"
#include "mojo/shell/public/cpp/shell.h"
+#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/application.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -77,12 +76,12 @@ class ApplicationImpl : public Shell, public shell::mojom::Application {
// Does not take ownership of |delegate|, which must remain valid for the
// lifetime of ApplicationImpl.
- ApplicationImpl(ApplicationDelegate* delegate,
+ ApplicationImpl(ShellClient* client,
InterfaceRequest<shell::mojom::Application> request);
// Constructs an ApplicationImpl with a custom termination closure. This
// closure is invoked on Quit() instead of the default behavior of quitting
// the current base::MessageLoop.
- ApplicationImpl(ApplicationDelegate* delegate,
+ ApplicationImpl(ShellClient* client,
InterfaceRequest<shell::mojom::Application> request,
const Closure& termination_closure);
~ApplicationImpl() override;
@@ -97,10 +96,8 @@ class ApplicationImpl : public Shell, public shell::mojom::Application {
void WaitForInitialize();
// Shell.
- scoped_ptr<ApplicationConnection> ConnectToApplication(
- const std::string& url) override;
- scoped_ptr<ApplicationConnection> ConnectToApplication(
- ConnectParams* params) override;
+ scoped_ptr<Connection> ConnectToApplication(const std::string& url) override;
+ scoped_ptr<Connection> ConnectToApplication(ConnectParams* params) override;
void Quit() override;
scoped_ptr<AppRefCount> CreateAppRefCount() override;
@@ -132,8 +129,8 @@ class ApplicationImpl : public Shell, public shell::mojom::Application {
// We track the lifetime of incoming connection registries as it more
// convenient for the client.
- ScopedVector<ApplicationConnection> incoming_connections_;
- ApplicationDelegate* delegate_;
+ ScopedVector<Connection> incoming_connections_;
+ ShellClient* client_;
Binding<shell::mojom::Application> binding_;
shell::mojom::ShellPtr shell_;
Closure termination_closure_;
diff --git a/mojo/shell/public/cpp/application_runner.h b/mojo/shell/public/cpp/application_runner.h
index 10eb0a7..ddebcd7 100644
--- a/mojo/shell/public/cpp/application_runner.h
+++ b/mojo/shell/public/cpp/application_runner.h
@@ -11,7 +11,7 @@
namespace mojo {
-class ApplicationDelegate;
+class ShellClient;
// A utility for running a chromium based mojo Application. The typical use
// case is to use when writing your MojoMain:
@@ -27,7 +27,7 @@ class ApplicationDelegate;
class ApplicationRunner {
public:
// Takes ownership of |delegate|.
- explicit ApplicationRunner(ApplicationDelegate* delegate);
+ explicit ApplicationRunner(ShellClient* client);
~ApplicationRunner();
static void InitBaseCommandLine();
@@ -47,7 +47,7 @@ class ApplicationRunner {
MojoResult Run(MojoHandle shell_handle);
private:
- scoped_ptr<ApplicationDelegate> delegate_;
+ scoped_ptr<ShellClient> client_;
// MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as
// the underlying message pump).
diff --git a/mojo/shell/public/cpp/application_test_base.h b/mojo/shell/public/cpp/application_test_base.h
index 1dc3516..eec60d8 100644
--- a/mojo/shell/public/cpp/application_test_base.h
+++ b/mojo/shell/public/cpp/application_test_base.h
@@ -9,8 +9,8 @@
#include "mojo/public/cpp/bindings/array.h"
#include "mojo/public/cpp/bindings/string.h"
#include "mojo/public/cpp/system/macros.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
#include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
#include "mojo/shell/public/interfaces/application.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,15 +29,15 @@ MojoResult RunAllTests(MojoHandle application_request_handle);
// ApplicationTestBase.
class TestHelper {
public:
- explicit TestHelper(ApplicationDelegate* delegate);
+ explicit TestHelper(ShellClient* client);
~TestHelper();
Shell* shell() { return application_impl_.get(); }
std::string shell_url() { return url_; }
private:
- // The application delegate used if GetApplicationDelegate is not overridden.
- ApplicationDelegate default_application_delegate_;
+ // The application delegate used if GetShellClient is not overridden.
+ ShellClient default_shell_client_;
// The application implementation instance, reconstructed for each test.
scoped_ptr<ApplicationImpl> application_impl_;
@@ -61,8 +61,8 @@ class ApplicationTestBase : public testing::Test {
return test_helper_ ? test_helper_->shell_url() : std::string();
}
- // Get the ApplicationDelegate for the application to be tested.
- virtual ApplicationDelegate* GetApplicationDelegate();
+ // Get the ShellClient for the application to be tested.
+ virtual ShellClient* GetShellClient();
// testing::Test:
void SetUp() override;
diff --git a/mojo/shell/public/cpp/application_connection.h b/mojo/shell/public/cpp/connection.h
index 28a3a85..4be8669 100644
--- a/mojo/shell/public/cpp/application_connection.h
+++ b/mojo/shell/public/cpp/connection.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_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
-#define MOJO_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
+#ifndef MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
+#define MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
#include <stdint.h>
@@ -19,7 +19,7 @@ namespace mojo {
class ServiceConnector;
// Represents a connection to another application. An instance of this class is
-// passed to ApplicationDelegate's AcceptConnection() method each
+// passed to ShellClient's AcceptConnection() method each
// time a connection is made to this app.
//
// To use, define a class that implements your specific service API (e.g.,
@@ -35,32 +35,29 @@ class ServiceConnector;
// connection->AddService<Foo>(&my_foo_and_bar_factory_);
// connection->AddService<Bar>(&my_foo_and_bar_factory_);
//
-// The InterfaceFactory must outlive the ApplicationConnection.
+// The InterfaceFactory must outlive the Connection.
//
// Additionally you specify a ServiceConnector. If a ServiceConnector has
// been set and an InterfaceFactory has not been registered for the interface
// request, than the interface request is sent to the ServiceConnector.
//
-// Just as with InterfaceFactory, ServiceConnector must outlive
-// ApplicationConnection.
+// Just as with InterfaceFactory, ServiceConnector must outlive Connection.
//
-// An ApplicationConnection's lifetime is managed by an ApplicationImpl. To
-// close a connection, call CloseConnection which will destroy this object.
-class ApplicationConnection {
+// An Connection's lifetime is managed by an ApplicationImpl. To close a
+// connection, call CloseConnection which will destroy this object.
+class Connection {
public:
- virtual ~ApplicationConnection() {}
+ virtual ~Connection() {}
class TestApi {
public:
- explicit TestApi(ApplicationConnection* connection)
- : connection_(connection) {
- }
- base::WeakPtr<ApplicationConnection> GetWeakPtr() {
+ explicit TestApi(Connection* connection) : connection_(connection) {}
+ base::WeakPtr<Connection> GetWeakPtr() {
return connection_->GetWeakPtr();
}
private:
- ApplicationConnection* connection_;
+ Connection* connection_;
};
// See class description for details.
@@ -92,13 +89,13 @@ class ApplicationConnection {
// Returns the URL that was used by the source application to establish a
// connection to the destination application.
//
- // When ApplicationConnection is representing an incoming connection this can
- // be different than the URL the application was initially loaded from, if the
+ // When Connection is representing an incoming connection this can be
+ // different than the URL the application was initially loaded from, if the
// application handles multiple URLs. Note that this is the URL after all
// URL rewriting and HTTP redirects have been performed.
//
- // When ApplicationConnection is representing and outgoing connection, this
- // will be the same as the value returned by GetRemoveApplicationURL().
+ // When Connection is representing and outgoing connection, this will be the
+ // same as the value returned by GetRemoveApplicationURL().
virtual const std::string& GetConnectionURL() = 0;
// Returns the URL identifying the remote application on this connection.
@@ -118,13 +115,12 @@ class ApplicationConnection {
virtual void SetRemoteServiceProviderConnectionErrorHandler(
const Closure& handler) = 0;
- // Returns the id of the remote application. For ApplicationConnections
- // created via ApplicationImpl::ConnectToApplication(), this will not be
- // determined until ConnectToApplication()'s callback is run, and this
- // function will return false. Use AddRemoteIDCallback() to schedule a
- // callback to be run when the remote application id is available. A value of
- // Shell::kInvalidApplicationID indicates no remote application connection
- // has been established.
+ // Returns the id of the remote application. For Connections created via
+ // ApplicationImpl::ConnectToApplication(), this will not be determined until
+ // ConnectToApplication()'s callback is run, and this function will return
+ // false. Use AddRemoteIDCallback() to schedule a callback to be run when the
+ // remote application id is available. A value of Shell::kInvalidApplicationID
+ // indicates no remote application connection has been established.
virtual bool GetRemoteApplicationID(uint32_t* remote_id) const = 0;
// Returns the id of the deepest content handler used in connecting to
@@ -144,9 +140,9 @@ class ApplicationConnection {
virtual bool SetServiceConnectorForName(ServiceConnector* service_connector,
const std::string& name) = 0;
- virtual base::WeakPtr<ApplicationConnection> GetWeakPtr() = 0;
+ virtual base::WeakPtr<Connection> GetWeakPtr() = 0;
};
} // namespace mojo
-#endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_CONNECTION_H_
+#endif // MOJO_SHELL_PUBLIC_CPP_CONNECTION_H_
diff --git a/mojo/shell/public/cpp/content_handler_factory.h b/mojo/shell/public/cpp/content_handler_factory.h
index a8aa8c3..a174cdd 100644
--- a/mojo/shell/public/cpp/content_handler_factory.h
+++ b/mojo/shell/public/cpp/content_handler_factory.h
@@ -54,7 +54,7 @@ class ContentHandlerFactory
private:
// From InterfaceFactory:
- void Create(ApplicationConnection* connection,
+ void Create(Connection* connection,
InterfaceRequest<shell::mojom::ContentHandler> request) override;
Delegate* delegate_;
diff --git a/mojo/shell/public/cpp/interface_factory.h b/mojo/shell/public/cpp/interface_factory.h
index 7f8f26e..7edf000 100644
--- a/mojo/shell/public/cpp/interface_factory.h
+++ b/mojo/shell/public/cpp/interface_factory.h
@@ -9,7 +9,7 @@
namespace mojo {
-class ApplicationConnection;
+class Connection;
template <typename Interface>
class InterfaceRequest;
@@ -21,7 +21,7 @@ template <typename Interface>
class InterfaceFactory {
public:
virtual ~InterfaceFactory() {}
- virtual void Create(ApplicationConnection* connection,
+ virtual void Create(Connection* connection,
InterfaceRequest<Interface> request) = 0;
};
diff --git a/mojo/shell/public/cpp/interface_factory_impl.h b/mojo/shell/public/cpp/interface_factory_impl.h
index 7de2449..f849922 100644
--- a/mojo/shell/public/cpp/interface_factory_impl.h
+++ b/mojo/shell/public/cpp/interface_factory_impl.h
@@ -17,7 +17,7 @@ class InterfaceFactoryImpl : public InterfaceFactory<Interface> {
public:
virtual ~InterfaceFactoryImpl() {}
- virtual void Create(ApplicationConnection* connection,
+ virtual void Create(Connection* connection,
InterfaceRequest<Interface> request) override {
BindToRequest(new Impl(), &request);
}
@@ -35,7 +35,7 @@ class InterfaceFactoryImplWithContext : public InterfaceFactory<Interface> {
: context_(context) {}
virtual ~InterfaceFactoryImplWithContext() {}
- virtual void Create(ApplicationConnection* connection,
+ virtual void Create(Connection* connection,
InterfaceRequest<Interface> request) override {
BindToRequest(new Impl(context_), &request);
}
diff --git a/mojo/shell/public/cpp/lib/application_delegate.cc b/mojo/shell/public/cpp/lib/application_delegate.cc
deleted file mode 100644
index 7c84264..0000000
--- a/mojo/shell/public/cpp/lib/application_delegate.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/shell/public/cpp/application_delegate.h"
-
-namespace mojo {
-
-ApplicationDelegate::ApplicationDelegate() {
-}
-ApplicationDelegate::~ApplicationDelegate() {
-}
-
-void ApplicationDelegate::Initialize(Shell* app, const std::string& url,
- uint32_t id) {
-}
-
-bool ApplicationDelegate::AcceptConnection(ApplicationConnection* connection) {
- return true;
-}
-
-bool ApplicationDelegate::ShellConnectionLost() {
- return true;
-}
-
-void ApplicationDelegate::Quit() {
-}
-
-} // namespace mojo
diff --git a/mojo/shell/public/cpp/lib/application_impl.cc b/mojo/shell/public/cpp/lib/application_impl.cc
index ca149a3..d51e5aa 100644
--- a/mojo/shell/public/cpp/lib/application_impl.cc
+++ b/mojo/shell/public/cpp/lib/application_impl.cc
@@ -10,9 +10,9 @@
#include "mojo/converters/network/network_type_converters.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "mojo/public/cpp/environment/logging.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
#include "mojo/shell/public/cpp/application_impl.h"
#include "mojo/shell/public/cpp/lib/service_registry.h"
+#include "mojo/shell/public/cpp/shell_client.h"
namespace mojo {
@@ -36,17 +36,17 @@ ApplicationImpl::ConnectParams::ConnectParams(URLRequestPtr request)
ApplicationImpl::ConnectParams::~ConnectParams() {}
ApplicationImpl::ApplicationImpl(
- ApplicationDelegate* delegate,
+ ShellClient* client,
InterfaceRequest<shell::mojom::Application> request)
- : ApplicationImpl(delegate,
+ : ApplicationImpl(client,
std::move(request),
base::Bind(&DefaultTerminationClosure)) {}
ApplicationImpl::ApplicationImpl(
- ApplicationDelegate* delegate,
+ ShellClient* client,
InterfaceRequest<shell::mojom::Application> request,
const Closure& termination_closure)
- : delegate_(delegate),
+ : client_(client),
binding_(this, std::move(request)),
termination_closure_(termination_closure),
app_lifetime_helper_(this),
@@ -62,15 +62,15 @@ void ApplicationImpl::WaitForInitialize() {
binding_.WaitForIncomingMethodCall();
}
-scoped_ptr<ApplicationConnection> ApplicationImpl::ConnectToApplication(
+scoped_ptr<Connection> ApplicationImpl::ConnectToApplication(
const std::string& url) {
ConnectParams params(url);
params.set_filter(CreatePermissiveCapabilityFilter());
return ConnectToApplication(&params);
}
-scoped_ptr<ApplicationConnection>
- ApplicationImpl::ConnectToApplication(ConnectParams* params) {
+scoped_ptr<Connection> ApplicationImpl::ConnectToApplication(
+ ConnectParams* params) {
if (!shell_)
return nullptr;
DCHECK(params);
@@ -118,7 +118,7 @@ void ApplicationImpl::Initialize(shell::mojom::ShellPtr shell,
uint32_t id) {
shell_ = std::move(shell);
shell_.set_connection_error_handler([this]() { OnConnectionError(); });
- delegate_->Initialize(this, url, id);
+ client_->Initialize(this, url, id);
}
void ApplicationImpl::AcceptConnection(
@@ -128,10 +128,10 @@ void ApplicationImpl::AcceptConnection(
ServiceProviderPtr exposed_services,
Array<String> allowed_interfaces,
const String& url) {
- scoped_ptr<ApplicationConnection> registry(new internal::ServiceRegistry(
+ scoped_ptr<Connection> registry(new internal::ServiceRegistry(
url, requestor_url, requestor_id, std::move(exposed_services),
std::move(services), allowed_interfaces.To<std::set<std::string>>()));
- if (!delegate_->AcceptConnection(registry.get()))
+ if (!client_->AcceptConnection(registry.get()))
return;
// If we were quitting because we thought there were no more services for this
@@ -154,11 +154,11 @@ void ApplicationImpl::OnQuitRequested(const Callback<void(bool)>& callback) {
void ApplicationImpl::OnConnectionError() {
base::WeakPtr<ApplicationImpl> ptr(weak_factory_.GetWeakPtr());
- // We give the delegate notice first, since it might want to do something on
+ // We give the client notice first, since it might want to do something on
// shell connection errors other than immediate termination of the run
// loop. The application might want to continue servicing connections other
// than the one to the shell.
- bool quit_now = delegate_->ShellConnectionLost();
+ bool quit_now = client_->ShellConnectionLost();
if (quit_now)
QuitNow();
if (!ptr)
@@ -167,7 +167,7 @@ void ApplicationImpl::OnConnectionError() {
}
void ApplicationImpl::QuitNow() {
- delegate_->Quit();
+ client_->Quit();
termination_closure_.Run();
}
diff --git a/mojo/shell/public/cpp/lib/application_runner.cc b/mojo/shell/public/cpp/lib/application_runner.cc
index e95133e..245dcd5 100644
--- a/mojo/shell/public/cpp/lib/application_runner.cc
+++ b/mojo/shell/public/cpp/lib/application_runner.cc
@@ -10,16 +10,16 @@
#include "base/message_loop/message_loop.h"
#include "base/process/launch.h"
#include "mojo/message_pump/message_pump_mojo.h"
-#include "mojo/shell/public/cpp/application_delegate.h"
#include "mojo/shell/public/cpp/application_impl.h"
+#include "mojo/shell/public/cpp/shell_client.h"
namespace mojo {
int g_application_runner_argc;
const char* const* g_application_runner_argv;
-ApplicationRunner::ApplicationRunner(ApplicationDelegate* delegate)
- : delegate_(scoped_ptr<ApplicationDelegate>(delegate)),
+ApplicationRunner::ApplicationRunner(ShellClient* client)
+ : client_(scoped_ptr<ShellClient>(client)),
message_loop_type_(base::MessageLoop::TYPE_CUSTOM),
has_run_(false) {}
@@ -54,19 +54,19 @@ MojoResult ApplicationRunner::Run(MojoHandle application_request_handle,
else
loop.reset(new base::MessageLoop(message_loop_type_));
- ApplicationImpl impl(delegate_.get(),
+ ApplicationImpl impl(client_.get(),
MakeRequest<shell::mojom::Application>(
MakeScopedHandle(MessagePipeHandle(
application_request_handle))));
loop->Run();
- // It's very common for the delegate to cache the app and terminate on
- // errors. If we don't delete the delegate before the app we run the risk
- // of the delegate having a stale reference to the app and trying to use it.
+ // It's very common for the client to cache the app and terminate on errors.
+ // If we don't delete the client before the app we run the risk of the
+ // client having a stale reference to the app and trying to use it.
// Note that we destruct the message loop first because that might trigger
// connection error handlers and they might access objects created by the
- // delegate.
+ // client.
loop.reset();
- delegate_.reset();
+ client_.reset();
}
return MOJO_RESULT_OK;
}
diff --git a/mojo/shell/public/cpp/lib/application_test_base.cc b/mojo/shell/public/cpp/lib/application_test_base.cc
index 3d6ad90..2bf6975 100644
--- a/mojo/shell/public/cpp/lib/application_test_base.cc
+++ b/mojo/shell/public/cpp/lib/application_test_base.cc
@@ -113,9 +113,9 @@ MojoResult RunAllTests(MojoHandle application_request_handle) {
return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN;
}
-TestHelper::TestHelper(ApplicationDelegate* delegate)
+TestHelper::TestHelper(ShellClient* client)
: application_impl_(new ApplicationImpl(
- delegate == nullptr ? &default_application_delegate_ : delegate,
+ client == nullptr ? &default_shell_client_ : client,
std::move(g_application_request))),
url_(g_url) {
// Fake application initialization.
@@ -129,7 +129,7 @@ TestHelper::~TestHelper() {
// ApplicationImpl::TestApi test_api(application_impl_);
// test_api.UnbindConnections(&g_application_request, &g_shell);
// }
- // We may have supplied a member as the delegate. Delete |application_impl_|
+ // We may have supplied a member as the client. Delete |application_impl_|
// while still valid.
application_impl_.reset();
}
@@ -139,7 +139,7 @@ ApplicationTestBase::ApplicationTestBase() : test_helper_(nullptr) {}
ApplicationTestBase::~ApplicationTestBase() {
}
-ApplicationDelegate* ApplicationTestBase::GetApplicationDelegate() {
+ShellClient* ApplicationTestBase::GetShellClient() {
return nullptr;
}
@@ -153,7 +153,7 @@ void ApplicationTestBase::SetUp() {
MOJO_CHECK(g_shell);
// New applications are constructed for each test to avoid persisting state.
- test_helper_.reset(new TestHelper(GetApplicationDelegate()));
+ test_helper_.reset(new TestHelper(GetShellClient()));
}
void ApplicationTestBase::TearDown() {
diff --git a/mojo/shell/public/cpp/lib/content_handler_factory.cc b/mojo/shell/public/cpp/lib/content_handler_factory.cc
index 17714f5..156faf0 100644
--- a/mojo/shell/public/cpp/lib/content_handler_factory.cc
+++ b/mojo/shell/public/cpp/lib/content_handler_factory.cc
@@ -15,7 +15,7 @@
#include "base/threading/platform_thread.h"
#include "mojo/message_pump/message_pump_mojo.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/content_handler_factory.h"
#include "mojo/shell/public/cpp/interface_factory_impl.h"
@@ -134,7 +134,7 @@ void ContentHandlerFactory::ManagedDelegate::RunApplication(
}
void ContentHandlerFactory::Create(
- ApplicationConnection* connection,
+ Connection* connection,
InterfaceRequest<shell::mojom::ContentHandler> request) {
new ContentHandlerImpl(delegate_, std::move(request));
}
diff --git a/mojo/shell/public/cpp/lib/interface_factory_connector.h b/mojo/shell/public/cpp/lib/interface_factory_connector.h
index 5ef7eaa..42c4c03 100644
--- a/mojo/shell/public/cpp/lib/interface_factory_connector.h
+++ b/mojo/shell/public/cpp/lib/interface_factory_connector.h
@@ -21,10 +21,10 @@ class InterfaceFactoryConnector : public ServiceConnector {
: factory_(factory) {}
~InterfaceFactoryConnector() override {}
- void ConnectToService(ApplicationConnection* application_connection,
+ void ConnectToService(Connection* connection,
const std::string& interface_name,
ScopedMessagePipeHandle client_handle) override {
- factory_->Create(application_connection,
+ factory_->Create(connection,
MakeRequest<Interface>(std::move(client_handle)));
}
diff --git a/mojo/shell/public/cpp/lib/service_connector_registry.cc b/mojo/shell/public/cpp/lib/service_connector_registry.cc
index edc91e0..fc74ef0 100644
--- a/mojo/shell/public/cpp/lib/service_connector_registry.cc
+++ b/mojo/shell/public/cpp/lib/service_connector_registry.cc
@@ -42,17 +42,17 @@ void ServiceConnectorRegistry::RemoveServiceConnectorForName(
}
void ServiceConnectorRegistry::ConnectToService(
- ApplicationConnection* application_connection,
+ Connection* connection,
const std::string& interface_name,
ScopedMessagePipeHandle client_handle) {
auto iter = name_to_service_connector_.find(interface_name);
if (iter != name_to_service_connector_.end()) {
- iter->second->ConnectToService(application_connection, interface_name,
+ iter->second->ConnectToService(connection, interface_name,
std::move(client_handle));
return;
}
if (service_connector_) {
- service_connector_->ConnectToService(application_connection, interface_name,
+ service_connector_->ConnectToService(connection, interface_name,
std::move(client_handle));
}
}
diff --git a/mojo/shell/public/cpp/lib/service_connector_registry.h b/mojo/shell/public/cpp/lib/service_connector_registry.h
index 9475436..4bf400f 100644
--- a/mojo/shell/public/cpp/lib/service_connector_registry.h
+++ b/mojo/shell/public/cpp/lib/service_connector_registry.h
@@ -12,7 +12,7 @@
namespace mojo {
-class ApplicationConnection;
+class Connection;
class ServiceConnector;
namespace internal {
@@ -42,7 +42,7 @@ class ServiceConnectorRegistry {
const std::string& interface_name);
void RemoveServiceConnectorForName(const std::string& interface_name);
- void ConnectToService(ApplicationConnection* application_connection,
+ void ConnectToService(Connection* connection,
const std::string& interface_name,
ScopedMessagePipeHandle client_handle);
diff --git a/mojo/shell/public/cpp/lib/service_provider_impl.cc b/mojo/shell/public/cpp/lib/service_provider_impl.cc
index 4a411a2..dc31a8b 100644
--- a/mojo/shell/public/cpp/lib/service_provider_impl.cc
+++ b/mojo/shell/public/cpp/lib/service_provider_impl.cc
@@ -28,7 +28,7 @@ void ServiceProviderImpl::ConnectToService(
const String& service_name,
ScopedMessagePipeHandle client_handle) {
// TODO(beng): perhaps take app connection thru ctor so that we can pass
- // ApplicationConnection through?
+ // Connection through?
service_connector_registry_.ConnectToService(nullptr, service_name,
std::move(client_handle));
}
diff --git a/mojo/shell/public/cpp/lib/service_registry.cc b/mojo/shell/public/cpp/lib/service_registry.cc
index 1425276..1df9976 100644
--- a/mojo/shell/public/cpp/lib/service_registry.cc
+++ b/mojo/shell/public/cpp/lib/service_registry.cc
@@ -10,7 +10,7 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/service_connector.h"
namespace mojo {
@@ -106,7 +106,7 @@ void ServiceRegistry::AddRemoteIDCallback(const Closure& callback) {
remote_id_callbacks_.push_back(callback);
}
-base::WeakPtr<ApplicationConnection> ServiceRegistry::GetWeakPtr() {
+base::WeakPtr<Connection> ServiceRegistry::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
diff --git a/mojo/shell/public/cpp/lib/service_registry.h b/mojo/shell/public/cpp/lib/service_registry.h
index 74c2e34..683e220 100644
--- a/mojo/shell/public/cpp/lib/service_registry.h
+++ b/mojo/shell/public/cpp/lib/service_registry.h
@@ -11,7 +11,7 @@
#include <string>
#include "mojo/public/cpp/bindings/binding.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/cpp/lib/service_connector_registry.h"
#include "mojo/shell/public/interfaces/service_provider.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -22,7 +22,7 @@ namespace internal {
// A ServiceRegistry represents each half of a connection between two
// applications, allowing customization of which services are published to the
// other.
-class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
+class ServiceRegistry : public ServiceProvider, public Connection {
public:
ServiceRegistry();
// |allowed_interfaces| are the set of interfaces that the shell has allowed
@@ -39,7 +39,7 @@ class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
shell::mojom::Shell::ConnectToApplicationCallback
GetConnectToApplicationCallback();
- // ApplicationConnection overrides.
+ // Connection overrides.
void SetServiceConnector(ServiceConnector* service_connector) override;
bool SetServiceConnectorForName(ServiceConnector* service_connector,
const std::string& interface_name) override;
@@ -52,7 +52,7 @@ class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
bool GetRemoteApplicationID(uint32_t* remote_id) const override;
bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override;
void AddRemoteIDCallback(const Closure& callback) override;
- base::WeakPtr<ApplicationConnection> GetWeakPtr() override;
+ base::WeakPtr<Connection> GetWeakPtr() override;
void RemoveServiceConnectorForName(const std::string& interface_name);
diff --git a/mojo/shell/public/cpp/lib/shell_client.cc b/mojo/shell/public/cpp/lib/shell_client.cc
new file mode 100644
index 0000000..b3e83b5
--- /dev/null
+++ b/mojo/shell/public/cpp/lib/shell_client.cc
@@ -0,0 +1,26 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/shell/public/cpp/shell_client.h"
+
+namespace mojo {
+
+ShellClient::ShellClient() {}
+ShellClient::~ShellClient() {}
+
+void ShellClient::Initialize(Shell* app, const std::string& url,
+ uint32_t id) {
+}
+
+bool ShellClient::AcceptConnection(Connection* connection) {
+ return false;
+}
+
+bool ShellClient::ShellConnectionLost() {
+ return true;
+}
+
+void ShellClient::Quit() {}
+
+} // namespace mojo
diff --git a/mojo/shell/public/cpp/service_connector.h b/mojo/shell/public/cpp/service_connector.h
index 8856e3f..5ba0192 100644
--- a/mojo/shell/public/cpp/service_connector.h
+++ b/mojo/shell/public/cpp/service_connector.h
@@ -11,7 +11,7 @@
namespace mojo {
-class ApplicationConnection;
+class Connection;
class ServiceConnector {
public:
@@ -20,7 +20,7 @@ class ServiceConnector {
// Asks the ServiceConnector to connect to the specified service. If the
// ServiceConnector connects to the service it should take ownership of
// the handle in |handle|.
- virtual void ConnectToService(ApplicationConnection* application_connection,
+ virtual void ConnectToService(Connection* connection,
const std::string& interface_name,
ScopedMessagePipeHandle handle) = 0;
};
diff --git a/mojo/shell/public/cpp/shell.h b/mojo/shell/public/cpp/shell.h
index 2a3acb3..1610693 100644
--- a/mojo/shell/public/cpp/shell.h
+++ b/mojo/shell/public/cpp/shell.h
@@ -6,7 +6,7 @@
#define MOJO_SHELL_PUBLIC_CPP_SHELL_H_
#include "mojo/shell/public/cpp/app_lifetime_helper.h"
-#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/cpp/connection.h"
#include "mojo/shell/public/interfaces/application.mojom.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
@@ -42,16 +42,16 @@ class Shell {
// Requests a new connection to an application. Returns a pointer to the
// connection if the connection is permitted by this application's delegate,
// or nullptr otherwise. Caller takes ownership.
- virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
+ virtual scoped_ptr<Connection> ConnectToApplication(
const std::string& url) = 0;
- virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
+ virtual scoped_ptr<Connection> ConnectToApplication(
ConnectParams* params) = 0;
// Connect to application identified by |request->url| and connect to the
// service implementation of the interface identified by |Interface|.
template <typename Interface>
void ConnectToService(ConnectParams* params, InterfacePtr<Interface>* ptr) {
- scoped_ptr<ApplicationConnection> connection = ConnectToApplication(params);
+ scoped_ptr<Connection> connection = ConnectToApplication(params);
if (!connection.get())
return;
connection->ConnectToService(ptr);
diff --git a/mojo/shell/public/cpp/application_delegate.h b/mojo/shell/public/cpp/shell_client.h
index b0a537f..e7c56d9 100644
--- a/mojo/shell/public/cpp/application_delegate.h
+++ b/mojo/shell/public/cpp/shell_client.h
@@ -2,40 +2,43 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
-#define MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
+#ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
+#define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
#include <stdint.h>
#include <string>
#include "mojo/public/cpp/system/macros.h"
+#include "mojo/shell/public/cpp/connection.h"
namespace mojo {
-class ApplicationConnection;
-class ApplicationImpl;
class Shell;
// An abstract class that the application may subclass to control various
// behaviors of ApplicationImpl.
-class ApplicationDelegate {
+class ShellClient {
public:
- ApplicationDelegate();
- virtual ~ApplicationDelegate();
+ ShellClient();
+ virtual ~ShellClient();
+ // Called once a bidirectional connection with the shell has been established.
+ // |url| is the URL used to start the application. |id| is a unique identifier
+ // the shell uses to identify this specific instance of the application.
// Called exactly once before any other method.
- virtual void Initialize(Shell* app, const std::string& url, uint32_t id);
+ virtual void Initialize(Shell* shell, const std::string& url, uint32_t id);
// Override this method to configure what services a connection supports when
// being connected to from an app.
- // Return false to reject the connection entirely.
- virtual bool AcceptConnection(ApplicationConnection* connection);
+ // Return false to reject the connection entirely. The default implementation
+ // returns false.
+ virtual bool AcceptConnection(Connection* connection);
// Called when the shell connection has a connection error.
//
// Return true to shutdown the application. Return false to skip shutting
// down the connection, but user is then required to call
- // ApplicationImpl::QuitNow() when done.
+ // ApplicationImpl::QuitNow() when done. Default implementation returns true.
virtual bool ShellConnectionLost();
// Called before ApplicationImpl::Terminate(). After returning from this call
@@ -43,9 +46,9 @@ class ApplicationDelegate {
virtual void Quit();
private:
- MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationDelegate);
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ShellClient);
};
} // namespace mojo
-#endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_DELEGATE_H_
+#endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_H_
diff --git a/mojo/shell/public/cpp/tests/service_registry_unittest.cc b/mojo/shell/public/cpp/tests/service_registry_unittest.cc
index 349e9aa..dc29d37 100644
--- a/mojo/shell/public/cpp/tests/service_registry_unittest.cc
+++ b/mojo/shell/public/cpp/tests/service_registry_unittest.cc
@@ -16,7 +16,7 @@ class TestConnector : public ServiceConnector {
public:
explicit TestConnector(int* delete_count) : delete_count_(delete_count) {}
~TestConnector() override { (*delete_count_)++; }
- void ConnectToService(ApplicationConnection* application_connection,
+ void ConnectToService(Connection* connection,
const std::string& interface_name,
ScopedMessagePipeHandle client_handle) override {}