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

Side by Side Diff: third_party/mojo/src/mojo/public/cpp/application/service_provider_impl.h

Issue 1127293003: Update mojo sdk to rev f84766d3b6420b7cf6a113d9d65d73cb5fe18d90 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge IPC fixes Created 5 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ 5 #ifndef MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
6 #define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ 6 #define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
7 7
8 #include "mojo/public/cpp/application/lib/service_connector.h" 8 #include <string>
9
10 #include "mojo/public/cpp/application/lib/interface_factory_connector.h"
11 #include "mojo/public/cpp/application/lib/service_connector_registry.h"
9 #include "mojo/public/cpp/bindings/binding.h" 12 #include "mojo/public/cpp/bindings/binding.h"
10 #include "mojo/public/interfaces/application/service_provider.mojom.h" 13 #include "mojo/public/interfaces/application/service_provider.mojom.h"
11 14
12 namespace mojo { 15 namespace mojo {
13 namespace internal {
14 class ServiceConnectorBase;
15 }
16 16
17 // Implements a registry that can be used to expose services to another app. 17 // Implements a registry that can be used to expose services to another app.
18 class ServiceProviderImpl : public ServiceProvider { 18 class ServiceProviderImpl : public ServiceProvider {
19 public: 19 public:
20 ServiceProviderImpl(); 20 ServiceProviderImpl();
21 explicit ServiceProviderImpl(InterfaceRequest<ServiceProvider> request); 21 explicit ServiceProviderImpl(InterfaceRequest<ServiceProvider> request);
22 ~ServiceProviderImpl() override; 22 ~ServiceProviderImpl() override;
23 23
24 void Bind(InterfaceRequest<ServiceProvider> request); 24 void Bind(InterfaceRequest<ServiceProvider> request);
25 // Disconnect this service provider and put it in a state where it can be 25 // Disconnect this service provider and put it in a state where it can be
26 // rebound to a new request. 26 // rebound to a new request.
27 void Close(); 27 void Close();
28 28
29 template <typename Interface> 29 template <typename Interface>
30 void AddService(InterfaceFactory<Interface>* factory) { 30 void AddService(InterfaceFactory<Interface>* factory) {
31 AddServiceConnector( 31 SetServiceConnectorForName(
32 new internal::InterfaceFactoryConnector<Interface>(factory)); 32 new internal::InterfaceFactoryConnector<Interface>(factory),
33 Interface::Name_);
33 } 34 }
34 35
35 private: 36 private:
36 typedef std::map<std::string, internal::ServiceConnectorBase*>
37 NameToServiceConnectorMap;
38
39 // Overridden from ServiceProvider: 37 // Overridden from ServiceProvider:
40 void ConnectToService(const String& service_name, 38 void ConnectToService(const String& service_name,
41 ScopedMessagePipeHandle client_handle) override; 39 ScopedMessagePipeHandle client_handle) override;
42 40
43 void AddServiceConnector(internal::ServiceConnectorBase* service_connector); 41 void SetServiceConnectorForName(ServiceConnector* service_connector,
44 void RemoveServiceConnector( 42 const std::string& interface_name);
45 internal::ServiceConnectorBase* service_connector);
46
47 NameToServiceConnectorMap service_connectors_;
48 43
49 Binding<ServiceProvider> binding_; 44 Binding<ServiceProvider> binding_;
50 45
46 internal::ServiceConnectorRegistry service_connector_registry_;
47
51 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl); 48 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl);
52 }; 49 };
53 50
54 } // namespace mojo 51 } // namespace mojo
55 52
56 #endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ 53 #endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698