| 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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 #if defined(OS_WIN) | 936 #if defined(OS_WIN) |
| 937 // Rewrite the handles to this (the parent) process. If the message is | 937 // Rewrite the handles to this (the parent) process. If the message is |
| 938 // destined for another child process, the handles will be rewritten to that | 938 // destined for another child process, the handles will be rewritten to that |
| 939 // process before going out (see NodeChannel::WriteChannelMessage). | 939 // process before going out (see NodeChannel::WriteChannelMessage). |
| 940 // | 940 // |
| 941 // TODO: We could avoid double-duplication. | 941 // TODO: We could avoid double-duplication. |
| 942 // | 942 // |
| 943 // Note that we explicitly mark the handles as being owned by the sending | 943 // Note that we explicitly mark the handles as being owned by the sending |
| 944 // process before rewriting them, in order to accommodate RewriteHandles' | 944 // process before rewriting them, in order to accommodate RewriteHandles' |
| 945 // internal sanity checks. | 945 // internal sanity checks. |
| 946 for (size_t i = 0; i < message->num_handles(); ++i) | 946 ScopedPlatformHandleVectorPtr handles = message->TakeHandles(); |
| 947 message->handles()[i].owning_process = from_process; | 947 for (size_t i = 0; i < handles->size(); ++i) |
| 948 (*handles)[i].owning_process = from_process; |
| 948 if (!Channel::Message::RewriteHandles(from_process, | 949 if (!Channel::Message::RewriteHandles(from_process, |
| 949 base::GetCurrentProcessHandle(), | 950 base::GetCurrentProcessHandle(), |
| 950 message->handles(), | 951 handles.get())) { |
| 951 message->num_handles())) { | |
| 952 DLOG(ERROR) << "Failed to relay one or more handles."; | 952 DLOG(ERROR) << "Failed to relay one or more handles."; |
| 953 } | 953 } |
| 954 message->SetHandles(std::move(handles)); |
| 954 #else | 955 #else |
| 955 MachPortRelay* relay = GetMachPortRelay(); | 956 MachPortRelay* relay = GetMachPortRelay(); |
| 956 if (!relay) { | 957 if (!relay) { |
| 957 LOG(ERROR) << "Receiving Mach ports without a port relay from " | 958 LOG(ERROR) << "Receiving Mach ports without a port relay from " |
| 958 << from_node << ". Dropping message."; | 959 << from_node << ". Dropping message."; |
| 959 return; | 960 return; |
| 960 } | 961 } |
| 961 if (!relay->ExtractPortRights(message.get(), from_process)) { | 962 if (!relay->ExtractPortRights(message.get(), from_process)) { |
| 962 // NodeChannel should ensure that MachPortRelay is ready for the remote | 963 // NodeChannel should ensure that MachPortRelay is ready for the remote |
| 963 // process. At this point, if the port extraction failed, either something | 964 // process. At this point, if the port extraction failed, either something |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 shutdown_callback_flag_.Set(false); | 1031 shutdown_callback_flag_.Set(false); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 DCHECK(!callback.is_null()); | 1034 DCHECK(!callback.is_null()); |
| 1034 | 1035 |
| 1035 callback.Run(); | 1036 callback.Run(); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 } // namespace edk | 1039 } // namespace edk |
| 1039 } // namespace mojo | 1040 } // namespace mojo |
| OLD | NEW |