Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: mojo/edk/system/node_controller.cc

Issue 1914053003: [mojo-edk] Fix lifetime management of rewritten Windows HANDLEs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/node_channel.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 904
905 // The parent should always know which process this came from. 905 // The parent should always know which process this came from.
906 DCHECK(from_process != base::kNullProcessHandle); 906 DCHECK(from_process != base::kNullProcessHandle);
907 907
908 #if defined(OS_WIN) 908 #if defined(OS_WIN)
909 // Rewrite the handles to this (the parent) process. If the message is 909 // Rewrite the handles to this (the parent) process. If the message is
910 // destined for another child process, the handles will be rewritten to that 910 // destined for another child process, the handles will be rewritten to that
911 // process before going out (see NodeChannel::WriteChannelMessage). 911 // process before going out (see NodeChannel::WriteChannelMessage).
912 // 912 //
913 // TODO: We could avoid double-duplication. 913 // TODO: We could avoid double-duplication.
914 //
915 // Note that we explicitly mark the handles as being owned by the sending
916 // process before rewriting them, in order to accommodate RewriteHandles'
917 // internal sanity checks.
918 for (size_t i = 0; i < message->num_handles(); ++i)
919 message->handles()[i].owning_process = from_process;
914 if (!Channel::Message::RewriteHandles(from_process, 920 if (!Channel::Message::RewriteHandles(from_process,
915 base::GetCurrentProcessHandle(), 921 base::GetCurrentProcessHandle(),
916 message->handles(), 922 message->handles(),
917 message->num_handles())) { 923 message->num_handles())) {
918 DLOG(ERROR) << "Failed to relay one or more handles."; 924 DLOG(ERROR) << "Failed to relay one or more handles.";
919 } 925 }
920 #else 926 #else
921 MachPortRelay* relay = GetMachPortRelay(); 927 MachPortRelay* relay = GetMachPortRelay();
922 if (!relay) { 928 if (!relay) {
923 LOG(ERROR) << "Receiving Mach ports without a port relay from " 929 LOG(ERROR) << "Receiving Mach ports without a port relay from "
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 shutdown_callback_flag_.Set(false); 1001 shutdown_callback_flag_.Set(false);
996 } 1002 }
997 1003
998 DCHECK(!callback.is_null()); 1004 DCHECK(!callback.is_null());
999 1005
1000 callback.Run(); 1006 callback.Run();
1001 } 1007 }
1002 1008
1003 } // namespace edk 1009 } // namespace edk
1004 } // namespace mojo 1010 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/node_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698