| 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 SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| 6 #define SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "services/shell/public/cpp/connection.h" | 10 #include "services/shell/public/cpp/connection.h" |
| 11 #include "services/shell/public/cpp/identity.h" | 11 #include "services/shell/public/cpp/identity.h" |
| 12 #include "services/shell/public/interfaces/connector.mojom.h" | 12 #include "services/shell/public/interfaces/connector.mojom.h" |
| 13 #include "services/shell/public/interfaces/service.mojom.h" |
| 13 #include "services/shell/public/interfaces/shell.mojom.h" | 14 #include "services/shell/public/interfaces/shell.mojom.h" |
| 14 #include "services/shell/public/interfaces/shell_client.mojom.h" | |
| 15 | 15 |
| 16 namespace shell { | 16 namespace shell { |
| 17 | 17 |
| 18 // An interface that encapsulates the Mojo Shell's broker interface by which | 18 // An interface that encapsulates the Mojo Shell's broker interface by which |
| 19 // connections between applications are established. Once Connect() is called, | 19 // connections between applications are established. Once Connect() is called, |
| 20 // this class is bound to the thread the call was made on and it cannot be | 20 // this class is bound to the thread the call was made on and it cannot be |
| 21 // passed to another thread without calling Clone(). | 21 // passed to another thread without calling Clone(). |
| 22 // An instance of this class is created internally by ShellConnection for use | 22 // An instance of this class is created internally by ShellConnection for use |
| 23 // on the thread ShellConnection is instantiated on, and this interface is | 23 // on the thread ShellConnection is instantiated on, and this interface is |
| 24 // wrapped by the Shell interface. | 24 // wrapped by the Shell interface. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 class ConnectParams { | 36 class ConnectParams { |
| 37 public: | 37 public: |
| 38 explicit ConnectParams(const Identity& target); | 38 explicit ConnectParams(const Identity& target); |
| 39 explicit ConnectParams(const std::string& name); | 39 explicit ConnectParams(const std::string& name); |
| 40 ~ConnectParams(); | 40 ~ConnectParams(); |
| 41 | 41 |
| 42 const Identity& target() { return target_; } | 42 const Identity& target() { return target_; } |
| 43 void set_target(const Identity& target) { target_ = target; } | 43 void set_target(const Identity& target) { target_ = target; } |
| 44 void set_client_process_connection( | 44 void set_client_process_connection( |
| 45 mojom::ShellClientPtr shell_client, | 45 mojom::ServicePtr service, |
| 46 mojom::PIDReceiverRequest pid_receiver_request) { | 46 mojom::PIDReceiverRequest pid_receiver_request) { |
| 47 shell_client_ = std::move(shell_client); | 47 service_ = std::move(service); |
| 48 pid_receiver_request_ = std::move(pid_receiver_request); | 48 pid_receiver_request_ = std::move(pid_receiver_request); |
| 49 } | 49 } |
| 50 void TakeClientProcessConnection( | 50 void TakeClientProcessConnection( |
| 51 mojom::ShellClientPtr* shell_client, | 51 mojom::ServicePtr* service, |
| 52 mojom::PIDReceiverRequest* pid_receiver_request) { | 52 mojom::PIDReceiverRequest* pid_receiver_request) { |
| 53 *shell_client = std::move(shell_client_); | 53 *service = std::move(service_); |
| 54 *pid_receiver_request = std::move(pid_receiver_request_); | 54 *pid_receiver_request = std::move(pid_receiver_request_); |
| 55 } | 55 } |
| 56 InterfaceRegistry* exposed_interfaces() { return exposed_interfaces_; } | 56 InterfaceRegistry* exposed_interfaces() { return exposed_interfaces_; } |
| 57 void set_exposed_interfaces(InterfaceRegistry* exposed_interfaces) { | 57 void set_exposed_interfaces(InterfaceRegistry* exposed_interfaces) { |
| 58 exposed_interfaces_ = exposed_interfaces; | 58 exposed_interfaces_ = exposed_interfaces; |
| 59 } | 59 } |
| 60 InterfaceProvider* remote_interfaces() { return remote_interfaces_; } | 60 InterfaceProvider* remote_interfaces() { return remote_interfaces_; } |
| 61 void set_remote_interfaces(InterfaceProvider* remote_interfaces) { | 61 void set_remote_interfaces(InterfaceProvider* remote_interfaces) { |
| 62 remote_interfaces_ = remote_interfaces; | 62 remote_interfaces_ = remote_interfaces; |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 Identity target_; | 66 Identity target_; |
| 67 mojom::ShellClientPtr shell_client_; | 67 mojom::ServicePtr service_; |
| 68 mojom::PIDReceiverRequest pid_receiver_request_; | 68 mojom::PIDReceiverRequest pid_receiver_request_; |
| 69 InterfaceRegistry* exposed_interfaces_ = nullptr; | 69 InterfaceRegistry* exposed_interfaces_ = nullptr; |
| 70 InterfaceProvider* remote_interfaces_ = nullptr; | 70 InterfaceProvider* remote_interfaces_ = nullptr; |
| 71 | 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(ConnectParams); | 72 DISALLOW_COPY_AND_ASSIGN(ConnectParams); |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 // Requests a new connection to an application. Returns a pointer to the | 75 // Requests a new connection to an application. Returns a pointer to the |
| 76 // connection if the connection is permitted by this application's delegate, | 76 // connection if the connection is permitted by this application's delegate, |
| 77 // or nullptr otherwise. Caller takes ownership. | 77 // or nullptr otherwise. Caller takes ownership. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 105 | 105 |
| 106 // Creates a new instance of this class which may be passed to another thread. | 106 // Creates a new instance of this class which may be passed to another thread. |
| 107 // The returned object may be passed multiple times until Connect() is called, | 107 // The returned object may be passed multiple times until Connect() is called, |
| 108 // at which point this method must be called again to pass again. | 108 // at which point this method must be called again to pass again. |
| 109 virtual std::unique_ptr<Connector> Clone() = 0; | 109 virtual std::unique_ptr<Connector> Clone() = 0; |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 } // namespace shell | 112 } // namespace shell |
| 113 | 113 |
| 114 #endif // SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 114 #endif // SERVICES_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
| OLD | NEW |