OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/component_updater/component_patcher_win.h" | 5 #include "chrome/browser/component_updater/component_patcher_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 CommandLine cl(CommandLine::NO_PROGRAM); | 78 CommandLine cl(CommandLine::NO_PROGRAM); |
79 cl.AppendSwitchASCII(installer::switches::kPatch, patch_type_str.c_str()); | 79 cl.AppendSwitchASCII(installer::switches::kPatch, patch_type_str.c_str()); |
80 cl.AppendSwitchPath(installer::switches::kInputFile, input_file); | 80 cl.AppendSwitchPath(installer::switches::kInputFile, input_file); |
81 cl.AppendSwitchPath(installer::switches::kPatchFile, patch_file); | 81 cl.AppendSwitchPath(installer::switches::kPatchFile, patch_file); |
82 cl.AppendSwitchPath(installer::switches::kOutputFile, output_file); | 82 cl.AppendSwitchPath(installer::switches::kOutputFile, output_file); |
83 | 83 |
84 // Create the child process in a job object. The job object prevents leaving | 84 // Create the child process in a job object. The job object prevents leaving |
85 // child processes around when the parent process exits, either gracefully or | 85 // child processes around when the parent process exits, either gracefully or |
86 // accidentally. | 86 // accidentally. |
87 base::win::ScopedHandle job(CreateJobObject(NULL, NULL)); | 87 base::win::ScopedHandle job(CreateJobObject(NULL, NULL)); |
88 if (!job || !base::SetJobObjectAsKillOnJobClose(job)) { | 88 if (!job || |
| 89 !base::SetJobObjectLimitFlags(job, JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE)) { |
89 *error = GetLastError(); | 90 *error = GetLastError(); |
90 return ComponentUnpacker::kDeltaPatchProcessFailure; | 91 return ComponentUnpacker::kDeltaPatchProcessFailure; |
91 } | 92 } |
92 | 93 |
93 base::LaunchOptions launch_options; | 94 base::LaunchOptions launch_options; |
94 launch_options.wait = true; | 95 launch_options.wait = true; |
95 launch_options.job_handle = job; | 96 launch_options.job_handle = job; |
96 launch_options.start_hidden = true; | 97 launch_options.start_hidden = true; |
97 CommandLine setup_path(exe_path); | 98 CommandLine setup_path(exe_path); |
98 setup_path.AppendArguments(cl, false); | 99 setup_path.AppendArguments(cl, false); |
99 | 100 |
100 // |ph| is closed by WaitForExitCode. | 101 // |ph| is closed by WaitForExitCode. |
101 base::ProcessHandle ph = base::kNullProcessHandle; | 102 base::ProcessHandle ph = base::kNullProcessHandle; |
102 int exit_code = 0; | 103 int exit_code = 0; |
103 if (!base::LaunchProcess(setup_path, launch_options, &ph) || | 104 if (!base::LaunchProcess(setup_path, launch_options, &ph) || |
104 !base::WaitForExitCode(ph, &exit_code)) { | 105 !base::WaitForExitCode(ph, &exit_code)) { |
105 *error = GetLastError(); | 106 *error = GetLastError(); |
106 return ComponentUnpacker::kDeltaPatchProcessFailure; | 107 return ComponentUnpacker::kDeltaPatchProcessFailure; |
107 } | 108 } |
108 | 109 |
109 *error = exit_code; | 110 *error = exit_code; |
110 return *error ? ComponentUnpacker::kDeltaOperationFailure : | 111 return *error ? ComponentUnpacker::kDeltaOperationFailure : |
111 ComponentUnpacker::kNone; | 112 ComponentUnpacker::kNone; |
112 } | 113 } |
113 | 114 |
OLD | NEW |