OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/edk/system/node_controller.h" | 5 #include "mojo/edk/system/node_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 node_->AcceptMessage(std::move(messages.front())); | 493 node_->AcceptMessage(std::move(messages.front())); |
494 messages.pop(); | 494 messages.pop(); |
495 } | 495 } |
496 } | 496 } |
497 AttemptShutdownIfRequested(); | 497 AttemptShutdownIfRequested(); |
498 } | 498 } |
499 | 499 |
500 void NodeController::DropAllPeers() { | 500 void NodeController::DropAllPeers() { |
501 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 501 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
502 | 502 |
| 503 std::vector<scoped_refptr<NodeChannel>> all_peers; |
503 { | 504 { |
504 base::AutoLock lock(parent_lock_); | 505 base::AutoLock lock(parent_lock_); |
505 if (bootstrap_parent_channel_) { | 506 if (bootstrap_parent_channel_) { |
506 bootstrap_parent_channel_->ShutDown(); | 507 // |bootstrap_parent_channel_| isn't null'd here becuase we rely on its |
507 bootstrap_parent_channel_ = nullptr; | 508 // existence to determine whether or not this is the root node. Once |
| 509 // bootstrap_parent_channel_->ShutDown() has been called, |
| 510 // |bootstrap_parent_channel_| is essentially a dead object and it doesn't |
| 511 // matter if it's deleted now or when |this| is deleted. |
| 512 // Note: |bootstrap_parent_channel_| is only modified on the IO thread. |
| 513 all_peers.push_back(bootstrap_parent_channel_); |
508 } | 514 } |
509 } | 515 } |
510 | 516 |
511 std::vector<scoped_refptr<NodeChannel>> all_peers; | |
512 { | 517 { |
513 base::AutoLock lock(peers_lock_); | 518 base::AutoLock lock(peers_lock_); |
514 for (const auto& peer : peers_) | 519 for (const auto& peer : peers_) |
515 all_peers.push_back(peer.second); | 520 all_peers.push_back(peer.second); |
516 for (const auto& peer : pending_children_) | 521 for (const auto& peer : pending_children_) |
517 all_peers.push_back(peer.second); | 522 all_peers.push_back(peer.second); |
518 peers_.clear(); | 523 peers_.clear(); |
519 pending_children_.clear(); | 524 pending_children_.clear(); |
520 pending_peer_messages_.clear(); | 525 pending_peer_messages_.clear(); |
521 } | 526 } |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 shutdown_callback_.Reset(); | 980 shutdown_callback_.Reset(); |
976 } | 981 } |
977 | 982 |
978 DCHECK(!callback.is_null()); | 983 DCHECK(!callback.is_null()); |
979 | 984 |
980 callback.Run(); | 985 callback.Run(); |
981 } | 986 } |
982 | 987 |
983 } // namespace edk | 988 } // namespace edk |
984 } // namespace mojo | 989 } // namespace mojo |
OLD | NEW |