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" |
11 #include "mojo/shell/public/interfaces/shell.mojom.h" | 11 #include "mojo/shell/public/interfaces/shell.mojom.h" |
12 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" | 12 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
13 | 13 |
14 namespace mojo { | 14 namespace mojo { |
15 | 15 |
16 // An interface that encapsulates the Mojo Shell's broker interface by which | 16 // An interface that encapsulates the Mojo Shell's broker interface by which |
17 // connections between applications are established. Once Connect() is called, | 17 // connections between applications are established. Once Connect() is called, |
18 // this class is bound to the thread the call was made on and it cannot be | 18 // this class is bound to the thread the call was made on and it cannot be |
19 // passed to another thread without calling Clone(). | 19 // passed to another thread without calling Clone(). |
20 // An instance of this class is created internally by ShellConnection for use | 20 // An instance of this class is created internally by ShellConnection for use |
21 // on the thread ShellConnection is instantiated on, and this interface is | 21 // on the thread ShellConnection is instantiated on, and this interface is |
22 // wrapped by the Shell interface. | 22 // wrapped by the Shell interface. |
(...skipping 10 matching lines...) Expand all Loading... |
33 | 33 |
34 class ConnectParams { | 34 class ConnectParams { |
35 public: | 35 public: |
36 explicit ConnectParams(const Identity& target); | 36 explicit ConnectParams(const Identity& target); |
37 explicit ConnectParams(const std::string& name); | 37 explicit ConnectParams(const std::string& name); |
38 ~ConnectParams(); | 38 ~ConnectParams(); |
39 | 39 |
40 const Identity& target() { return target_; } | 40 const Identity& target() { return target_; } |
41 void set_target(const Identity& target) { target_ = target; } | 41 void set_target(const Identity& target) { target_ = target; } |
42 void set_client_process_connection( | 42 void set_client_process_connection( |
43 shell::mojom::ShellClientFactoryPtr shell_client_factory, | 43 shell::mojom::ShellClientPtr shell_client, |
44 shell::mojom::PIDReceiverRequest pid_receiver_request) { | 44 shell::mojom::PIDReceiverRequest pid_receiver_request) { |
45 shell_client_factory_ = std::move(shell_client_factory); | 45 shell_client_ = std::move(shell_client); |
46 pid_receiver_request_ = std::move(pid_receiver_request); | 46 pid_receiver_request_ = std::move(pid_receiver_request); |
47 } | 47 } |
48 void TakeClientProcessConnection( | 48 void TakeClientProcessConnection( |
49 shell::mojom::ShellClientFactoryPtr* shell_client_factory, | 49 shell::mojom::ShellClientPtr* shell_client, |
50 shell::mojom::PIDReceiverRequest* pid_receiver_request) { | 50 shell::mojom::PIDReceiverRequest* pid_receiver_request) { |
51 *shell_client_factory = std::move(shell_client_factory_); | 51 *shell_client = std::move(shell_client_); |
52 *pid_receiver_request = std::move(pid_receiver_request_); | 52 *pid_receiver_request = std::move(pid_receiver_request_); |
53 } | 53 } |
54 | 54 |
55 private: | 55 private: |
56 Identity target_; | 56 Identity target_; |
57 shell::mojom::ShellClientFactoryPtr shell_client_factory_; | 57 shell::mojom::ShellClientPtr shell_client_; |
58 shell::mojom::PIDReceiverRequest pid_receiver_request_; | 58 shell::mojom::PIDReceiverRequest pid_receiver_request_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(ConnectParams); | 60 DISALLOW_COPY_AND_ASSIGN(ConnectParams); |
61 }; | 61 }; |
62 | 62 |
63 // Requests a new connection to an application. Returns a pointer to the | 63 // Requests a new connection to an application. Returns a pointer to the |
64 // connection if the connection is permitted by this application's delegate, | 64 // connection if the connection is permitted by this application's delegate, |
65 // or nullptr otherwise. Caller takes ownership. | 65 // or nullptr otherwise. Caller takes ownership. |
66 // Once this method is called, this object is bound to the thread on which the | 66 // Once this method is called, this object is bound to the thread on which the |
67 // call took place. To pass to another thread, call Clone() and pass the | 67 // call took place. To pass to another thread, call Clone() and pass the |
(...skipping 24 matching lines...) Expand all Loading... |
92 | 92 |
93 // Creates a new instance of this class which may be passed to another thread. | 93 // Creates a new instance of this class which may be passed to another thread. |
94 // The returned object may be passed multiple times until Connect() is called, | 94 // The returned object may be passed multiple times until Connect() is called, |
95 // at which point this method must be called again to pass again. | 95 // at which point this method must be called again to pass again. |
96 virtual scoped_ptr<Connector> Clone() = 0; | 96 virtual scoped_ptr<Connector> Clone() = 0; |
97 }; | 97 }; |
98 | 98 |
99 } // namespace mojo | 99 } // namespace mojo |
100 | 100 |
101 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 101 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
OLD | NEW |