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

Side by Side Diff: base/process_util_win.cc

Issue 8667006: Extract similar code into SetJobObjectAsKillOnJobClose() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « base/process_util.h ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/process_util.h" 5 #include "base/process_util.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <io.h> 8 #include <io.h>
9 #include <windows.h> 9 #include <windows.h>
10 #include <userenv.h> 10 #include <userenv.h>
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 355 }
356 return true; 356 return true;
357 } 357 }
358 358
359 bool LaunchProcess(const CommandLine& cmdline, 359 bool LaunchProcess(const CommandLine& cmdline,
360 const LaunchOptions& options, 360 const LaunchOptions& options,
361 ProcessHandle* process_handle) { 361 ProcessHandle* process_handle) {
362 return LaunchProcess(cmdline.GetCommandLineString(), options, process_handle); 362 return LaunchProcess(cmdline.GetCommandLineString(), options, process_handle);
363 } 363 }
364 364
365 bool SetJobObjectAsKillOnJobClose(HANDLE job_object) {
366 JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {0};
367 limit_info.BasicLimitInformation.LimitFlags =
368 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
369 return 0 != SetInformationJobObject(
370 job_object,
371 JobObjectExtendedLimitInformation,
372 &limit_info,
373 sizeof(limit_info));
374 }
375
365 // Attempts to kill the process identified by the given process 376 // Attempts to kill the process identified by the given process
366 // entry structure, giving it the specified exit code. 377 // entry structure, giving it the specified exit code.
367 // Returns true if this is successful, false otherwise. 378 // Returns true if this is successful, false otherwise.
368 bool KillProcessById(ProcessId process_id, int exit_code, bool wait) { 379 bool KillProcessById(ProcessId process_id, int exit_code, bool wait) {
369 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 380 HANDLE process = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE,
370 FALSE, // Don't inherit handle 381 FALSE, // Don't inherit handle
371 process_id); 382 process_id);
372 if (!process) { 383 if (!process) {
373 DLOG(ERROR) << "Unable to open process " << process_id << " : " 384 DLOG(ERROR) << "Unable to open process " << process_id << " : "
374 << GetLastError(); 385 << GetLastError();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 984
974 PERFORMANCE_INFORMATION info; 985 PERFORMANCE_INFORMATION info;
975 if (!InternalGetPerformanceInfo(&info, sizeof(info))) { 986 if (!InternalGetPerformanceInfo(&info, sizeof(info))) {
976 DLOG(ERROR) << "Failed to fetch internal performance info."; 987 DLOG(ERROR) << "Failed to fetch internal performance info.";
977 return 0; 988 return 0;
978 } 989 }
979 return (info.CommitTotal * system_info.dwPageSize) / 1024; 990 return (info.CommitTotal * system_info.dwPageSize) / 1024;
980 } 991 }
981 992
982 } // namespace base 993 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698