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 // Helpers for using |ServiceProvider|s. | 5 // Helpers for using |ServiceProvider|s. |
6 | 6 |
7 #ifndef MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ | 7 #ifndef MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ |
8 #define MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ | 8 #define MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ |
9 | 9 |
| 10 #include "mojo/public/cpp/bindings/interface_handle.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 11 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "mojo/public/interfaces/application/application_connector.mojom.h" | 12 #include "mojo/public/interfaces/application/application_connector.mojom.h" |
12 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 13 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
13 #include "mojo/public/interfaces/application/shell.mojom.h" | 14 #include "mojo/public/interfaces/application/shell.mojom.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 | 17 |
17 // Helper for using a |ServiceProvider|'s |ConnectToService()| that takes a | 18 // Helper for using a |ServiceProvider|'s |ConnectToService()| that takes a |
18 // fully-typed interface request (and can use the default interface name). Note | 19 // fully-typed interface request (and can use the default interface name). Note |
19 // that this can be used in conjunction with |GetProxy()|, etc. E.g.: | 20 // that this can be used in conjunction with |GetProxy()|, etc. E.g.: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 template <typename Interface> | 52 template <typename Interface> |
52 inline void ConnectToService(ApplicationConnector* application_connector, | 53 inline void ConnectToService(ApplicationConnector* application_connector, |
53 const std::string& application_url, | 54 const std::string& application_url, |
54 InterfaceRequest<Interface> request) { | 55 InterfaceRequest<Interface> request) { |
55 ServiceProviderPtr service_provider; | 56 ServiceProviderPtr service_provider; |
56 application_connector->ConnectToApplication( | 57 application_connector->ConnectToApplication( |
57 application_url, GetProxy(&service_provider), nullptr); | 58 application_url, GetProxy(&service_provider), nullptr); |
58 ConnectToService(service_provider.get(), request.Pass()); | 59 ConnectToService(service_provider.get(), request.Pass()); |
59 } | 60 } |
60 | 61 |
| 62 // Helper for getting an |InterfaceHandle<ApplicationConnector>| (which can be |
| 63 // passed to any thread) from the shell. |
| 64 InterfaceHandle<ApplicationConnector> CreateApplicationConnector(Shell* shell); |
| 65 |
61 } // namespace mojo | 66 } // namespace mojo |
62 | 67 |
63 #endif // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ | 68 #endif // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_ |
OLD | NEW |