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/interfaces/shell.mojom.h" | 9 #include "mojo/shell/public/interfaces/shell.mojom.h" |
10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 | 13 |
14 // An interface that encapsulates the Mojo Shell's broker interface by which | 14 // An interface that encapsulates the Mojo Shell's broker interface by which |
15 // connections between applications are established. Once Connect() is called, | 15 // connections between applications are established. Once Connect() is called, |
16 // this class is bound to the thread the call was made on and it cannot be | 16 // this class is bound to the thread the call was made on and it cannot be |
17 // passed to another thread without calling Clone(). | 17 // passed to another thread without calling Clone(). |
18 // An instance of this class is created internally by ShellConnection for use | 18 // An instance of this class is created internally by ShellConnection for use |
19 // on the thread ShellConnection is instantiated on, and this interface is | 19 // on the thread ShellConnection is instantiated on, and this interface is |
20 // wrapped by the Shell interface. | 20 // wrapped by the Shell interface. |
21 // To use this interface on other threads, call Shell::CloneConnector() and | 21 // To use this interface on other threads, call Shell::CloneConnector() and |
22 // pass the result to another thread. To pass to subsequent threads, call | 22 // pass the result to another thread. To pass to subsequent threads, call |
23 // Clone() on instances of this object. | 23 // Clone() on instances of this object. |
24 // While instances of this object are owned by the caller, the underlying | 24 // While instances of this object are owned by the caller, the underlying |
25 // connection with the shell is bound to the lifetime of the instance that | 25 // connection with the shell is bound to the lifetime of the instance that |
26 // created it, i.e. when the application is terminated the Connector pipe is | 26 // created it, i.e. when the application is terminated the Connector pipe is |
27 // closed. | 27 // closed. |
28 class Connector { | 28 class Connector { |
29 public: | 29 public: |
| 30 virtual ~Connector() {} |
| 31 |
30 class ConnectParams { | 32 class ConnectParams { |
31 public: | 33 public: |
32 explicit ConnectParams(const std::string& url); | 34 explicit ConnectParams(const std::string& url); |
33 ~ConnectParams(); | 35 ~ConnectParams(); |
34 | 36 |
35 const GURL& url() { return url_; } | 37 const GURL& url() { return url_; } |
36 void set_user_id(uint32_t user_id) { user_id_ = user_id; } | 38 void set_user_id(uint32_t user_id) { user_id_ = user_id; } |
37 uint32_t user_id() const { return user_id_; } | 39 uint32_t user_id() const { return user_id_; } |
38 | 40 |
39 private: | 41 private: |
(...skipping 29 matching lines...) Expand all Loading... |
69 | 71 |
70 // Creates a new instance of this class which may be passed to another thread. | 72 // Creates a new instance of this class which may be passed to another thread. |
71 // The returned object may be passed multiple times until Connect() is called, | 73 // The returned object may be passed multiple times until Connect() is called, |
72 // at which point this method must be called again to pass again. | 74 // at which point this method must be called again to pass again. |
73 virtual scoped_ptr<Connector> Clone() = 0; | 75 virtual scoped_ptr<Connector> Clone() = 0; |
74 }; | 76 }; |
75 | 77 |
76 } // namespace mojo | 78 } // namespace mojo |
77 | 79 |
78 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ | 80 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ |
OLD | NEW |