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

Side by Side Diff: services/shell/public/cpp/lib/shell_connection.cc

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 #include "services/shell/public/cpp/shell_connection.h" 5 #include "services/shell/public/cpp/shell_connection.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/bindings/interface_ptr.h" 10 #include "mojo/public/cpp/bindings/interface_ptr.h"
(...skipping 25 matching lines...) Expand all
36 void ShellConnection::set_initialize_handler(const base::Closure& callback) { 36 void ShellConnection::set_initialize_handler(const base::Closure& callback) {
37 initialize_handler_ = callback; 37 initialize_handler_ = callback;
38 } 38 }
39 39
40 void ShellConnection::SetAppTestConnectorForTesting( 40 void ShellConnection::SetAppTestConnectorForTesting(
41 mojom::ConnectorPtr connector) { 41 mojom::ConnectorPtr connector) {
42 pending_connector_request_ = nullptr; 42 pending_connector_request_ = nullptr;
43 connector_.reset(new ConnectorImpl(std::move(connector))); 43 connector_.reset(new ConnectorImpl(std::move(connector)));
44 } 44 }
45 45
46 void ShellConnection::SetConnectionLostClosure(const base::Closure& closure) {
47 connection_lost_closure_ = closure;
48 if (should_run_connection_lost_closure_ &&
49 !connection_lost_closure_.is_null())
50 connection_lost_closure_.Run();
51 }
52
46 //////////////////////////////////////////////////////////////////////////////// 53 ////////////////////////////////////////////////////////////////////////////////
47 // ShellConnection, mojom::ShellClient implementation: 54 // ShellConnection, mojom::ShellClient implementation:
48 55
49 void ShellConnection::Initialize(mojom::IdentityPtr identity, 56 void ShellConnection::Initialize(mojom::IdentityPtr identity,
50 uint32_t id, 57 uint32_t id,
51 const InitializeCallback& callback) { 58 const InitializeCallback& callback) {
52 identity_ = identity.To<Identity>(); 59 identity_ = identity.To<Identity>();
53 if (!initialize_handler_.is_null()) 60 if (!initialize_handler_.is_null())
54 initialize_handler_.Run(); 61 initialize_handler_.Run();
55 62
(...skipping 24 matching lines...) Expand all
80 incoming_connections_.push_back(std::move(registry)); 87 incoming_connections_.push_back(std::move(registry));
81 } 88 }
82 89
83 //////////////////////////////////////////////////////////////////////////////// 90 ////////////////////////////////////////////////////////////////////////////////
84 // ShellConnection, private: 91 // ShellConnection, private:
85 92
86 void ShellConnection::OnConnectionError() { 93 void ShellConnection::OnConnectionError() {
87 // Note that the ShellClient doesn't technically have to quit now, it may live 94 // Note that the ShellClient doesn't technically have to quit now, it may live
88 // on to service existing connections. All existing Connectors however are 95 // on to service existing connections. All existing Connectors however are
89 // invalid. 96 // invalid.
90 if (client_->ShellConnectionLost() && !connection_lost_closure_.is_null()) 97 should_run_connection_lost_closure_ = client_->ShellConnectionLost();
98 if (should_run_connection_lost_closure_ &&
99 !connection_lost_closure_.is_null())
91 connection_lost_closure_.Run(); 100 connection_lost_closure_.Run();
92 // We don't reset the connector as clients may have taken a raw pointer to it. 101 // We don't reset the connector as clients may have taken a raw pointer to it.
93 // Connect() will return nullptr if they try to connect to anything. 102 // Connect() will return nullptr if they try to connect to anything.
94 } 103 }
95 104
96 } // namespace shell 105 } // namespace shell
OLDNEW
« no previous file with comments | « services/shell/public/cpp/lib/application_runner.cc ('k') | services/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698