| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 base::CloseProcessHandle(process_handle_); | 133 base::CloseProcessHandle(process_handle_); |
| 134 process_handle_ = base::kNullProcessHandle; | 134 process_handle_ = base::kNullProcessHandle; |
| 135 } else { | 135 } else { |
| 136 VLOG(1) << "Kill failed?"; | 136 VLOG(1) << "Kill failed?"; |
| 137 } | 137 } |
| 138 | 138 |
| 139 return ret; | 139 return ret; |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool LocalTestServer::Init(const FilePath& document_root) { | 142 bool LocalTestServer::Init(const FilePath& document_root) { |
| 143 if (document_root.IsAbsolute()) | |
| 144 return false; | |
| 145 | |
| 146 // At this point, the port that the test server will listen on is unknown. | 143 // At this point, the port that the test server will listen on is unknown. |
| 147 // The test server will listen on an ephemeral port, and write the port | 144 // The test server will listen on an ephemeral port, and write the port |
| 148 // number out over a pipe that this TestServer object will read from. Once | 145 // number out over a pipe that this TestServer object will read from. Once |
| 149 // that is complete, the host port pair will contain the actual port. | 146 // that is complete, the host port pair will contain the actual port. |
| 150 DCHECK(!GetPort()); | 147 DCHECK(!GetPort()); |
| 151 process_handle_ = base::kNullProcessHandle; | 148 process_handle_ = base::kNullProcessHandle; |
| 152 | 149 |
| 153 FilePath src_dir; | 150 FilePath src_dir; |
| 154 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) | 151 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir)) |
| 155 return false; | 152 return false; |
| 156 SetResourcePath(src_dir.Append(document_root), | 153 |
| 154 FilePath root; |
| 155 if (document_root.IsAbsolute()) |
| 156 root = document_root; |
| 157 else |
| 158 root = src_dir.Append(document_root); |
| 159 |
| 160 SetResourcePath(root, |
| 157 src_dir.AppendASCII("net") | 161 src_dir.AppendASCII("net") |
| 158 .AppendASCII("data") | 162 .AppendASCII("data") |
| 159 .AppendASCII("ssl") | 163 .AppendASCII("ssl") |
| 160 .AppendASCII("certificates")); | 164 .AppendASCII("certificates")); |
| 161 return true; | 165 return true; |
| 162 } | 166 } |
| 163 | 167 |
| 164 bool LocalTestServer::SetPythonPath() const { | 168 bool LocalTestServer::SetPythonPath() const { |
| 165 FilePath third_party_dir; | 169 FilePath third_party_dir; |
| 166 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { | 170 if (!PathService::Get(base::DIR_SOURCE_ROOT, &third_party_dir)) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 break; | 254 break; |
| 251 default: | 255 default: |
| 252 NOTREACHED(); | 256 NOTREACHED(); |
| 253 return false; | 257 return false; |
| 254 } | 258 } |
| 255 | 259 |
| 256 return true; | 260 return true; |
| 257 } | 261 } |
| 258 | 262 |
| 259 } // namespace net | 263 } // namespace net |
| OLD | NEW |