Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: services/shell/public/cpp/shell_connection.h

Issue 1920033005: services/shell: Fix running the connection-lost callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Connector* connector() { return connector_.get(); } 56 Connector* connector() { return connector_.get(); }
57 const Identity& identity() { return identity_; } 57 const Identity& identity() { return identity_; }
58 58
59 // TODO(rockot): Remove this. http://crbug.com/594852. 59 // TODO(rockot): Remove this. http://crbug.com/594852.
60 void set_initialize_handler(const base::Closure& callback); 60 void set_initialize_handler(const base::Closure& callback);
61 61
62 // TODO(rockot): Remove this once we get rid of app tests. 62 // TODO(rockot): Remove this once we get rid of app tests.
63 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector); 63 void SetAppTestConnectorForTesting(mojom::ConnectorPtr connector);
64 64
65 // 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.
66 void set_connection_lost_closure(const base::Closure& closure) { 66 // Note that if connection has already been lost, then |closure| is called
67 connection_lost_closure_ = closure; 67 // immediately.
68 } 68 void SetConnectionLostClosure(const base::Closure& closure);
69 69
70 private: 70 private:
71 // mojom::ShellClient: 71 // mojom::ShellClient:
72 void Initialize(mojom::IdentityPtr identity, 72 void Initialize(mojom::IdentityPtr identity,
73 uint32_t id, 73 uint32_t id,
74 const InitializeCallback& callback) override; 74 const InitializeCallback& callback) override;
75 void AcceptConnection(mojom::IdentityPtr source, 75 void AcceptConnection(mojom::IdentityPtr source,
76 uint32_t source_id, 76 uint32_t source_id,
77 mojom::InterfaceProviderRequest remote_interfaces, 77 mojom::InterfaceProviderRequest remote_interfaces,
78 mojom::InterfaceProviderPtr local_interfaces, 78 mojom::InterfaceProviderPtr local_interfaces,
79 mojom::CapabilityRequestPtr allowed_capabilities, 79 mojom::CapabilityRequestPtr allowed_capabilities,
80 const mojo::String& name) override; 80 const mojo::String& name) override;
81 81
82 void OnConnectionError(); 82 void OnConnectionError();
83 83
84 // A callback called when Initialize() is run. 84 // A callback called when Initialize() is run.
85 base::Closure initialize_handler_; 85 base::Closure initialize_handler_;
86 86
87 // We track the lifetime of incoming connection registries as it more 87 // We track the lifetime of incoming connection registries as it more
88 // convenient for the client. 88 // convenient for the client.
89 ScopedVector<Connection> incoming_connections_; 89 ScopedVector<Connection> incoming_connections_;
90 90
91 // 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.
92 mojom::ConnectorRequest pending_connector_request_; 92 mojom::ConnectorRequest pending_connector_request_;
93 93
94 shell::ShellClient* client_; 94 shell::ShellClient* client_;
95 mojo::Binding<mojom::ShellClient> binding_; 95 mojo::Binding<mojom::ShellClient> binding_;
96 std::unique_ptr<Connector> connector_; 96 std::unique_ptr<Connector> connector_;
97 shell::Identity identity_; 97 shell::Identity identity_;
98 bool should_run_connection_lost_closure_;
Ben Goodger (Google) 2016/04/27 22:29:20 = false;
sadrul 2016/04/27 22:45:11 Done.
98 99
99 base::Closure connection_lost_closure_; 100 base::Closure connection_lost_closure_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(ShellConnection); 102 DISALLOW_COPY_AND_ASSIGN(ShellConnection);
102 }; 103 };
103 104
104 } // namespace shell 105 } // namespace shell
105 106
106 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ 107 #endif // SERVICES_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698