OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 | 91 |
92 Init(host, document_root); | 92 Init(host, document_root); |
93 } | 93 } |
94 | 94 |
95 TestServer::~TestServer() { | 95 TestServer::~TestServer() { |
96 TestRootCerts* root_certs = TestRootCerts::GetInstance(); | 96 TestRootCerts* root_certs = TestRootCerts::GetInstance(); |
97 root_certs->Clear(); | 97 root_certs->Clear(); |
98 Stop(); | 98 Stop(); |
99 } | 99 } |
100 | 100 |
101 FilePath TestServer::GetTestServerDirectory() { | |
102 // Get path to python server script. | |
103 FilePath testserver_dir; | |
104 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_dir)) { | |
105 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; | |
106 return FilePath(); | |
Paweł Hajdan Jr.
2012/03/13 17:15:23
I don't like potentially ambiguous return types. M
tim (not reviewing)
2012/03/15 00:41:40
Done.
| |
107 } | |
108 | |
109 testserver_dir = testserver_dir | |
110 .Append(FILE_PATH_LITERAL("net")) | |
111 .Append(FILE_PATH_LITERAL("tools")) | |
112 .Append(FILE_PATH_LITERAL("testserver")); | |
113 return testserver_dir; | |
114 } | |
115 | |
101 bool TestServer::Start() { | 116 bool TestServer::Start() { |
102 if (type_ == TYPE_HTTPS) { | 117 if (type_ == TYPE_HTTPS) { |
103 if (!LoadTestRootCert()) | 118 if (!LoadTestRootCert()) |
104 return false; | 119 return false; |
105 } | 120 } |
106 | 121 |
107 // Get path to python server script | 122 FilePath testserver_path(GetTestServerDirectory()); |
108 FilePath testserver_path; | 123 if (testserver_path.empty()) |
109 if (!PathService::Get(base::DIR_SOURCE_ROOT, &testserver_path)) { | |
110 LOG(ERROR) << "Failed to get DIR_SOURCE_ROOT"; | |
111 return false; | 124 return false; |
112 } | 125 testserver_path = |
113 testserver_path = testserver_path | 126 testserver_path.Append(FILE_PATH_LITERAL("testserver.py")); |
114 .Append(FILE_PATH_LITERAL("net")) | |
115 .Append(FILE_PATH_LITERAL("tools")) | |
116 .Append(FILE_PATH_LITERAL("testserver")) | |
117 .Append(FILE_PATH_LITERAL("testserver.py")); | |
118 | 127 |
119 if (!SetPythonPath()) | 128 if (!SetPythonPath()) |
120 return false; | 129 return false; |
121 | 130 |
122 if (!LaunchPython(testserver_path)) | 131 if (!LaunchPython(testserver_path)) |
123 return false; | 132 return false; |
124 | 133 |
125 if (!WaitToStart()) { | 134 if (!WaitToStart()) { |
126 Stop(); | 135 Stop(); |
127 return false; | 136 return false; |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 command_line->AppendArg(kBulkCipherSwitch + "=3des"); | 421 command_line->AppendArg(kBulkCipherSwitch + "=3des"); |
413 | 422 |
414 if (https_options_.record_resume) | 423 if (https_options_.record_resume) |
415 command_line->AppendArg("--https-record-resume"); | 424 command_line->AppendArg("--https-record-resume"); |
416 } | 425 } |
417 | 426 |
418 return true; | 427 return true; |
419 } | 428 } |
420 | 429 |
421 } // namespace net | 430 } // namespace net |
OLD | NEW |