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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 GenerateRandomName(port_name); | 637 GenerateRandomName(port_name); |
638 } | 638 } |
639 | 639 |
640 void NodeController::AllocMessage(size_t num_header_bytes, | 640 void NodeController::AllocMessage(size_t num_header_bytes, |
641 ports::ScopedMessage* message) { | 641 ports::ScopedMessage* message) { |
642 message->reset(new PortsMessage(num_header_bytes, 0, 0, nullptr)); | 642 message->reset(new PortsMessage(num_header_bytes, 0, 0, nullptr)); |
643 } | 643 } |
644 | 644 |
645 void NodeController::ForwardMessage(const ports::NodeName& node, | 645 void NodeController::ForwardMessage(const ports::NodeName& node, |
646 ports::ScopedMessage message) { | 646 ports::ScopedMessage message) { |
| 647 DCHECK(message); |
647 if (node == name_) { | 648 if (node == name_) { |
648 // NOTE: We need to avoid re-entering the Node instance within | 649 // NOTE: We need to avoid re-entering the Node instance within |
649 // ForwardMessage. Because ForwardMessage is only ever called | 650 // ForwardMessage. Because ForwardMessage is only ever called |
650 // (synchronously) in response to Node's ClosePort, SendMessage, or | 651 // (synchronously) in response to Node's ClosePort, SendMessage, or |
651 // AcceptMessage, we flush the queue after calling any of those methods. | 652 // AcceptMessage, we flush the queue after calling any of those methods. |
652 base::AutoLock lock(messages_lock_); | 653 base::AutoLock lock(messages_lock_); |
653 incoming_messages_.emplace(std::move(message)); | 654 incoming_messages_.emplace(std::move(message)); |
654 incoming_messages_flag_.Set(true); | 655 incoming_messages_flag_.Set(true); |
655 } else { | 656 } else { |
656 SendPeerMessage(node, std::move(message)); | 657 SendPeerMessage(node, std::move(message)); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 shutdown_callback_flag_.Set(false); | 1122 shutdown_callback_flag_.Set(false); |
1122 } | 1123 } |
1123 | 1124 |
1124 DCHECK(!callback.is_null()); | 1125 DCHECK(!callback.is_null()); |
1125 | 1126 |
1126 callback.Run(); | 1127 callback.Run(); |
1127 } | 1128 } |
1128 | 1129 |
1129 } // namespace edk | 1130 } // namespace edk |
1130 } // namespace mojo | 1131 } // namespace mojo |
OLD | NEW |