Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: net/test/spawned_test_server/base_test_server.cc

Issue 1485853003: Revert of Remove kuint16max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint2
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/dns_transaction_unittest.cc ('k') | net/test/spawned_test_server/remote_test_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
10 #include <string> 7 #include <string>
11 #include <vector> 8 #include <vector>
12 9
13 #include "base/base64.h" 10 #include "base/base64.h"
14 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
15 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
16 #include "base/logging.h" 13 #include "base/logging.h"
17 #include "base/path_service.h" 14 #include "base/path_service.h"
18 #include "base/values.h" 15 #include "base/values.h"
19 #include "net/base/address_list.h" 16 #include "net/base/address_list.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 BoundNetLog()); 278 BoundNetLog());
282 if (rv == ERR_IO_PENDING) 279 if (rv == ERR_IO_PENDING)
283 rv = callback.WaitForResult(); 280 rv = callback.WaitForResult();
284 if (rv != OK) { 281 if (rv != OK) {
285 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host(); 282 LOG(ERROR) << "Failed to resolve hostname: " << host_port_pair_.host();
286 return false; 283 return false;
287 } 284 }
288 return true; 285 return true;
289 } 286 }
290 287
291 uint16_t BaseTestServer::GetPort() { 288 uint16 BaseTestServer::GetPort() {
292 return host_port_pair_.port(); 289 return host_port_pair_.port();
293 } 290 }
294 291
295 void BaseTestServer::SetPort(uint16_t port) { 292 void BaseTestServer::SetPort(uint16 port) {
296 host_port_pair_.set_port(port); 293 host_port_pair_.set_port(port);
297 } 294 }
298 295
299 GURL BaseTestServer::GetURL(const std::string& path) const { 296 GURL BaseTestServer::GetURL(const std::string& path) const {
300 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path); 297 return GURL(GetScheme() + "://" + host_port_pair_.ToString() + "/" + path);
301 } 298 }
302 299
303 GURL BaseTestServer::GetURLWithUser(const std::string& path, 300 GURL BaseTestServer::GetURLWithUser(const std::string& path,
304 const std::string& user) const { 301 const std::string& user) const {
305 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() + 302 return GURL(GetScheme() + "://" + user + "@" + host_port_pair_.ToString() +
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 << json_reader.GetErrorMessage(); 407 << json_reader.GetErrorMessage();
411 return false; 408 return false;
412 } 409 }
413 410
414 server_data_.reset(static_cast<base::DictionaryValue*>(value.release())); 411 server_data_.reset(static_cast<base::DictionaryValue*>(value.release()));
415 int port = 0; 412 int port = 0;
416 if (!server_data_->GetInteger("port", &port)) { 413 if (!server_data_->GetInteger("port", &port)) {
417 LOG(ERROR) << "Could not find port value"; 414 LOG(ERROR) << "Could not find port value";
418 return false; 415 return false;
419 } 416 }
420 if ((port <= 0) || (port > std::numeric_limits<uint16_t>::max())) { 417 if ((port <= 0) || (port > kuint16max)) {
421 LOG(ERROR) << "Invalid port value: " << port; 418 LOG(ERROR) << "Invalid port value: " << port;
422 return false; 419 return false;
423 } 420 }
424 host_port_pair_.set_port(port); 421 host_port_pair_.set_port(port);
425 422
426 return true; 423 return true;
427 } 424 }
428 425
429 bool BaseTestServer::SetupWhenServerStarted() { 426 bool BaseTestServer::SetupWhenServerStarted() {
430 DCHECK(host_port_pair_.port()); 427 DCHECK(host_port_pair_.port());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 578
582 return GenerateAdditionalArguments(arguments); 579 return GenerateAdditionalArguments(arguments);
583 } 580 }
584 581
585 bool BaseTestServer::GenerateAdditionalArguments( 582 bool BaseTestServer::GenerateAdditionalArguments(
586 base::DictionaryValue* arguments) const { 583 base::DictionaryValue* arguments) const {
587 return true; 584 return true;
588 } 585 }
589 586
590 } // namespace net 587 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_transaction_unittest.cc ('k') | net/test/spawned_test_server/remote_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698