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

Side by Side Diff: cloud_print/gcp20/prototype/command_line_reader.cc

Issue 1475803002: Remove kuint16max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint2
Patch Set: cloud print 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
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 "cloud_print/gcp20/prototype/command_line_reader.h" 5 #include "cloud_print/gcp20/prototype/command_line_reader.h"
6 6
7 #include <limits>
8
7 #include "base/command_line.h" 9 #include "base/command_line.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
10 #include "cloud_print/gcp20/prototype/gcp20_switches.h" 12 #include "cloud_print/gcp20/prototype/gcp20_switches.h"
11 13
12 namespace command_line_reader { 14 namespace command_line_reader {
13 15
14 uint16 ReadHttpPort(uint16 default_value) { 16 uint16_t ReadHttpPort(uint16_t default_value) {
15 uint32 http_port = 0; 17 uint32_t http_port = 0;
16 18
17 std::string http_port_string = 19 std::string http_port_string =
18 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 20 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
19 switches::kHttpPort); 21 switches::kHttpPort);
20 22
21 if (!base::StringToUint(http_port_string, &http_port)) 23 if (!base::StringToUint(http_port_string, &http_port))
22 http_port = default_value; 24 http_port = default_value;
23 25
24 if (http_port > kuint16max) { 26 if (http_port > std::numeric_limits<uint16_t>::max()) {
25 LOG(ERROR) << "HTTP Port is too large"; 27 LOG(ERROR) << "HTTP Port is too large";
26 http_port = default_value; 28 http_port = default_value;
27 } 29 }
28 30
29 VLOG(1) << "HTTP port for responses: " << http_port; 31 VLOG(1) << "HTTP port for responses: " << http_port;
30 return static_cast<uint16>(http_port); 32 return static_cast<uint16_t>(http_port);
31 } 33 }
32 34
33 uint32 ReadTtl(uint32 default_value) { 35 uint32_t ReadTtl(uint32_t default_value) {
34 uint32 ttl = 0; 36 uint32_t ttl = 0;
35 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 37 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
36 38
37 if (!base::StringToUint( 39 if (!base::StringToUint(
38 command_line->GetSwitchValueASCII(switches::kTtl), 40 command_line->GetSwitchValueASCII(switches::kTtl),
39 &ttl)) { 41 &ttl)) {
40 ttl = default_value; 42 ttl = default_value;
41 } 43 }
42 44
43 VLOG(1) << "TTL for announcements: " << ttl; 45 VLOG(1) << "TTL for announcements: " << ttl;
44 return ttl; 46 return ttl;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 82 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
81 switches::kStatePath); 83 switches::kStatePath);
82 84
83 if (filename.empty()) 85 if (filename.empty())
84 return default_value; 86 return default_value;
85 return filename; 87 return filename;
86 } 88 }
87 89
88 } // namespace command_line_reader 90 } // namespace command_line_reader
89 91
OLDNEW
« no previous file with comments | « cloud_print/gcp20/prototype/command_line_reader.h ('k') | components/policy/core/browser/url_blacklist_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698