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_APPLICATION_APPLICATION_CONNECTION_H_ | 5 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ |
6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ | 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "mojo/public/cpp/application/interface_provider.h" |
10 #include "mojo/public/cpp/application/lib/service_connector.h" | 11 #include "mojo/public/cpp/application/lib/service_connector.h" |
11 | 12 |
12 namespace mojo { | 13 namespace mojo { |
13 | 14 |
14 // An instance of this class is passed to | 15 // An instance of this class is passed to |
15 // ApplicationDelegate's ConfigureIncomingConnection() method each time a | 16 // ApplicationDelegate's ConfigureIncomingConnection() method each time a |
16 // connection is made to this app, and to ApplicationDelegate's | 17 // connection is made to this app, and to ApplicationDelegate's |
17 // ConfigureOutgoingConnection() method when the app connects to | 18 // ConfigureOutgoingConnection() method when the app connects to |
18 // another. | 19 // another. |
19 // | 20 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Impl’s constructor will receive two arguments: | 54 // Impl’s constructor will receive two arguments: |
54 // Impl::Impl(Application::Context* app_context, | 55 // Impl::Impl(Application::Context* app_context, |
55 // ServiceContext* svc_context) | 56 // ServiceContext* svc_context) |
56 template <typename Impl, typename ServiceContext> | 57 template <typename Impl, typename ServiceContext> |
57 void AddService(ServiceContext* context) { | 58 void AddService(ServiceContext* context) { |
58 AddServiceConnector( | 59 AddServiceConnector( |
59 new internal::ServiceConnector<Impl, ServiceContext>(Impl::Name_, | 60 new internal::ServiceConnector<Impl, ServiceContext>(Impl::Name_, |
60 context)); | 61 context)); |
61 } | 62 } |
62 | 63 |
| 64 template <typename Interface> |
| 65 void AddServiceProvider(InterfaceProvider<Interface>* provider) { |
| 66 AddServiceConnector( |
| 67 new internal::InterfaceProviderConnector<Interface>(provider)); |
| 68 } |
| 69 |
63 // Impl’s constructor will receive one argument: | 70 // Impl’s constructor will receive one argument: |
64 // Impl::Impl(Application::Context* app_context) | 71 // Impl::Impl(Application::Context* app_context) |
65 template <typename Impl> | 72 template <typename Impl> |
66 void AddService() { | 73 void AddService() { |
67 AddServiceConnector( | 74 AddServiceConnector( |
68 new internal::ServiceConnector<Impl, void>(Impl::Name_, NULL)); | 75 new internal::ServiceConnector<Impl, void>(Impl::Name_, NULL)); |
69 } | 76 } |
70 | 77 |
71 // Connect to the service implementing |Interface|. | 78 // Connect to the service implementing |Interface|. |
72 template <typename Interface> | 79 template <typename Interface> |
(...skipping 24 matching lines...) Expand all Loading... |
97 virtual ServiceProvider* GetServiceProvider() = 0; | 104 virtual ServiceProvider* GetServiceProvider() = 0; |
98 | 105 |
99 private: | 106 private: |
100 virtual void AddServiceConnector( | 107 virtual void AddServiceConnector( |
101 internal::ServiceConnectorBase* service_connector) = 0; | 108 internal::ServiceConnectorBase* service_connector) = 0; |
102 }; | 109 }; |
103 | 110 |
104 } // namespace mojo | 111 } // namespace mojo |
105 | 112 |
106 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ | 113 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ |
OLD | NEW |