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

Side by Side Diff: base/test/launcher/test_launcher.cc

Issue 369703003: Reduce usage of MessageLoopProxy in base/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Explicit Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/test/launcher/test_launcher.h" 5 #include "base/test/launcher/test_launcher.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #endif 9 #endif
10 10
(...skipping 15 matching lines...) Expand all
26 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
27 #include "base/strings/string_split.h" 27 #include "base/strings/string_split.h"
28 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
29 #include "base/strings/stringize_macros.h" 29 #include "base/strings/stringize_macros.h"
30 #include "base/strings/stringprintf.h" 30 #include "base/strings/stringprintf.h"
31 #include "base/strings/utf_string_conversions.h" 31 #include "base/strings/utf_string_conversions.h"
32 #include "base/test/launcher/test_results_tracker.h" 32 #include "base/test/launcher/test_results_tracker.h"
33 #include "base/test/sequenced_worker_pool_owner.h" 33 #include "base/test/sequenced_worker_pool_owner.h"
34 #include "base/test/test_switches.h" 34 #include "base/test/test_switches.h"
35 #include "base/test/test_timeouts.h" 35 #include "base/test/test_timeouts.h"
36 #include "base/thread_task_runner_handle.h"
36 #include "base/threading/thread_checker.h" 37 #include "base/threading/thread_checker.h"
37 #include "base/time/time.h" 38 #include "base/time/time.h"
38 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
39 40
40 #if defined(OS_MACOSX) 41 #if defined(OS_MACOSX)
41 #include "base/mac/scoped_nsautorelease_pool.h" 42 #include "base/mac/scoped_nsautorelease_pool.h"
42 #endif 43 #endif
43 44
44 namespace base { 45 namespace base {
45 46
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 bool was_timeout, 219 bool was_timeout,
219 const std::string& output) { 220 const std::string& output) {
220 callback.Run(exit_code, elapsed_time, was_timeout, output); 221 callback.Run(exit_code, elapsed_time, was_timeout, output);
221 } 222 }
222 223
223 void DoLaunchChildTestProcess( 224 void DoLaunchChildTestProcess(
224 const CommandLine& command_line, 225 const CommandLine& command_line,
225 base::TimeDelta timeout, 226 base::TimeDelta timeout,
226 bool use_job_objects, 227 bool use_job_objects,
227 bool redirect_stdio, 228 bool redirect_stdio,
228 scoped_refptr<MessageLoopProxy> message_loop_proxy, 229 scoped_refptr<SequencedTaskRunner> task_runner,
229 const TestLauncher::LaunchChildGTestProcessCallback& callback) { 230 const TestLauncher::LaunchChildGTestProcessCallback& callback) {
230 TimeTicks start_time = TimeTicks::Now(); 231 TimeTicks start_time = TimeTicks::Now();
231 232
232 // Redirect child process output to a file. 233 // Redirect child process output to a file.
233 base::FilePath output_file; 234 base::FilePath output_file;
234 CHECK(base::CreateTemporaryFile(&output_file)); 235 CHECK(base::CreateTemporaryFile(&output_file));
235 236
236 LaunchOptions options; 237 LaunchOptions options;
237 #if defined(OS_WIN) 238 #if defined(OS_WIN)
238 win::ScopedHandle handle; 239 win::ScopedHandle handle;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 std::string output_file_contents; 290 std::string output_file_contents;
290 CHECK(base::ReadFileToString(output_file, &output_file_contents)); 291 CHECK(base::ReadFileToString(output_file, &output_file_contents));
291 292
292 if (!base::DeleteFile(output_file, false)) { 293 if (!base::DeleteFile(output_file, false)) {
293 // This needs to be non-fatal at least for Windows. 294 // This needs to be non-fatal at least for Windows.
294 LOG(WARNING) << "Failed to delete " << output_file.AsUTF8Unsafe(); 295 LOG(WARNING) << "Failed to delete " << output_file.AsUTF8Unsafe();
295 } 296 }
296 297
297 // Run target callback on the thread it was originating from, not on 298 // Run target callback on the thread it was originating from, not on
298 // a worker pool thread. 299 // a worker pool thread.
299 message_loop_proxy->PostTask( 300 task_runner->PostTask(FROM_HERE,
300 FROM_HERE, 301 Bind(&RunCallback,
301 Bind(&RunCallback, 302 callback,
302 callback, 303 exit_code,
303 exit_code, 304 TimeTicks::Now() - start_time,
304 TimeTicks::Now() - start_time, 305 was_timeout,
305 was_timeout, 306 output_file_contents));
306 output_file_contents));
307 } 307 }
308 308
309 } // namespace 309 } // namespace
310 310
311 const char kGTestFilterFlag[] = "gtest_filter"; 311 const char kGTestFilterFlag[] = "gtest_filter";
312 const char kGTestHelpFlag[] = "gtest_help"; 312 const char kGTestHelpFlag[] = "gtest_help";
313 const char kGTestListTestsFlag[] = "gtest_list_tests"; 313 const char kGTestListTestsFlag[] = "gtest_list_tests";
314 const char kGTestRepeatFlag[] = "gtest_repeat"; 314 const char kGTestRepeatFlag[] = "gtest_repeat";
315 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; 315 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests";
316 const char kGTestOutputFlag[] = "gtest_output"; 316 const char kGTestOutputFlag[] = "gtest_output";
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // JSON summary. 422 // JSON summary.
423 bool redirect_stdio = (parallel_jobs_ > 1) || BotModeEnabled(); 423 bool redirect_stdio = (parallel_jobs_ > 1) || BotModeEnabled();
424 424
425 worker_pool_owner_->pool()->PostWorkerTask( 425 worker_pool_owner_->pool()->PostWorkerTask(
426 FROM_HERE, 426 FROM_HERE,
427 Bind(&DoLaunchChildTestProcess, 427 Bind(&DoLaunchChildTestProcess,
428 new_command_line, 428 new_command_line,
429 timeout, 429 timeout,
430 use_job_objects, 430 use_job_objects,
431 redirect_stdio, 431 redirect_stdio,
432 MessageLoopProxy::current(), 432 ThreadTaskRunnerHandle::Get(),
433 Bind(&TestLauncher::OnLaunchTestProcessFinished, 433 Bind(&TestLauncher::OnLaunchTestProcessFinished,
434 Unretained(this), 434 Unretained(this),
435 callback))); 435 callback)));
436 } 436 }
437 437
438 void TestLauncher::OnTestFinished(const TestResult& result) { 438 void TestLauncher::OnTestFinished(const TestResult& result) {
439 ++test_finished_count_; 439 ++test_finished_count_;
440 440
441 bool print_snippet = false; 441 bool print_snippet = false;
442 std::string print_test_stdio("auto"); 442 std::string print_test_stdio("auto");
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1089
1090 g_live_processes.Get().erase(process_handle); 1090 g_live_processes.Get().erase(process_handle);
1091 } 1091 }
1092 1092
1093 base::CloseProcessHandle(process_handle); 1093 base::CloseProcessHandle(process_handle);
1094 1094
1095 return exit_code; 1095 return exit_code;
1096 } 1096 }
1097 1097
1098 } // namespace base 1098 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698