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

Unified Diff: mojo/public/cpp/application/service_provider_impl.h

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, 4 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
« no previous file with comments | « mojo/public/cpp/application/lib/weak_service_provider.cc ('k') | mojo/services/html_viewer/html_viewer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/application/service_provider_impl.h
diff --git a/mojo/public/cpp/application/service_provider_impl.h b/mojo/public/cpp/application/service_provider_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..657be22b12a5a91301be431ef1d5c193a5d87e0b
--- /dev/null
+++ b/mojo/public/cpp/application/service_provider_impl.h
@@ -0,0 +1,64 @@
+// 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_SERVICE_PROVIDER_IMPL_H_
+#define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
+
+#include "mojo/public/cpp/application/lib/service_connector.h"
+#include "mojo/public/interfaces/application/service_provider.mojom.h"
+
+namespace mojo {
+namespace internal {
+class WeakServiceProvider;
+class ServiceConnectorBase;
+}
+
+// Implements a registry that can be used to expose services to another app.
+class ServiceProviderImpl : public InterfaceImpl<ServiceProvider> {
+ public:
+ ServiceProviderImpl();
+ virtual ~ServiceProviderImpl();
+
+ template <typename Interface>
+ void AddService(InterfaceFactory<Interface>* factory) {
+ AddServiceConnector(
+ new internal::InterfaceFactoryConnector<Interface>(factory));
+ }
+
+ // Returns an instance of a ServiceProvider that weakly wraps this impl's
+ // connection to some other app. Whereas the lifetime of an instance of
+ // ServiceProviderImpl is bound to the lifetime of the pipe it
+ // encapsulates, the lifetime of the ServiceProvider instance returned by this
+ // method is assumed by the caller. After the pipe is closed
+ // ConnectToService() calls on this object will be silently dropped.
+ // This method must only be called once per ServiceProviderImpl.
+ ServiceProvider* CreateRemoteServiceProvider();
+
+ private:
+ typedef std::map<std::string, internal::ServiceConnectorBase*>
+ NameToServiceConnectorMap;
+
+ // Overridden from ServiceProvider:
+ virtual void ConnectToService(
+ const String& service_name,
+ ScopedMessagePipeHandle client_handle) MOJO_OVERRIDE;
+
+ // Overridden from InterfaceImpl:
+ virtual void OnConnectionError() MOJO_OVERRIDE;
+
+ void AddServiceConnector(
+ internal::ServiceConnectorBase* service_connector);
+ void RemoveServiceConnector(
+ internal::ServiceConnectorBase* service_connector);
+
+ NameToServiceConnectorMap service_connectors_;
+
+ internal::WeakServiceProvider* remote_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl);
+};
+
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
« no previous file with comments | « mojo/public/cpp/application/lib/weak_service_provider.cc ('k') | mojo/services/html_viewer/html_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698