summaryrefslogtreecommitdiffstats
path: root/mojo/public/cpp/application/lib/application.cc
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 15:51:00 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-27 15:51:00 +0000
commit922f25039d939159501fad266518290b2c05fe2a (patch)
tree82f23eaa36a8d86f86d86b7f8aa85c487629057d /mojo/public/cpp/application/lib/application.cc
parentbcbdd98cc4d033b29fa633cbc1c81599ba6d9977 (diff)
downloadchromium_src-922f25039d939159501fad266518290b2c05fe2a.zip
chromium_src-922f25039d939159501fad266518290b2c05fe2a.tar.gz
chromium_src-922f25039d939159501fad266518290b2c05fe2a.tar.bz2
Change Shell / ShellClient to ServiceProvider
BUG= R=darin@chromium.org Review URL: https://codereview.chromium.org/298653010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/public/cpp/application/lib/application.cc')
-rw-r--r--mojo/public/cpp/application/lib/application.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/mojo/public/cpp/application/lib/application.cc b/mojo/public/cpp/application/lib/application.cc
new file mode 100644
index 0000000..72ce5802
--- /dev/null
+++ b/mojo/public/cpp/application/lib/application.cc
@@ -0,0 +1,55 @@
+// 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.h"
+
+namespace mojo {
+
+Application::Application(ScopedMessagePipeHandle service_provider_handle)
+ : internal::ServiceConnectorBase::Owner(service_provider_handle.Pass()) {
+}
+
+Application::Application(MojoHandle service_provider_handle)
+ : internal::ServiceConnectorBase::Owner(
+ mojo::MakeScopedHandle(
+ MessagePipeHandle(service_provider_handle)).Pass()) {}
+
+Application::~Application() {
+ for (ServiceConnectorList::iterator it = service_connectors_.begin();
+ it != service_connectors_.end(); ++it) {
+ delete *it;
+ }
+}
+
+void Application::AddServiceConnector(
+ internal::ServiceConnectorBase* service_connector) {
+ service_connectors_.push_back(service_connector);
+ set_service_connector_owner(service_connector, this);
+}
+
+void Application::RemoveServiceConnector(
+ internal::ServiceConnectorBase* service_connector) {
+ for (ServiceConnectorList::iterator it = service_connectors_.begin();
+ it != service_connectors_.end(); ++it) {
+ if (*it == service_connector) {
+ service_connectors_.erase(it);
+ delete service_connector;
+ break;
+ }
+ }
+ if (service_connectors_.empty())
+ service_provider_.reset();
+}
+
+void Application::ConnectToService(const mojo::String& url,
+ ScopedMessagePipeHandle client_handle) {
+ // TODO(davemoore): This method must be overridden by an Application subclass
+ // to dispatch to the right ServiceConnector. We need to figure out an
+ // approach to registration to make this better.
+ assert(1 == service_connectors_.size());
+ return service_connectors_.front()->ConnectToService(url.To<std::string>(),
+ client_handle.Pass());
+}
+
+} // namespace mojo