| 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_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 11 #include "mojo/application/public/cpp/lib/interface_factory_connector.h" | 12 #include "mojo/application/public/cpp/lib/interface_factory_connector.h" |
| 12 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 13 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
| 13 | 14 |
| 14 namespace mojo { | 15 namespace mojo { |
| 15 | 16 |
| 16 class ServiceConnector; | 17 class ServiceConnector; |
| 17 | 18 |
| 18 // Represents a connection to another application. An instance of this class is | 19 // Represents a connection to another application. An instance of this class is |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 Interface::Name_); | 76 Interface::Name_); |
| 76 } | 77 } |
| 77 | 78 |
| 78 // Binds |ptr| to an implemention of Interface in the remote application. | 79 // Binds |ptr| to an implemention of Interface in the remote application. |
| 79 // |ptr| can immediately be used to start sending requests to the remote | 80 // |ptr| can immediately be used to start sending requests to the remote |
| 80 // service. | 81 // service. |
| 81 template <typename Interface> | 82 template <typename Interface> |
| 82 void ConnectToService(InterfacePtr<Interface>* ptr) { | 83 void ConnectToService(InterfacePtr<Interface>* ptr) { |
| 83 if (ServiceProvider* sp = GetServiceProvider()) { | 84 if (ServiceProvider* sp = GetServiceProvider()) { |
| 84 MessagePipe pipe; | 85 MessagePipe pipe; |
| 85 ptr->Bind(InterfacePtrInfo<Interface>(pipe.handle0.Pass(), 0u)); | 86 ptr->Bind(InterfacePtrInfo<Interface>(std::move(pipe.handle0), 0u)); |
| 86 sp->ConnectToService(Interface::Name_, pipe.handle1.Pass()); | 87 sp->ConnectToService(Interface::Name_, std::move(pipe.handle1)); |
| 87 } | 88 } |
| 88 } | 89 } |
| 89 | 90 |
| 90 // Returns the URL that was used by the source application to establish a | 91 // Returns the URL that was used by the source application to establish a |
| 91 // connection to the destination application. | 92 // connection to the destination application. |
| 92 // | 93 // |
| 93 // When ApplicationConnection is representing an incoming connection this can | 94 // When ApplicationConnection is representing an incoming connection this can |
| 94 // be different than the URL the application was initially loaded from, if the | 95 // be different than the URL the application was initially loaded from, if the |
| 95 // application handles multiple URLs. Note that this is the URL after all | 96 // application handles multiple URLs. Note that this is the URL after all |
| 96 // URL rewriting and HTTP redirects have been performed. | 97 // URL rewriting and HTTP redirects have been performed. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // some filtering policy preventing this interface from being exposed). | 133 // some filtering policy preventing this interface from being exposed). |
| 133 virtual bool SetServiceConnectorForName(ServiceConnector* service_connector, | 134 virtual bool SetServiceConnectorForName(ServiceConnector* service_connector, |
| 134 const std::string& name) = 0; | 135 const std::string& name) = 0; |
| 135 | 136 |
| 136 virtual base::WeakPtr<ApplicationConnection> GetWeakPtr() = 0; | 137 virtual base::WeakPtr<ApplicationConnection> GetWeakPtr() = 0; |
| 137 }; | 138 }; |
| 138 | 139 |
| 139 } // namespace mojo | 140 } // namespace mojo |
| 140 | 141 |
| 141 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ | 142 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_CONNECTION_H_ |
| OLD | NEW |