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

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

Issue 2111453002: [mojo-edk] Duplicate process handle and take ownership in NodeChannel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ports::NodeName node_name; 172 ports::NodeName node_name;
173 GenerateRandomName(&node_name); 173 GenerateRandomName(&node_name);
174 174
175 { 175 {
176 base::AutoLock lock(reserved_ports_lock_); 176 base::AutoLock lock(reserved_ports_lock_);
177 bool inserted = pending_child_tokens_.insert( 177 bool inserted = pending_child_tokens_.insert(
178 std::make_pair(node_name, child_token)).second; 178 std::make_pair(node_name, child_token)).second;
179 DCHECK(inserted); 179 DCHECK(inserted);
180 } 180 }
181 181
182 #if defined(OS_WIN)
183 // On Windows, we need to duplicate the process handle because we have no
184 // control over its lifetime and it may become invalid by the time the posted
185 // task runs.
186 HANDLE dup_handle = INVALID_HANDLE_VALUE;
187 BOOL ok = ::DuplicateHandle(
188 base::GetCurrentProcessHandle(), process_handle,
189 base::GetCurrentProcessHandle(), &dup_handle,
190 0, FALSE, DUPLICATE_SAME_ACCESS);
191 DPCHECK(ok);
192 process_handle = dup_handle;
193 #endif
194
182 io_task_runner_->PostTask( 195 io_task_runner_->PostTask(
183 FROM_HERE, 196 FROM_HERE,
184 base::Bind(&NodeController::ConnectToChildOnIOThread, 197 base::Bind(&NodeController::ConnectToChildOnIOThread,
185 base::Unretained(this), 198 base::Unretained(this),
186 process_handle, 199 process_handle,
187 base::Passed(&platform_handle), 200 base::Passed(&platform_handle),
188 node_name, 201 node_name,
189 process_error_callback)); 202 process_error_callback));
190 } 203 }
191 204
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 shutdown_callback_flag_.Set(false); 1203 shutdown_callback_flag_.Set(false);
1191 } 1204 }
1192 1205
1193 DCHECK(!callback.is_null()); 1206 DCHECK(!callback.is_null());
1194 1207
1195 callback.Run(); 1208 callback.Run();
1196 } 1209 }
1197 1210
1198 } // namespace edk 1211 } // namespace edk
1199 } // namespace mojo 1212 } // 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