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/remote_test_server.h" | 5 #include "net/test/remote_test_server.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // root in the host machine where the test server is launched. So prepend | 154 // root in the host machine where the test server is launched. So prepend |
155 // DIR_SOURCE_ROOT here to get the actual path of document root on the Android | 155 // DIR_SOURCE_ROOT here to get the actual path of document root on the Android |
156 // device. | 156 // device. |
157 base::FilePath RemoteTestServer::GetDocumentRoot() const { | 157 base::FilePath RemoteTestServer::GetDocumentRoot() const { |
158 base::FilePath src_dir; | 158 base::FilePath src_dir; |
159 PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); | 159 PathService::Get(base::DIR_SOURCE_ROOT, &src_dir); |
160 return src_dir.Append(document_root()); | 160 return src_dir.Append(document_root()); |
161 } | 161 } |
162 | 162 |
163 bool RemoteTestServer::Init(const base::FilePath& document_root) { | 163 bool RemoteTestServer::Init(const base::FilePath& document_root) { |
164 if (document_root.IsAbsolute()) | 164 if (!document_root.IsAbsolute()) |
165 return false; | 165 return false; |
166 | 166 |
167 // Gets ports information used by test server spawner and Python test server. | 167 // Gets ports information used by test server spawner and Python test server. |
168 int test_server_port = 0; | 168 int test_server_port = 0; |
169 | 169 |
170 // Parse file to extract the ports information. | 170 // Parse file to extract the ports information. |
171 std::string port_info; | 171 std::string port_info; |
172 if (!file_util::ReadFileToString(GetTestServerPortInfoFile(), | 172 if (!file_util::ReadFileToString(GetTestServerPortInfoFile(), |
173 &port_info) || | 173 &port_info) || |
174 port_info.empty()) { | 174 port_info.empty()) { |
(...skipping 12 matching lines...) Expand all Loading... |
187 return false; | 187 return false; |
188 | 188 |
189 // Allow the test_server_port to be 0, which means the test server spawner | 189 // Allow the test_server_port to be 0, which means the test server spawner |
190 // will pick up a random port to run the test server. | 190 // will pick up a random port to run the test server. |
191 base::StringToInt(ports[1], &test_server_port); | 191 base::StringToInt(ports[1], &test_server_port); |
192 if (static_cast<uint32>(test_server_port) >= kuint16max) | 192 if (static_cast<uint32>(test_server_port) >= kuint16max) |
193 return false; | 193 return false; |
194 SetPort(test_server_port); | 194 SetPort(test_server_port); |
195 | 195 |
196 SetResourcePath(document_root, base::FilePath().AppendASCII("net") | 196 SetResourcePath(document_root, base::FilePath().AppendASCII("net") |
197 .AppendASCII("data") | 197 .AppendASCII("data") |
198 .AppendASCII("ssl") | 198 .AppendASCII("ssl") |
199 .AppendASCII("certificates")); | 199 .AppendASCII("certificates")); |
200 return true; | 200 return true; |
201 } | 201 } |
202 | 202 |
203 } // namespace net | 203 } // namespace net |
204 | 204 |
OLD | NEW |