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/local_test_server.h" | 5 #include "net/test/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" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return false; | 84 return false; |
85 } | 85 } |
86 testserver_dir = testserver_dir.Append(FILE_PATH_LITERAL("net")) | 86 testserver_dir = testserver_dir.Append(FILE_PATH_LITERAL("net")) |
87 .Append(FILE_PATH_LITERAL("tools")) | 87 .Append(FILE_PATH_LITERAL("tools")) |
88 .Append(FILE_PATH_LITERAL("testserver")); | 88 .Append(FILE_PATH_LITERAL("testserver")); |
89 *testserver_path = testserver_dir.Append(FILE_PATH_LITERAL("testserver.py")); | 89 *testserver_path = testserver_dir.Append(FILE_PATH_LITERAL("testserver.py")); |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 bool LocalTestServer::Start() { | 93 bool LocalTestServer::Start() { |
| 94 return StartInBackground() && BlockUntilStarted(); |
| 95 } |
| 96 |
| 97 bool LocalTestServer::StartInBackground() { |
94 // Get path to Python server script. | 98 // Get path to Python server script. |
95 FilePath testserver_path; | 99 FilePath testserver_path; |
96 if (!GetTestServerPath(&testserver_path)) | 100 if (!GetTestServerPath(&testserver_path)) |
97 return false; | 101 return false; |
98 | 102 |
99 if (!SetPythonPath()) | 103 if (!SetPythonPath()) |
100 return false; | 104 return false; |
101 | 105 |
102 if (!LaunchPython(testserver_path)) | 106 if (!LaunchPython(testserver_path)) |
103 return false; | 107 return false; |
104 | 108 |
| 109 return true; |
| 110 } |
| 111 |
| 112 bool LocalTestServer::BlockUntilStarted() { |
105 if (!WaitToStart()) { | 113 if (!WaitToStart()) { |
106 Stop(); | 114 Stop(); |
107 return false; | 115 return false; |
108 } | 116 } |
109 | 117 |
110 return SetupWhenServerStarted(); | 118 return SetupWhenServerStarted(); |
111 } | 119 } |
112 | 120 |
113 bool LocalTestServer::Stop() { | 121 bool LocalTestServer::Stop() { |
114 CleanUpWhenStoppingServer(); | 122 CleanUpWhenStoppingServer(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 break; | 250 break; |
243 default: | 251 default: |
244 NOTREACHED(); | 252 NOTREACHED(); |
245 return false; | 253 return false; |
246 } | 254 } |
247 | 255 |
248 return true; | 256 return true; |
249 } | 257 } |
250 | 258 |
251 } // namespace net | 259 } // namespace net |
OLD | NEW |