| OLD | NEW |
| 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 "chrome/test/layout_test_http_server.h" | 5 #include "chrome/test/layout_test_http_server.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 layout_tests_dir.value()); | 75 layout_tests_dir.value()); |
| 76 | 76 |
| 77 // For Windows 7, if we start the lighttpd server on the foreground mode, | 77 // For Windows 7, if we start the lighttpd server on the foreground mode, |
| 78 // it will mess up with the command window and cause conhost.exe to crash. To | 78 // it will mess up with the command window and cause conhost.exe to crash. To |
| 79 // work around this, we start the http server on the background mode. | 79 // work around this, we start the http server on the background mode. |
| 80 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
| 81 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | 81 if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
| 82 cmd_line.AppendArg("--run_background"); | 82 cmd_line.AppendArg("--run_background"); |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 running_ = base::LaunchApp(cmd_line, true, false, NULL); | 85 // The Python script waits for the server to start responding to requests, |
| 86 // then exits. So we want to wait for the Python script to exit before |
| 87 // continuing. |
| 88 base::LaunchOptions options; |
| 89 options.wait = true; |
| 90 running_ = base::LaunchProcess(cmd_line, options); |
| 86 return running_; | 91 return running_; |
| 87 } | 92 } |
| 88 | 93 |
| 89 bool LayoutTestHttpServer::Stop() { | 94 bool LayoutTestHttpServer::Stop() { |
| 90 if (!running_) { | 95 if (!running_) { |
| 91 LOG(ERROR) << "LayoutTestHttpServer not running."; | 96 LOG(ERROR) << "LayoutTestHttpServer not running."; |
| 92 return false; | 97 return false; |
| 93 } | 98 } |
| 94 | 99 |
| 95 CommandLine cmd_line(CommandLine::NO_PROGRAM); | 100 CommandLine cmd_line(CommandLine::NO_PROGRAM); |
| 96 if (!PrepareCommandLine(&cmd_line)) | 101 if (!PrepareCommandLine(&cmd_line)) |
| 97 return false; | 102 return false; |
| 98 cmd_line.AppendArg("--server=stop"); | 103 cmd_line.AppendArg("--server=stop"); |
| 99 bool stopped = base::LaunchApp(cmd_line, true, false, NULL); | 104 |
| 105 base::LaunchOptions options; |
| 106 options.wait = true; |
| 107 bool stopped = base::LaunchProcess(cmd_line, options); |
| 100 running_ = !stopped; | 108 running_ = !stopped; |
| 101 return stopped; | 109 return stopped; |
| 102 } | 110 } |
| 103 | 111 |
| OLD | NEW |