| 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/spawned_test_server/base_test_server.h" | 5 #include "net/test/spawned_test_server/base_test_server.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 9 #include <limits> |
| 7 #include <string> | 10 #include <string> |
| 8 #include <vector> | 11 #include <vector> |
| 9 | 12 |
| 10 #include "base/base64.h" | 13 #include "base/base64.h" |
| 11 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 12 #include "base/json/json_reader.h" | 15 #include "base/json/json_reader.h" |
| 13 #include "base/logging.h" | 16 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 15 #include "base/values.h" | 18 #include "base/values.h" |
| 16 #include "net/base/address_list.h" | 19 #include "net/base/address_list.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 BoundNetLog()); | 281 BoundNetLog()); |
| 279 if (rv == ERR_IO_PENDING) | 282 if (rv == ERR_IO_PENDING) |
| 280 rv = callback.WaitForResult(); | 283 rv = callback.WaitForResult(); |
| 281 if (rv != OK) { | 284 if (rv != OK) { |
| 282 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host(); | 285 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host(); |
| 283 return false; | 286 return false; |
| 284 } | 287 } |
| 285 return true; | 288 return true; |
| 286 } | 289 } |
| 287 | 290 |
| 288 uint16 BaseTestServer::GetPort() { | 291 uint16_t BaseTestServer::GetPort() { |
| 289 return host_port_pair_.port(); | 292 return host_port_pair_.port(); |
| 290 } | 293 } |
| 291 | 294 |
| 292 void BaseTestServer::SetPort(uint16 port) { | 295 void BaseTestServer::SetPort(uint16_t port) { |
| 293 host_port_pair_.set_port(port); | 296 host_port_pair_.set_port(port); |
| 294 } | 297 } |
| 295 | 298 |
| 296 GURL BaseTestServer::GetURL(const std::string& path) const { | 299 GURL BaseTestServer::GetURL(const std::string& path) const { |
| 297 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path); | 300 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path); |
| 298 } | 301 } |
| 299 | 302 |
| 300 GURL BaseTestServer::GetURLWithUser(const std::string& path, | 303 GURL BaseTestServer::GetURLWithUser(const std::string& path, |
| 301 const std::string& user) const { | 304 const std::string& user) const { |
| 302 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() + | 305 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() + |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 << json_reader.GetErrorMessage(); | 410 << json_reader.GetErrorMessage(); |
| 408 return false; | 411 return false; |
| 409 } | 412 } |
| 410 | 413 |
| 411 server_data_.reset(static_cast<base::DictionaryValue*>(value.release())); | 414 server_data_.reset(static_cast<base::DictionaryValue*>(value.release())); |
| 412 int port = 0; | 415 int port = 0; |
| 413 if (!server_data_->GetInteger("port", &port)) { | 416 if (!server_data_->GetInteger("port", &port)) { |
| 414 LOG(ERROR) << "Could not find port value"; | 417 LOG(ERROR) << "Could not find port value"; |
| 415 return false; | 418 return false; |
| 416 } | 419 } |
| 417 if ((port <= 0) || (port > kuint16max)) { | 420 if ((port <= 0) || (port > std::numeric_limits<uint16_t>::max())) { |
| 418 LOG(ERROR) << "Invalid port value: " << port; | 421 LOG(ERROR) << "Invalid port value: " << port; |
| 419 return false; | 422 return false; |
| 420 } | 423 } |
| 421 host_port_pair_.set_port(port); | 424 host_port_pair_.set_port(port); |
| 422 | 425 |
| 423 return true; | 426 return true; |
| 424 } | 427 } |
| 425 | 428 |
| 426 bool BaseTestServer::SetupWhenServerStarted() { | 429 bool BaseTestServer::SetupWhenServerStarted() { |
| 427 DCHECK(host_port_pair_.port()); | 430 DCHECK(host_port_pair_.port()); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 581 |
| 579 return GenerateAdditionalArguments(arguments); | 582 return GenerateAdditionalArguments(arguments); |
| 580 } | 583 } |
| 581 | 584 |
| 582 bool BaseTestServer::GenerateAdditionalArguments( | 585 bool BaseTestServer::GenerateAdditionalArguments( |
| 583 base::DictionaryValue* arguments) const { | 586 base::DictionaryValue* arguments) const { |
| 584 return true; | 587 return true; |
| 585 } | 588 } |
| 586 | 589 |
| 587 } // namespace net | 590 } // namespace net |
| OLD | NEW |