| 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/base_test_server.h" | 5 #include "net/test/base_test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 BoundNetLog()); | 169 BoundNetLog()); |
| 170 if (rv == ERR_IO_PENDING) | 170 if (rv == ERR_IO_PENDING) |
| 171 rv = callback.WaitForResult(); | 171 rv = callback.WaitForResult(); |
| 172 if (rv != net::OK) { | 172 if (rv != net::OK) { |
| 173 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host(); | 173 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host(); |
| 174 return false; | 174 return false; |
| 175 } | 175 } |
| 176 return true; | 176 return true; |
| 177 } | 177 } |
| 178 | 178 |
| 179 uint16 BaseTestServer::GetPort() { | 179 uint16 BaseTestServer::GetPort() const { |
| 180 return host_port_pair_.port(); | 180 return host_port_pair_.port(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void BaseTestServer::SetPort(uint16 port) { | 183 void BaseTestServer::SetPort(uint16 port) { |
| 184 host_port_pair_.set_port(port); | 184 host_port_pair_.set_port(port); |
| 185 } | 185 } |
| 186 | 186 |
| 187 uint16 BaseTestServer::GetXmppPort() const { |
| 188 return xmpp_port_; |
| 189 } |
| 190 |
| 191 void BaseTestServer::SetXmppPort(uint16 xmpp_port) { |
| 192 xmpp_port_ = xmpp_port; |
| 193 } |
| 194 |
| 187 GURL BaseTestServer::GetURL(const std::string& path) const { | 195 GURL BaseTestServer::GetURL(const std::string& path) const { |
| 188 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path); | 196 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path); |
| 189 } | 197 } |
| 190 | 198 |
| 191 GURL BaseTestServer::GetURLWithUser(const std::string& path, | 199 GURL BaseTestServer::GetURLWithUser(const std::string& path, |
| 192 const std::string& user) const { | 200 const std::string& user) const { |
| 193 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() + | 201 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() + |
| 194 "/" + path); | 202 "/" + path); |
| 195 } | 203 } |
| 196 | 204 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 // the test server spawner, in the form of | 328 // the test server spawner, in the form of |
| 321 // { argument-name: argument-value, ... } | 329 // { argument-name: argument-value, ... } |
| 322 // Returns false if an invalid configuration is specified. | 330 // Returns false if an invalid configuration is specified. |
| 323 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { | 331 bool BaseTestServer::GenerateArguments(base::DictionaryValue* arguments) const { |
| 324 DCHECK(arguments); | 332 DCHECK(arguments); |
| 325 | 333 |
| 326 arguments->SetString("host", host_port_pair_.host()); | 334 arguments->SetString("host", host_port_pair_.host()); |
| 327 arguments->SetInteger("port", host_port_pair_.port()); | 335 arguments->SetInteger("port", host_port_pair_.port()); |
| 328 arguments->SetString("data-dir", document_root_.value()); | 336 arguments->SetString("data-dir", document_root_.value()); |
| 329 | 337 |
| 338 if (type_ == TYPE_SYNC && xmpp_port_ != 0) { |
| 339 arguments->SetInteger("xmpp-port", xmpp_port_); |
| 340 } |
| 341 |
| 330 if (VLOG_IS_ON(1) || log_to_console_) | 342 if (VLOG_IS_ON(1) || log_to_console_) |
| 331 arguments->Set("log-to-console", base::Value::CreateNullValue()); | 343 arguments->Set("log-to-console", base::Value::CreateNullValue()); |
| 332 | 344 |
| 333 if (type_ == TYPE_HTTPS) { | 345 if (type_ == TYPE_HTTPS) { |
| 334 arguments->Set("https", base::Value::CreateNullValue()); | 346 arguments->Set("https", base::Value::CreateNullValue()); |
| 335 | 347 |
| 336 // Check the certificate arguments of the HTTPS server. | 348 // Check the certificate arguments of the HTTPS server. |
| 337 FilePath certificate_path(certificates_dir_); | 349 FilePath certificate_path(certificates_dir_); |
| 338 FilePath certificate_file(https_options_.GetCertificateFile()); | 350 FilePath certificate_file(https_options_.GetCertificateFile()); |
| 339 if (!certificate_file.value().empty()) { | 351 if (!certificate_file.value().empty()) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); | 389 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); |
| 378 if (https_options_.record_resume) | 390 if (https_options_.record_resume) |
| 379 arguments->Set("https-record-resume", base::Value::CreateNullValue()); | 391 arguments->Set("https-record-resume", base::Value::CreateNullValue()); |
| 380 if (https_options_.tls_intolerant) | 392 if (https_options_.tls_intolerant) |
| 381 arguments->Set("tls-intolerant", base::Value::CreateNullValue()); | 393 arguments->Set("tls-intolerant", base::Value::CreateNullValue()); |
| 382 } | 394 } |
| 383 return true; | 395 return true; |
| 384 } | 396 } |
| 385 | 397 |
| 386 } // namespace net | 398 } // namespace net |
| OLD | NEW |