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

Unified Diff: base/process/launch_win.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Fix Created 3 years, 6 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
Index: base/process/launch_win.cc
diff --git a/base/process/launch_win.cc b/base/process/launch_win.cc
index f55c96841503b34f17ecf8649ee55078861412d4..59678722fe80e7f537a6640f67cadf1623dcb630 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)

Powered by Google App Engine
This is Rietveld 408576698