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

Unified Diff: base/process/launch_win.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Merge Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process/launch_posix.cc ('k') | base/process/process_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/launch_win.cc
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc
index 03ace4f59fedb67a423def9a94931324d97ea4eb..b13f70d7ce34a7b6321fba5be08c2aabfd5a78cd 100644
--- a/base/process/launch_win.cc
+++ b/base/process/launch_win.cc
@@ -212,42 +212,40 @@ Process LaunchProcess(const string16& cmdline,
win::StartupInformation startup_info_wrapper;
STARTUPINFO* startup_info = startup_info_wrapper.startup_info();
- bool inherit_handles = options.inherit_handles;
+ bool inherit_handles = options.inherit_mode == LaunchOptions::Inherit::kAll;
DWORD flags = 0;
- if (options.handles_to_inherit) {
- if (options.handles_to_inherit->empty()) {
- inherit_handles = false;
- } else {
- if (options.handles_to_inherit->size() >
- std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) {
- DLOG(ERROR) << "Too many handles to inherit.";
- return Process();
- }
-
- // Ensure the handles can be inherited.
- for (HANDLE handle : *options.handles_to_inherit) {
- BOOL result = SetHandleInformation(handle, HANDLE_FLAG_INHERIT,
- HANDLE_FLAG_INHERIT);
- PCHECK(result);
- }
-
- if (!startup_info_wrapper.InitializeProcThreadAttributeList(1)) {
- DPLOG(ERROR);
- return Process();
- }
-
- if (!startup_info_wrapper.UpdateProcThreadAttribute(
- PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
- const_cast<HANDLE*>(&options.handles_to_inherit->at(0)),
- static_cast<DWORD>(options.handles_to_inherit->size() *
- sizeof(HANDLE)))) {
- DPLOG(ERROR);
- return Process();
- }
-
- inherit_handles = true;
- flags |= EXTENDED_STARTUPINFO_PRESENT;
+ if (!options.handles_to_inherit.empty()) {
+ DCHECK_EQ(options.inherit_mode, LaunchOptions::Inherit::kSpecific);
+
+ if (options.handles_to_inherit.size() >
+ std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) {
+ DLOG(ERROR) << "Too many handles to inherit.";
+ return Process();
+ }
+
+ // Ensure the handles can be inherited.
+ for (HANDLE handle : options.handles_to_inherit) {
+ BOOL result = SetHandleInformation(handle, HANDLE_FLAG_INHERIT,
+ HANDLE_FLAG_INHERIT);
+ PCHECK(result);
+ }
+
+ if (!startup_info_wrapper.InitializeProcThreadAttributeList(1)) {
+ DPLOG(ERROR);
+ return Process();
}
+
+ if (!startup_info_wrapper.UpdateProcThreadAttribute(
+ PROC_THREAD_ATTRIBUTE_HANDLE_LIST,
+ const_cast<HANDLE*>(&options.handles_to_inherit[0]),
+ static_cast<DWORD>(options.handles_to_inherit.size() *
+ sizeof(HANDLE)))) {
+ DPLOG(ERROR);
+ return Process();
+ }
+
+ inherit_handles = true;
+ flags |= EXTENDED_STARTUPINFO_PRESENT;
}
if (options.empty_desktop_name)
« no previous file with comments | « base/process/launch_posix.cc ('k') | base/process/process_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698