| OLD | NEW |
| 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 "net/test/spawned_test_server/local_test_server.h" | 5 #include "net/test/spawned_test_server/local_test_server.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/threading/thread_restrictions.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "net/base/host_port_pair.h" | 14 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 15 #include "net/test/python_utils.h" | 16 #include "net/test/python_utils.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 .Append(FILE_PATH_LITERAL("testserver")); | 88 .Append(FILE_PATH_LITERAL("testserver")); |
| 88 *testserver_path = testserver_dir.Append(FILE_PATH_LITERAL("testserver.py")); | 89 *testserver_path = testserver_dir.Append(FILE_PATH_LITERAL("testserver.py")); |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool LocalTestServer::Start() { | 93 bool LocalTestServer::Start() { |
| 93 return StartInBackground() && BlockUntilStarted(); | 94 return StartInBackground() && BlockUntilStarted(); |
| 94 } | 95 } |
| 95 | 96 |
| 96 bool LocalTestServer::StartInBackground() { | 97 bool LocalTestServer::StartInBackground() { |
| 98 base::ThreadRestrictions::ScopedAllowIO allow_io_from_test_code; |
| 99 |
| 97 // Get path to Python server script. | 100 // Get path to Python server script. |
| 98 base::FilePath testserver_path; | 101 base::FilePath testserver_path; |
| 99 if (!GetTestServerPath(&testserver_path)) | 102 if (!GetTestServerPath(&testserver_path)) |
| 100 return false; | 103 return false; |
| 101 | 104 |
| 102 if (!SetPythonPath()) | 105 if (!SetPythonPath()) |
| 103 return false; | 106 return false; |
| 104 | 107 |
| 105 if (!LaunchPython(testserver_path)) | 108 if (!LaunchPython(testserver_path)) |
| 106 return false; | 109 return false; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 break; | 244 break; |
| 242 default: | 245 default: |
| 243 NOTREACHED(); | 246 NOTREACHED(); |
| 244 return false; | 247 return false; |
| 245 } | 248 } |
| 246 | 249 |
| 247 return true; | 250 return true; |
| 248 } | 251 } |
| 249 | 252 |
| 250 } // namespace net | 253 } // namespace net |
| OLD | NEW |