summaryrefslogtreecommitdiffstats
path: root/mojo/public/cpp/application/lib
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/public/cpp/application/lib')
-rw-r--r--mojo/public/cpp/application/lib/DEPS3
-rw-r--r--mojo/public/cpp/application/lib/application_connection.cc12
-rw-r--r--mojo/public/cpp/application/lib/application_delegate.cc27
-rw-r--r--mojo/public/cpp/application/lib/application_impl.cc117
-rw-r--r--mojo/public/cpp/application/lib/application_runner.cc39
-rw-r--r--mojo/public/cpp/application/lib/application_test_base.cc129
-rw-r--r--mojo/public/cpp/application/lib/application_test_main.cc14
-rw-r--r--mojo/public/cpp/application/lib/service_connector.cc18
-rw-r--r--mojo/public/cpp/application/lib/service_connector.h55
-rw-r--r--mojo/public/cpp/application/lib/service_provider_impl.cc69
-rw-r--r--mojo/public/cpp/application/lib/service_registry.cc91
-rw-r--r--mojo/public/cpp/application/lib/service_registry.h64
-rw-r--r--mojo/public/cpp/application/lib/weak_service_provider.cc36
-rw-r--r--mojo/public/cpp/application/lib/weak_service_provider.h41
14 files changed, 0 insertions, 715 deletions
diff --git a/mojo/public/cpp/application/lib/DEPS b/mojo/public/cpp/application/lib/DEPS
deleted file mode 100644
index a04ed0f..0000000
--- a/mojo/public/cpp/application/lib/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+mojo/public/cpp/utility",
-]
diff --git a/mojo/public/cpp/application/lib/application_connection.cc b/mojo/public/cpp/application/lib/application_connection.cc
deleted file mode 100644
index d557817..0000000
--- a/mojo/public/cpp/application/lib/application_connection.cc
+++ /dev/null
@@ -1,12 +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/public/cpp/application/application_connection.h"
-
-namespace mojo {
-
-ApplicationConnection::~ApplicationConnection() {
-}
-
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_delegate.cc b/mojo/public/cpp/application/lib/application_delegate.cc
deleted file mode 100644
index bd6aebd..0000000
--- a/mojo/public/cpp/application/lib/application_delegate.cc
+++ /dev/null
@@ -1,27 +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/public/cpp/application/application_delegate.h"
-
-namespace mojo {
-
-ApplicationDelegate::ApplicationDelegate() {
-}
-ApplicationDelegate::~ApplicationDelegate() {
-}
-
-void ApplicationDelegate::Initialize(ApplicationImpl* app) {
-}
-
-bool ApplicationDelegate::ConfigureIncomingConnection(
- ApplicationConnection* connection) {
- return true;
-}
-
-bool ApplicationDelegate::ConfigureOutgoingConnection(
- ApplicationConnection* connection) {
- return true;
-}
-
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_impl.cc b/mojo/public/cpp/application/lib/application_impl.cc
deleted file mode 100644
index 6677003..0000000
--- a/mojo/public/cpp/application/lib/application_impl.cc
+++ /dev/null
@@ -1,117 +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/public/cpp/application/application_impl.h"
-
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/lib/service_registry.h"
-#include "mojo/public/cpp/bindings/interface_ptr.h"
-#include "mojo/public/cpp/environment/logging.h"
-
-namespace mojo {
-
-class ApplicationImpl::ShellPtrWatcher : public ErrorHandler {
- public:
- ShellPtrWatcher(ApplicationImpl* impl) : impl_(impl) {}
-
- ~ShellPtrWatcher() override {}
-
- void OnConnectionError() override { impl_->OnShellError(); }
-
- private:
- ApplicationImpl* impl_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher);
-};
-
-ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
- ScopedMessagePipeHandle shell_handle)
- : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
- BindShell(shell_handle.Pass());
-}
-
-ApplicationImpl::ApplicationImpl(ApplicationDelegate* delegate,
- MojoHandle shell_handle)
- : initialized_(false), delegate_(delegate), shell_watch_(nullptr) {
- BindShell(MakeScopedHandle(MessagePipeHandle(shell_handle)));
-}
-
-bool ApplicationImpl::HasArg(const std::string& arg) const {
- return std::find(args_.begin(), args_.end(), arg) != args_.end();
-}
-
-void ApplicationImpl::ClearConnections() {
- for (ServiceRegistryList::iterator i(incoming_service_registries_.begin());
- i != incoming_service_registries_.end();
- ++i)
- delete *i;
- for (ServiceRegistryList::iterator i(outgoing_service_registries_.begin());
- i != outgoing_service_registries_.end();
- ++i)
- delete *i;
- incoming_service_registries_.clear();
- outgoing_service_registries_.clear();
-}
-
-ApplicationImpl::~ApplicationImpl() {
- ClearConnections();
- delete shell_watch_;
-}
-
-ApplicationConnection* ApplicationImpl::ConnectToApplication(
- const String& application_url) {
- MOJO_CHECK(initialized_);
- ServiceProviderPtr local_services;
- InterfaceRequest<ServiceProvider> local_request = GetProxy(&local_services);
- ServiceProviderPtr remote_services;
- shell_->ConnectToApplication(application_url, GetProxy(&remote_services),
- local_services.Pass());
- internal::ServiceRegistry* registry = new internal::ServiceRegistry(
- this, application_url, remote_services.Pass(), local_request.Pass());
- if (!delegate_->ConfigureOutgoingConnection(registry)) {
- delete registry;
- return nullptr;
- }
- outgoing_service_registries_.push_back(registry);
- return registry;
-}
-
-bool ApplicationImpl::WaitForInitialize() {
- MOJO_CHECK(!initialized_);
- bool result = shell_.WaitForIncomingMethodCall();
- MOJO_CHECK(initialized_ || !result);
- return result;
-}
-
-ScopedMessagePipeHandle ApplicationImpl::UnbindShell() {
- return shell_.PassMessagePipe();
-}
-
-void ApplicationImpl::Initialize(Array<String> args) {
- MOJO_CHECK(!initialized_);
- initialized_ = true;
- args_ = args.To<std::vector<std::string>>();
- delegate_->Initialize(this);
-}
-
-void ApplicationImpl::BindShell(ScopedMessagePipeHandle shell_handle) {
- shell_watch_ = new ShellPtrWatcher(this);
- shell_.Bind(shell_handle.Pass());
- shell_.set_client(this);
- shell_.set_error_handler(shell_watch_);
-}
-
-void ApplicationImpl::AcceptConnection(
- const String& requestor_url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) {
- internal::ServiceRegistry* registry = new internal::ServiceRegistry(
- this, requestor_url, exposed_services.Pass(), services.Pass());
- if (!delegate_->ConfigureIncomingConnection(registry)) {
- delete registry;
- return;
- }
- incoming_service_registries_.push_back(registry);
-}
-
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_runner.cc b/mojo/public/cpp/application/lib/application_runner.cc
deleted file mode 100644
index dec74489..0000000
--- a/mojo/public/cpp/application/lib/application_runner.cc
+++ /dev/null
@@ -1,39 +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/public/cpp/application/application_runner.h"
-
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/environment/environment.h"
-#include "mojo/public/cpp/utility/run_loop.h"
-
-namespace mojo {
-
-// static
-void ApplicationImpl::Terminate() {
- RunLoop::current()->Quit();
-}
-
-ApplicationRunner::ApplicationRunner(ApplicationDelegate* delegate)
- : delegate_(delegate) {
-}
-ApplicationRunner::~ApplicationRunner() {
- assert(!delegate_);
-}
-
-MojoResult ApplicationRunner::Run(MojoHandle shell_handle) {
- Environment env;
- {
- RunLoop loop;
- ApplicationImpl app(delegate_, shell_handle);
- loop.Run();
- }
-
- delete delegate_;
- delegate_ = nullptr;
- return MOJO_RESULT_OK;
-}
-
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_test_base.cc b/mojo/public/cpp/application/lib/application_test_base.cc
deleted file mode 100644
index 20a60a1..0000000
--- a/mojo/public/cpp/application/lib/application_test_base.cc
+++ /dev/null
@@ -1,129 +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/public/cpp/application/application_test_base.h"
-
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/environment/environment.h"
-#include "mojo/public/cpp/system/message_pipe.h"
-
-namespace mojo {
-namespace test {
-
-namespace {
-
-// This shell handle is shared by multiple test application instances.
-MessagePipeHandle g_shell_handle;
-// Share the application command-line arguments with multiple application tests.
-Array<String> g_args;
-
-ScopedMessagePipeHandle PassShellHandle() {
- MOJO_CHECK(g_shell_handle.is_valid());
- ScopedMessagePipeHandle scoped_handle(g_shell_handle);
- g_shell_handle = MessagePipeHandle();
- return scoped_handle.Pass();
-}
-
-void SetShellHandle(ScopedMessagePipeHandle handle) {
- MOJO_CHECK(handle.is_valid());
- MOJO_CHECK(!g_shell_handle.is_valid());
- g_shell_handle = handle.release();
-}
-
-void InitializeArgs(int argc, std::vector<const char*> argv) {
- MOJO_CHECK(g_args.is_null());
- for (const char* arg : argv) {
- if (arg)
- g_args.push_back(arg);
- }
-}
-
-} // namespace
-
-const Array<String>& Args() {
- return g_args;
-}
-
-MojoResult RunAllTests(MojoHandle shell_handle) {
- {
- // This loop is used for init, and then destroyed before running tests.
- Environment::InstantiateDefaultRunLoop();
-
- // Construct an ApplicationImpl just for the GTEST commandline arguments.
- // GTEST command line arguments are supported amid application arguments:
- // $ mojo_shell mojo:example_apptests
- // --args-for='mojo:example_apptests arg1 --gtest_filter=foo arg2'
- mojo::ApplicationDelegate dummy_application_delegate;
- mojo::ApplicationImpl app(&dummy_application_delegate, shell_handle);
- MOJO_CHECK(app.WaitForInitialize());
-
- // InitGoogleTest expects (argc + 1) elements, including a terminating null.
- // It also removes GTEST arguments from |argv| and updates the |argc| count.
- const std::vector<std::string>& args = app.args();
- MOJO_CHECK(args.size() <
- static_cast<size_t>(std::numeric_limits<int>::max()));
- int argc = static_cast<int>(args.size());
- std::vector<const char*> argv(argc + 1);
- for (int i = 0; i < argc; ++i)
- argv[i] = args[i].c_str();
- argv[argc] = nullptr;
-
- testing::InitGoogleTest(&argc, const_cast<char**>(&(argv[0])));
- SetShellHandle(app.UnbindShell());
- InitializeArgs(argc, argv);
-
- Environment::DestroyDefaultRunLoop();
- }
-
- int result = RUN_ALL_TESTS();
-
- shell_handle = mojo::test::PassShellHandle().release().value();
- MojoResult close_result = MojoClose(shell_handle);
- MOJO_CHECK(close_result == MOJO_RESULT_OK);
-
- return (result == 0) ? MOJO_RESULT_OK : MOJO_RESULT_UNKNOWN;
-}
-
-ApplicationTestBase::ApplicationTestBase() : application_impl_(nullptr) {
-}
-
-ApplicationTestBase::~ApplicationTestBase() {
-}
-
-ApplicationDelegate* ApplicationTestBase::GetApplicationDelegate() {
- return &default_application_delegate_;
-}
-
-void ApplicationTestBase::SetUpWithArgs(const Array<String>& args) {
- // A run loop is recommended for ApplicationImpl initialization and
- // communication.
- if (ShouldCreateDefaultRunLoop())
- Environment::InstantiateDefaultRunLoop();
-
- // New applications are constructed for each test to avoid persisting state.
- application_impl_ = new ApplicationImpl(GetApplicationDelegate(),
- PassShellHandle());
-
- // Fake application initialization with the given command line arguments.
- application_impl_->Initialize(args.Clone());
-}
-
-void ApplicationTestBase::SetUp() {
- SetUpWithArgs(Args());
-}
-
-void ApplicationTestBase::TearDown() {
- SetShellHandle(application_impl_->UnbindShell());
- delete application_impl_;
- if (ShouldCreateDefaultRunLoop())
- Environment::DestroyDefaultRunLoop();
-}
-
-bool ApplicationTestBase::ShouldCreateDefaultRunLoop() {
- return true;
-}
-
-} // namespace test
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/application_test_main.cc b/mojo/public/cpp/application/lib/application_test_main.cc
deleted file mode 100644
index 47f36e9..0000000
--- a/mojo/public/cpp/application/lib/application_test_main.cc
+++ /dev/null
@@ -1,14 +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/public/c/system/main.h"
-#include "mojo/public/cpp/application/application_test_base.h"
-#include "mojo/public/cpp/environment/environment.h"
-
-MojoResult MojoMain(MojoHandle shell_handle) {
- // An Environment instance is needed to construct run loops.
- mojo::Environment environment;
-
- return mojo::test::RunAllTests(shell_handle);
-}
diff --git a/mojo/public/cpp/application/lib/service_connector.cc b/mojo/public/cpp/application/lib/service_connector.cc
deleted file mode 100644
index ada5d9c..0000000
--- a/mojo/public/cpp/application/lib/service_connector.cc
+++ /dev/null
@@ -1,18 +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/public/cpp/application/lib/service_connector.h"
-
-namespace mojo {
-namespace internal {
-
-ServiceConnectorBase::ServiceConnectorBase(const std::string& name)
- : name_(name), application_connection_(nullptr) {
-}
-
-ServiceConnectorBase::~ServiceConnectorBase() {
-}
-
-} // namespace internal
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/service_connector.h b/mojo/public/cpp/application/lib/service_connector.h
deleted file mode 100644
index 70c1380..0000000
--- a/mojo/public/cpp/application/lib/service_connector.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
-#define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
-
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "mojo/public/cpp/bindings/interface_request.h"
-
-namespace mojo {
-class ApplicationConnection;
-
-namespace internal {
-
-class ServiceConnectorBase {
- public:
- ServiceConnectorBase(const std::string& name);
- virtual ~ServiceConnectorBase();
- virtual void ConnectToService(const std::string& name,
- ScopedMessagePipeHandle client_handle) = 0;
- std::string name() const { return name_; }
- void set_application_connection(ApplicationConnection* connection) {
- application_connection_ = connection;
- }
-
- protected:
- std::string name_;
- ApplicationConnection* application_connection_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnectorBase);
-};
-
-template <typename Interface>
-class InterfaceFactoryConnector : public ServiceConnectorBase {
- public:
- explicit InterfaceFactoryConnector(InterfaceFactory<Interface>* factory)
- : ServiceConnectorBase(Interface::Name_), factory_(factory) {}
- virtual ~InterfaceFactoryConnector() {}
-
- virtual void ConnectToService(const std::string& name,
- ScopedMessagePipeHandle client_handle) {
- factory_->Create(application_connection_,
- MakeRequest<Interface>(client_handle.Pass()));
- }
-
- private:
- InterfaceFactory<Interface>* factory_;
- MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceFactoryConnector);
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_
diff --git a/mojo/public/cpp/application/lib/service_provider_impl.cc b/mojo/public/cpp/application/lib/service_provider_impl.cc
deleted file mode 100644
index 08a0648..0000000
--- a/mojo/public/cpp/application/lib/service_provider_impl.cc
+++ /dev/null
@@ -1,69 +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/public/cpp/application/service_provider_impl.h"
-
-#include "mojo/public/cpp/application/lib/service_connector.h"
-#include "mojo/public/cpp/application/lib/weak_service_provider.h"
-#include "mojo/public/cpp/environment/logging.h"
-
-namespace mojo {
-
-ServiceProviderImpl::ServiceProviderImpl() : remote_(nullptr) {
-}
-
-ServiceProviderImpl::~ServiceProviderImpl() {
-}
-
-ServiceProvider* ServiceProviderImpl::CreateRemoteServiceProvider() {
- // TODO(beng): it sure would be nice if this method could return a scoped_ptr.
- MOJO_DCHECK(!remote_);
- remote_ = new internal::WeakServiceProvider(this, client());
- return remote_;
-}
-
-void ServiceProviderImpl::ConnectToService(
- const String& service_name,
- ScopedMessagePipeHandle client_handle) {
- if (service_connectors_.find(service_name) == service_connectors_.end()) {
- client_handle.reset();
- return;
- }
-
- internal::ServiceConnectorBase* service_connector =
- service_connectors_[service_name];
- return service_connector->ConnectToService(service_name,
- client_handle.Pass());
-}
-
-void ServiceProviderImpl::OnConnectionError() {
- ClearRemote();
-}
-
-void ServiceProviderImpl::AddServiceConnector(
- internal::ServiceConnectorBase* service_connector) {
- RemoveServiceConnector(service_connector);
- service_connectors_[service_connector->name()] = service_connector;
- // TODO(beng): perhaps take app connection thru ctor??
- service_connector->set_application_connection(nullptr);
-}
-
-void ServiceProviderImpl::RemoveServiceConnector(
- internal::ServiceConnectorBase* service_connector) {
- NameToServiceConnectorMap::iterator it =
- service_connectors_.find(service_connector->name());
- if (it == service_connectors_.end())
- return;
- delete it->second;
- service_connectors_.erase(it);
-}
-
-void ServiceProviderImpl::ClearRemote() {
- if (remote_) {
- remote_->Clear();
- remote_ = nullptr;
- }
-}
-
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/service_registry.cc b/mojo/public/cpp/application/lib/service_registry.cc
deleted file mode 100644
index d934a16..0000000
--- a/mojo/public/cpp/application/lib/service_registry.cc
+++ /dev/null
@@ -1,91 +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/public/cpp/application/lib/service_registry.h"
-
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/lib/service_connector.h"
-
-namespace mojo {
-namespace internal {
-
-ServiceRegistry::ServiceRegistry(
- ApplicationImpl* application_impl,
- const std::string& url,
- ServiceProviderPtr remote_services,
- InterfaceRequest<ServiceProvider> local_services)
- : application_impl_(application_impl),
- url_(url),
- local_binding_(this, local_services.Pass()),
- remote_service_provider_(remote_services.Pass()) {
-}
-
-ServiceRegistry::ServiceRegistry()
- : application_impl_(nullptr), local_binding_(this) {
-}
-
-ServiceRegistry::~ServiceRegistry() {
- for (NameToServiceConnectorMap::iterator i =
- name_to_service_connector_.begin();
- i != name_to_service_connector_.end();
- ++i) {
- delete i->second;
- }
- name_to_service_connector_.clear();
-}
-
-void ServiceRegistry::AddServiceConnector(
- ServiceConnectorBase* service_connector) {
- RemoveServiceConnectorInternal(service_connector);
- name_to_service_connector_[service_connector->name()] = service_connector;
- service_connector->set_application_connection(this);
-}
-
-void ServiceRegistry::RemoveServiceConnector(
- ServiceConnectorBase* service_connector) {
- RemoveServiceConnectorInternal(service_connector);
- if (name_to_service_connector_.empty())
- remote_service_provider_.reset();
-}
-
-bool ServiceRegistry::RemoveServiceConnectorInternal(
- ServiceConnectorBase* service_connector) {
- NameToServiceConnectorMap::iterator it =
- name_to_service_connector_.find(service_connector->name());
- if (it == name_to_service_connector_.end())
- return false;
- delete it->second;
- name_to_service_connector_.erase(it);
- return true;
-}
-
-const std::string& ServiceRegistry::GetRemoteApplicationURL() {
- return url_;
-}
-
-ServiceProvider* ServiceRegistry::GetServiceProvider() {
- return remote_service_provider_.get();
-}
-
-ApplicationConnection* ServiceRegistry::ConnectToApplication(
- const std::string& url) {
- return application_impl_->ConnectToApplication(url);
-}
-
-void ServiceRegistry::ConnectToService(const mojo::String& service_name,
- ScopedMessagePipeHandle client_handle) {
- if (name_to_service_connector_.find(service_name) ==
- name_to_service_connector_.end()) {
- client_handle.reset();
- return;
- }
- internal::ServiceConnectorBase* service_connector =
- name_to_service_connector_[service_name];
- return service_connector->ConnectToService(service_name,
- client_handle.Pass());
-}
-
-} // namespace internal
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/service_registry.h b/mojo/public/cpp/application/lib/service_registry.h
deleted file mode 100644
index af1613b..0000000
--- a/mojo/public/cpp/application/lib/service_registry.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
-#define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
-
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-
-namespace mojo {
-
-class Application;
-class ApplicationImpl;
-
-namespace internal {
-
-class ServiceConnectorBase;
-
-// 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 {
- public:
- ServiceRegistry();
- ServiceRegistry(ApplicationImpl* application_impl,
- const std::string& url,
- ServiceProviderPtr remote_services,
- InterfaceRequest<ServiceProvider> local_services);
- ~ServiceRegistry() override;
-
- // ApplicationConnection overrides.
- void AddServiceConnector(ServiceConnectorBase* service_connector) override;
- const std::string& GetRemoteApplicationURL() override;
- ApplicationConnection* ConnectToApplication(const std::string& url) override;
- ServiceProvider* GetServiceProvider() override;
-
- virtual void RemoveServiceConnector(ServiceConnectorBase* service_connector);
-
- private:
- // ServiceProvider method.
- void ConnectToService(const mojo::String& service_name,
- ScopedMessagePipeHandle client_handle) override;
-
- ApplicationImpl* application_impl_;
- const std::string url_;
-
- private:
- bool RemoveServiceConnectorInternal(ServiceConnectorBase* service_connector);
-
- Application* application_;
- typedef std::map<std::string, ServiceConnectorBase*>
- NameToServiceConnectorMap;
- NameToServiceConnectorMap name_to_service_connector_;
- Binding<ServiceProvider> local_binding_;
- ServiceProviderPtr remote_service_provider_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
diff --git a/mojo/public/cpp/application/lib/weak_service_provider.cc b/mojo/public/cpp/application/lib/weak_service_provider.cc
deleted file mode 100644
index de0cb6c..0000000
--- a/mojo/public/cpp/application/lib/weak_service_provider.cc
+++ /dev/null
@@ -1,36 +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/public/cpp/application/lib/weak_service_provider.h"
-
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-
-namespace mojo {
-namespace internal {
-
-WeakServiceProvider::WeakServiceProvider(ServiceProviderImpl* creator,
- ServiceProvider* service_provider)
- : creator_(creator), service_provider_(service_provider) {
-}
-
-WeakServiceProvider::~WeakServiceProvider() {
- if (creator_)
- creator_->ClearRemote();
-}
-
-void WeakServiceProvider::Clear() {
- creator_ = nullptr;
- service_provider_ = nullptr;
-}
-
-void WeakServiceProvider::ConnectToService(
- const String& service_name,
- ScopedMessagePipeHandle client_handle) {
- if (service_provider_)
- service_provider_->ConnectToService(service_name, client_handle.Pass());
-}
-
-} // namespace internal
-} // namespace mojo
diff --git a/mojo/public/cpp/application/lib/weak_service_provider.h b/mojo/public/cpp/application/lib/weak_service_provider.h
deleted file mode 100644
index 3d959d1..0000000
--- a/mojo/public/cpp/application/lib/weak_service_provider.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef MOJO_PUBLIC_APPLICATION_LIB_WEAK_SERVICE_PROVIDER_H_
-#define MOJO_PUBLIC_APPLICATION_LIB_WEAK_SERVICE_PROVIDER_H_
-
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-
-namespace mojo {
-class ServiceProviderImpl;
-namespace internal {
-class ServiceConnectorBase;
-
-// Implements a weak pointer to a ServiceProvider. Necessary as the lifetime of
-// the ServiceProviderImpl is bound to that of its pipe, but code may continue
-// to reference a remote service provider beyond the lifetime of said pipe.
-// Calls to ConnectToService() are silently dropped when the pipe is closed.
-class WeakServiceProvider : public ServiceProvider {
- public:
- WeakServiceProvider(ServiceProviderImpl* creator,
- ServiceProvider* service_provider);
- ~WeakServiceProvider() override;
-
- void Clear();
-
- private:
- // Overridden from ServiceProvider:
- void ConnectToService(const String& service_name,
- ScopedMessagePipeHandle client_handle) override;
-
- ServiceProviderImpl* creator_;
- ServiceProvider* service_provider_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(WeakServiceProvider);
-};
-
-} // namespace internal
-} // namespace mojo
-
-#endif // MOJO_PUBLIC_APPLICATION_LIB_WEAK_SERVICE_PROVIDER_H_