| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| 6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include "mojo/shell/public/cpp/connection.h" | 8 #include "mojo/shell/public/cpp/connection.h" |
| 9 #include "mojo/shell/public/cpp/identity.h" | 9 #include "mojo/shell/public/cpp/identity.h" |
| 10 #include "mojo/shell/public/interfaces/connector.mojom.h" | 10 #include "mojo/shell/public/interfaces/connector.mojom.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Connect to application identified by |request->name| and connect to the | 56 // Connect to application identified by |request->name| and connect to the |
| 57 // service implementation of the interface identified by |Interface|. | 57 // service implementation of the interface identified by |Interface|. |
| 58 template <typename Interface> | 58 template <typename Interface> |
| 59 void ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) { | 59 void ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) { |
| 60 scoped_ptr<Connection> connection = Connect(params); | 60 scoped_ptr<Connection> connection = Connect(params); |
| 61 if (connection) | 61 if (connection) |
| 62 connection->GetInterface(ptr); | 62 connection->GetInterface(ptr); |
| 63 } | 63 } |
| 64 template <typename Interface> | 64 template <typename Interface> |
| 65 void ConnectToInterface(const Identity& target, |
| 66 InterfacePtr<Interface>* ptr) { |
| 67 ConnectParams params(target); |
| 68 return ConnectToInterface(¶ms, ptr); |
| 69 } |
| 70 template <typename Interface> |
| 65 void ConnectToInterface(const std::string& name, | 71 void ConnectToInterface(const std::string& name, |
| 66 InterfacePtr<Interface>* ptr) { | 72 InterfacePtr<Interface>* ptr) { |
| 67 ConnectParams params(name); | 73 ConnectParams params(name); |
| 68 return ConnectToInterface(¶ms, ptr); | 74 return ConnectToInterface(¶ms, ptr); |
| 69 } | 75 } |
| 70 | 76 |
| 71 // Creates a new instance of this class which may be passed to another thread. | 77 // Creates a new instance of this class which may be passed to another thread. |
| 72 // The returned object may be passed multiple times until Connect() is called, | 78 // The returned object may be passed multiple times until Connect() is called, |
| 73 // at which point this method must be called again to pass again. | 79 // at which point this method must be called again to pass again. |
| 74 virtual scoped_ptr<Connector> Clone() = 0; | 80 virtual scoped_ptr<Connector> Clone() = 0; |
| 75 }; | 81 }; |
| 76 | 82 |
| 77 } // namespace mojo | 83 } // namespace mojo |
| 78 | 84 |
| 79 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 85 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| OLD | NEW |