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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.cc

Issue 2274743002: Mojo C++ bindings: clean up pending callbacks when connection error occurs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mojo/public/cpp/bindings/interface_endpoint_client.h" 5 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 return payload_validator_->Accept(message); 260 return payload_validator_->Accept(message);
261 } 261 }
262 262
263 void InterfaceEndpointClient::NotifyError() { 263 void InterfaceEndpointClient::NotifyError() {
264 DCHECK(thread_checker_.CalledOnValidThread()); 264 DCHECK(thread_checker_.CalledOnValidThread());
265 265
266 if (encountered_error_) 266 if (encountered_error_)
267 return; 267 return;
268 encountered_error_ = true; 268 encountered_error_ = true;
269
270 // The callbacks may hold on to resources. There is no need to keep them any
271 // longer.
272 async_responders_.clear();
273
269 if (!error_handler_.is_null()) 274 if (!error_handler_.is_null())
270 error_handler_.Run(); 275 error_handler_.Run();
271 } 276 }
272 277
273 bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) { 278 bool InterfaceEndpointClient::HandleValidatedMessage(Message* message) {
274 DCHECK_EQ(handle_.id(), message->interface_id()); 279 DCHECK_EQ(handle_.id(), message->interface_id());
280 DCHECK(!encountered_error_);
275 281
276 if (message->has_flag(Message::kFlagExpectsResponse)) { 282 if (message->has_flag(Message::kFlagExpectsResponse)) {
277 if (!incoming_receiver_) 283 if (!incoming_receiver_)
278 return false; 284 return false;
279 285
280 MessageReceiverWithStatus* responder = 286 MessageReceiverWithStatus* responder =
281 new ResponderThunk(weak_ptr_factory_.GetWeakPtr(), task_runner_); 287 new ResponderThunk(weak_ptr_factory_.GetWeakPtr(), task_runner_);
282 bool ok = incoming_receiver_->AcceptWithResponder(message, responder); 288 bool ok = incoming_receiver_->AcceptWithResponder(message, responder);
283 if (!ok) 289 if (!ok)
284 delete responder; 290 delete responder;
(...skipping 18 matching lines...) Expand all
303 return responder->Accept(message); 309 return responder->Accept(message);
304 } else { 310 } else {
305 if (!incoming_receiver_) 311 if (!incoming_receiver_)
306 return false; 312 return false;
307 313
308 return incoming_receiver_->Accept(message); 314 return incoming_receiver_->Accept(message);
309 } 315 }
310 } 316 }
311 317
312 } // namespace mojo 318 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698