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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
6 #define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
7
8 #include "mojo/public/cpp/application/lib/service_connector.h"
9 #include "mojo/public/interfaces/application/service_provider.mojom.h"
10
11 namespace mojo {
12 namespace internal {
13 class WeakServiceProvider;
14 class ServiceConnectorBase;
15 }
16
17 // Implements a registry that can be used to expose services to another app.
18 class ServiceProviderImpl : public InterfaceImpl<ServiceProvider> {
19 public:
20 ServiceProviderImpl();
21 virtual ~ServiceProviderImpl();
22
23 template <typename Interface>
24 void AddService(InterfaceFactory<Interface>* factory) {
25 AddServiceConnector(
26 new internal::InterfaceFactoryConnector<Interface>(factory));
27 }
28
29 // Returns an instance of a ServiceProvider that weakly wraps this impl's
30 // connection to some other app. Whereas the lifetime of an instance of
31 // ServiceProviderImpl is bound to the lifetime of the pipe it
32 // encapsulates, the lifetime of the ServiceProvider instance returned by this
33 // method is assumed by the caller. After the pipe is closed
34 // ConnectToService() calls on this object will be silently dropped.
35 // This method must only be called once per ServiceProviderImpl.
36 ServiceProvider* CreateRemoteServiceProvider();
37
38 private:
39 typedef std::map<std::string, internal::ServiceConnectorBase*>
40 NameToServiceConnectorMap;
41
42 // Overridden from ServiceProvider:
43 virtual void ConnectToService(
44 const String& service_name,
45 ScopedMessagePipeHandle client_handle) MOJO_OVERRIDE;
46
47 // Overridden from InterfaceImpl:
48 virtual void OnConnectionError() MOJO_OVERRIDE;
49
50 void AddServiceConnector(
51 internal::ServiceConnectorBase* service_connector);
52 void RemoveServiceConnector(
53 internal::ServiceConnectorBase* service_connector);
54
55 NameToServiceConnectorMap service_connectors_;
56
57 internal::WeakServiceProvider* remote_;
58
59 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl);
60 };
61
62 } // namespace mojo
63
64 #endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
OLDNEW
« 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