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/lib/interface_factory_connector.h" | 10 #include "mojo/public/cpp/application/lib/interface_factory_connector.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 Interface::Name_); | 56 Interface::Name_); |
57 } | 57 } |
58 | 58 |
59 // Binds |ptr| to an implemention of Interface in the remote application. | 59 // Binds |ptr| to an implemention of Interface in the remote application. |
60 // |ptr| can immediately be used to start sending requests to the remote | 60 // |ptr| can immediately be used to start sending requests to the remote |
61 // service. | 61 // service. |
62 template <typename Interface> | 62 template <typename Interface> |
63 void ConnectToService(InterfacePtr<Interface>* ptr) { | 63 void ConnectToService(InterfacePtr<Interface>* ptr) { |
64 if (ServiceProvider* sp = GetServiceProvider()) { | 64 if (ServiceProvider* sp = GetServiceProvider()) { |
65 MessagePipe pipe; | 65 MessagePipe pipe; |
66 ptr->Bind(pipe.handle0.Pass()); | 66 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); |
67 sp->ConnectToService(Interface::Name_, pipe.handle1.Pass()); | 67 sp->ConnectToService(Interface::Name_, pipe.handle1.Pass()); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 // Returns the URL that was used by the source application to establish a | 71 // Returns the URL that was used by the source application to establish a |
72 // connection to the destination application. | 72 // connection to the destination application. |
73 // | 73 // |
74 // When ApplicationConnection is representing an incoming connection this can | 74 // When ApplicationConnection is representing an incoming connection this can |
75 // be different than the URL the application was initially loaded from, if the | 75 // be different than the URL the application was initially loaded from, if the |
76 // application handles multiple URLs. Note that this is the URL after all | 76 // application handles multiple URLs. Note that this is the URL after all |
(...skipping 12 matching lines...) Expand all Loading... |
89 virtual ServiceProvider* GetServiceProvider() = 0; | 89 virtual ServiceProvider* GetServiceProvider() = 0; |
90 | 90 |
91 private: | 91 private: |
92 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, | 92 virtual void SetServiceConnectorForName(ServiceConnector* service_connector, |
93 const std::string& name) = 0; | 93 const std::string& name) = 0; |
94 }; | 94 }; |
95 | 95 |
96 } // namespace mojo | 96 } // namespace mojo |
97 | 97 |
98 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ | 98 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_CONNECTION_H_ |
OLD | NEW |