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

Side by Side Diff: net/test/test_server_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 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 | « chrome/test/ui/ui_test_suite.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 (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 "net/test/test_server.h" 5 #include "net/test/test_server.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <wincrypt.h> 8 #include <wincrypt.h>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "base/process_util.h"
16 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "base/test/test_timeouts.h" 19 #include "base/test/test_timeouts.h"
19 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
21 #include "base/win/scoped_handle.h" 22 #include "base/win/scoped_handle.h"
22 23
23 #pragma comment(lib, "crypt32.lib") 24 #pragma comment(lib, "crypt32.lib")
24 25
25 namespace { 26 namespace {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // 64-bit)." 126 // 64-bit)."
126 python_command.AppendArg("--startup-pipe=" + 127 python_command.AppendArg("--startup-pipe=" +
127 base::IntToString(reinterpret_cast<uintptr_t>(child_write))); 128 base::IntToString(reinterpret_cast<uintptr_t>(child_write)));
128 129
129 job_handle_.Set(CreateJobObject(NULL, NULL)); 130 job_handle_.Set(CreateJobObject(NULL, NULL));
130 if (!job_handle_.IsValid()) { 131 if (!job_handle_.IsValid()) {
131 LOG(ERROR) << "Could not create JobObject."; 132 LOG(ERROR) << "Could not create JobObject.";
132 return false; 133 return false;
133 } 134 }
134 135
135 JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info = {0}; 136 if (!base::SetJobObjectAsKillOnJobClose(job_handle_.Get())) {
136 limit_info.BasicLimitInformation.LimitFlags =
137 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
138 if (0 == SetInformationJobObject(job_handle_.Get(),
139 JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info))) {
140 LOG(ERROR) << "Could not SetInformationJobObject."; 137 LOG(ERROR) << "Could not SetInformationJobObject.";
141 return false; 138 return false;
142 } 139 }
143 140
144 base::LaunchOptions launch_options; 141 base::LaunchOptions launch_options;
145 launch_options.inherit_handles = true; 142 launch_options.inherit_handles = true;
146 launch_options.job_handle = job_handle_.Get(); 143 launch_options.job_handle = job_handle_.Get();
147 if (!base::LaunchProcess(python_command, launch_options, &process_handle_)) { 144 if (!base::LaunchProcess(python_command, launch_options, &process_handle_)) {
148 LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString(); 145 LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString();
149 return false; 146 return false;
(...skipping 22 matching lines...) Expand all
172 169
173 if (!ParseServerData(server_data)) { 170 if (!ParseServerData(server_data)) {
174 LOG(ERROR) << "Could not parse server_data: " << server_data; 171 LOG(ERROR) << "Could not parse server_data: " << server_data;
175 return false; 172 return false;
176 } 173 }
177 174
178 return true; 175 return true;
179 } 176 }
180 177
181 } // namespace net 178 } // namespace net
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test_suite.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698