OLD | NEW |
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_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "mojo/public/cpp/application/interface_provider.h" |
12 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 13 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
13 | 14 |
14 namespace mojo { | 15 namespace mojo { |
15 class ApplicationConnection; | 16 class ApplicationConnection; |
16 | 17 |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 template <class ServiceImpl, typename Context> | 20 template <class ServiceImpl, typename Context> |
20 class ServiceConnector; | 21 class ServiceConnector; |
21 | 22 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 Context* context() const { return context_; } | 129 Context* context() const { return context_; } |
129 | 130 |
130 private: | 131 private: |
131 typedef std::vector<ServiceImpl*> ConnectionList; | 132 typedef std::vector<ServiceImpl*> ConnectionList; |
132 ConnectionList connections_; | 133 ConnectionList connections_; |
133 Context* context_; | 134 Context* context_; |
134 | 135 |
135 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnector); | 136 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceConnector); |
136 }; | 137 }; |
137 | 138 |
| 139 template <typename Interface> |
| 140 class InterfaceProviderConnector : public ServiceConnectorBase { |
| 141 public: |
| 142 InterfaceProviderConnector(InterfaceProvider<Interface>* provider) |
| 143 : ServiceConnectorBase(Interface::Name_), provider_(provider) {} |
| 144 virtual ~InterfaceProviderConnector() {} |
| 145 |
| 146 virtual void ConnectToService(const std::string& name, |
| 147 ScopedMessagePipeHandle client_handle) { |
| 148 InterfaceRequest<Interface> request; |
| 149 request.Bind(client_handle.Pass()); |
| 150 provider_->BindToRequest(application_connection_, request.Pass()); |
| 151 } |
| 152 |
| 153 private: |
| 154 InterfaceProvider<Interface>* provider_; |
| 155 MOJO_DISALLOW_COPY_AND_ASSIGN(InterfaceProviderConnector); |
| 156 }; |
| 157 |
138 } // namespace internal | 158 } // namespace internal |
139 } // namespace mojo | 159 } // namespace mojo |
140 | 160 |
141 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ | 161 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_CONNECTOR_H_ |
OLD | NEW |