Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Unified Diff: mojo/public/cpp/application/lib/exported_service_registry.cc

Issue 433513005: Pass ServiceProvider thru ViewManagerService::Embed() allowing embedder & embeddee to expose servic… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/application/lib/exported_service_registry.cc
diff --git a/mojo/public/cpp/application/lib/exported_service_registry.cc b/mojo/public/cpp/application/lib/exported_service_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d0b1a1fd472d6a67b13675948c10a1b767505f12
--- /dev/null
+++ b/mojo/public/cpp/application/lib/exported_service_registry.cc
@@ -0,0 +1,49 @@
+// 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/exported_service_registry.h"
+
+#include "mojo/public/cpp/application/lib/service_connector.h"
+
+namespace mojo {
+
+ExportedServiceRegistry::ExportedServiceRegistry() : remote_(NULL) {
+}
+
+ExportedServiceRegistry::~ExportedServiceRegistry() {
+}
+
+void ExportedServiceRegistry::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 ExportedServiceRegistry::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(NULL);
+}
+
+void ExportedServiceRegistry::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);
+}
+
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698