| 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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 while (!message_queue.empty()) { | 783 while (!message_queue.empty()) { |
| 784 broker->RelayPortsMessage(destination, std::move(message_queue.front())); | 784 broker->RelayPortsMessage(destination, std::move(message_queue.front())); |
| 785 message_queue.pop(); | 785 message_queue.pop(); |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 #endif | 788 #endif |
| 789 | 789 |
| 790 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name; | 790 DVLOG(1) << "Child " << name_ << " accepted by broker " << broker_name; |
| 791 } | 791 } |
| 792 | 792 |
| 793 void NodeController::OnPortsMessage(Channel::MessagePtr channel_message) { | 793 void NodeController::OnPortsMessage(const ports::NodeName& from_node, |
| 794 Channel::MessagePtr channel_message) { |
| 794 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 795 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
| 795 | 796 |
| 796 void* data; | 797 void* data; |
| 797 size_t num_data_bytes; | 798 size_t num_data_bytes; |
| 798 NodeChannel::GetPortsMessageData( | 799 NodeChannel::GetPortsMessageData( |
| 799 channel_message.get(), &data, &num_data_bytes); | 800 channel_message.get(), &data, &num_data_bytes); |
| 801 if (!num_data_bytes) { |
| 802 DropPeer(from_node); |
| 803 return; |
| 804 } |
| 800 | 805 |
| 801 size_t num_header_bytes, num_payload_bytes, num_ports_bytes; | 806 size_t num_header_bytes, num_payload_bytes, num_ports_bytes; |
| 802 ports::Message::Parse(data, | 807 if (!ports::Message::Parse(data, |
| 803 num_data_bytes, | 808 num_data_bytes, |
| 804 &num_header_bytes, | 809 &num_header_bytes, |
| 805 &num_payload_bytes, | 810 &num_payload_bytes, |
| 806 &num_ports_bytes); | 811 &num_ports_bytes)) { |
| 812 DropPeer(from_node); |
| 813 return; |
| 814 } |
| 807 | 815 |
| 808 CHECK(channel_message); | 816 CHECK(channel_message); |
| 809 ports::ScopedMessage message( | 817 ports::ScopedMessage message( |
| 810 new PortsMessage(num_header_bytes, | 818 new PortsMessage(num_header_bytes, |
| 811 num_payload_bytes, | 819 num_payload_bytes, |
| 812 num_ports_bytes, | 820 num_ports_bytes, |
| 813 std::move(channel_message))); | 821 std::move(channel_message))); |
| 814 | 822 |
| 815 node_->AcceptMessage(std::move(message)); | 823 node_->AcceptMessage(std::move(message)); |
| 816 AcceptIncomingMessages(); | 824 AcceptIncomingMessages(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 // process. At this point, if the port extraction failed, either something | 939 // process. At this point, if the port extraction failed, either something |
| 932 // went wrong in the mach stuff, or the remote process died. | 940 // went wrong in the mach stuff, or the remote process died. |
| 933 LOG(ERROR) << "Error on receiving Mach ports " << from_node | 941 LOG(ERROR) << "Error on receiving Mach ports " << from_node |
| 934 << ". Dropping message."; | 942 << ". Dropping message."; |
| 935 return; | 943 return; |
| 936 } | 944 } |
| 937 #endif // defined(OS_WIN) | 945 #endif // defined(OS_WIN) |
| 938 | 946 |
| 939 if (destination == name_) { | 947 if (destination == name_) { |
| 940 // Great, we can deliver this message locally. | 948 // Great, we can deliver this message locally. |
| 941 OnPortsMessage(std::move(message)); | 949 OnPortsMessage(from_node, std::move(message)); |
| 942 return; | 950 return; |
| 943 } | 951 } |
| 944 | 952 |
| 945 scoped_refptr<NodeChannel> peer = GetPeerChannel(destination); | 953 scoped_refptr<NodeChannel> peer = GetPeerChannel(destination); |
| 946 if (peer) | 954 if (peer) |
| 947 peer->PortsMessage(std::move(message)); | 955 peer->PortsMessage(std::move(message)); |
| 948 else | 956 else |
| 949 DLOG(ERROR) << "Dropping relay message for unknown node " << destination; | 957 DLOG(ERROR) << "Dropping relay message for unknown node " << destination; |
| 950 } | 958 } |
| 951 #endif | 959 #endif |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 shutdown_callback_flag_.Set(false); | 1006 shutdown_callback_flag_.Set(false); |
| 999 } | 1007 } |
| 1000 | 1008 |
| 1001 DCHECK(!callback.is_null()); | 1009 DCHECK(!callback.is_null()); |
| 1002 | 1010 |
| 1003 callback.Run(); | 1011 callback.Run(); |
| 1004 } | 1012 } |
| 1005 | 1013 |
| 1006 } // namespace edk | 1014 } // namespace edk |
| 1007 } // namespace mojo | 1015 } // namespace mojo |
| OLD | NEW |