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 SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 // Creates a new ShellConnection bound to |request|. This connection may be | 47 // Creates a new ShellConnection bound to |request|. This connection may be |
48 // used immediately to make outgoing connections via connector(). Does not | 48 // used immediately to make outgoing connections via connector(). Does not |
49 // take ownership of |client|, which must remain valid for the lifetime of | 49 // take ownership of |client|, which must remain valid for the lifetime of |
50 // ShellConnection. | 50 // ShellConnection. |
51 ShellConnection(shell::ShellClient* client, | 51 ShellConnection(shell::ShellClient* client, |
52 mojom::ShellClientRequest request); | 52 mojom::ShellClientRequest request); |
53 | 53 |
54 ~ShellConnection() override; | 54 ~ShellConnection() override; |
55 | 55 |
56 Connector* connector() { return connector_.get(); } | 56 Connector* connector() { return connector_.get(); } |
57 const Identity& identity() { return identity_; } | |
57 | 58 |
58 // TODO(rockot): Remove this. http://crbug.com/594852. | 59 // TODO(rockot): Remove this. http://crbug.com/594852. |
59 void set_initialize_handler(const base::Closure& callback); | 60 void set_initialize_handler(const base::Closure& callback); |
60 | 61 |
61 // TODO(rockot): Remove this once we get rid of app tests. | 62 // TODO(rockot): Remove this once we get rid of app tests. |
62 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector); | 63 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector); |
63 | 64 |
64 // Specify a function to be called when the connection to the shell is lost. | 65 // Specify a function to be called when the connection to the shell is lost. |
65 void set_connection_lost_closure(const base::Closure& closure) { | 66 void set_connection_lost_closure(const base::Closure& closure) { |
66 connection_lost_closure_ = closure; | 67 connection_lost_closure_ = closure; |
67 } | 68 } |
68 | 69 |
69 private: | 70 private: |
sky
2016/04/22 15:51:19
nit: fix this line too.
msw
2016/04/22 19:02:18
Done.
| |
70 // mojom::ShellClient: | 71 // mojom::ShellClient: |
71 void Initialize(mojom::IdentityPtr identity, | 72 void Initialize(mojom::IdentityPtr identity, |
72 uint32_t id, | 73 uint32_t id, |
73 const InitializeCallback& callback) override; | 74 const InitializeCallback& callback) override; |
74 void AcceptConnection(mojom::IdentityPtr source, | 75 void AcceptConnection(mojom::IdentityPtr source, |
75 uint32_t source_id, | 76 uint32_t source_id, |
76 mojom::InterfaceProviderRequest remote_interfaces, | 77 mojom::InterfaceProviderRequest remote_interfaces, |
77 mojom::InterfaceProviderPtr local_interfaces, | 78 mojom::InterfaceProviderPtr local_interfaces, |
78 mojom::CapabilityRequestPtr allowed_capabilities, | 79 mojom::CapabilityRequestPtr allowed_capabilities, |
79 const mojo::String& name) override; | 80 const mojo::String& name) override; |
80 | 81 |
81 void OnConnectionError(); | 82 void OnConnectionError(); |
82 | 83 |
83 // A callback called when Initialize() is run. | 84 // A callback called when Initialize() is run. |
84 base::Closure initialize_handler_; | 85 base::Closure initialize_handler_; |
85 | 86 |
86 // We track the lifetime of incoming connection registries as it more | 87 // We track the lifetime of incoming connection registries as it more |
87 // convenient for the client. | 88 // convenient for the client. |
88 ScopedVector<Connection> incoming_connections_; | 89 ScopedVector<Connection> incoming_connections_; |
89 | 90 |
90 // A pending Connector request which will eventually be passed to the shell. | 91 // A pending Connector request which will eventually be passed to the shell. |
91 mojom::ConnectorRequest pending_connector_request_; | 92 mojom::ConnectorRequest pending_connector_request_; |
92 | 93 |
93 shell::ShellClient* client_; | 94 shell::ShellClient* client_; |
94 mojo::Binding<mojom::ShellClient> binding_; | 95 mojo::Binding<mojom::ShellClient> binding_; |
95 std::unique_ptr<Connector> connector_; | 96 std::unique_ptr<Connector> connector_; |
97 shell::Identity identity_; | |
96 | 98 |
97 base::Closure connection_lost_closure_; | 99 base::Closure connection_lost_closure_; |
98 | 100 |
99 DISALLOW_COPY_AND_ASSIGN(ShellConnection); | 101 DISALLOW_COPY_AND_ASSIGN(ShellConnection); |
100 }; | 102 }; |
101 | 103 |
102 } // namespace shell | 104 } // namespace shell |
103 | 105 |
104 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ | 106 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
OLD | NEW |