| 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 #include "mojo/public/cpp/bindings/lib/router.h" | 5 #include "mojo/public/cpp/bindings/lib/router.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 connector_.task_runner()->PostTask( | 316 connector_.task_runner()->PostTask( |
| 317 FROM_HERE, | 317 FROM_HERE, |
| 318 base::Bind(&Router::OnConnectionError, weak_factory_.GetWeakPtr())); | 318 base::Bind(&Router::OnConnectionError, weak_factory_.GetWeakPtr())); |
| 319 return; | 319 return; |
| 320 } | 320 } |
| 321 | 321 |
| 322 control_message_proxy_.OnConnectionError(); | 322 control_message_proxy_.OnConnectionError(); |
| 323 | 323 |
| 324 encountered_error_ = true; | 324 encountered_error_ = true; |
| 325 | 325 |
| 326 // The callbacks may hold on to resources. There is no need to keep them any | 326 // Response callbacks may hold on to resource, and there's no need to keep |
| 327 // longer. | 327 // them alive any longer. Note that it's allowed that a pending response |
| 328 async_responders_.clear(); | 328 // callback may own this endpoint, so we simply move the responders onto the |
| 329 // stack here and let them be destroyed when the stack unwinds. |
| 330 AsyncResponderMap responders = std::move(async_responders_); |
| 329 | 331 |
| 330 if (!error_handler_.is_null()) { | 332 if (!error_handler_.is_null()) { |
| 331 error_handler_.Run(); | 333 error_handler_.Run(); |
| 332 } else if (!error_with_reason_handler_.is_null()) { | 334 } else if (!error_with_reason_handler_.is_null()) { |
| 333 // Make a copy on the stack. If we directly pass a reference to a member of | 335 // Make a copy on the stack. If we directly pass a reference to a member of |
| 334 // |control_message_handler_|, that reference will be invalidated as soon as | 336 // |control_message_handler_|, that reference will be invalidated as soon as |
| 335 // the user destroys the interface endpoint. | 337 // the user destroys the interface endpoint. |
| 336 std::string description = control_message_handler_.disconnect_description(); | 338 std::string description = control_message_handler_.disconnect_description(); |
| 337 error_with_reason_handler_.Run( | 339 error_with_reason_handler_.Run( |
| 338 control_message_handler_.disconnect_custom_reason(), description); | 340 control_message_handler_.disconnect_custom_reason(), description); |
| 339 } | 341 } |
| 340 } | 342 } |
| 341 | 343 |
| 342 // ---------------------------------------------------------------------------- | 344 // ---------------------------------------------------------------------------- |
| 343 | 345 |
| 344 } // namespace internal | 346 } // namespace internal |
| 345 } // namespace mojo | 347 } // namespace mojo |
| OLD | NEW |