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

Unified Diff: chrome/test/chromedriver/server/chromedriver_server.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/net/websocket.cc ('k') | chromecast/browser/devtools/remote_debugging_server.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/server/chromedriver_server.cc
diff --git a/chrome/test/chromedriver/server/chromedriver_server.cc b/chrome/test/chromedriver/server/chromedriver_server.cc
index d7f09d222e0e18cb1a540a1113a1d1d16ade36f6..26f105d6e98096555e6c456c8266cf014b13db95 100644
--- a/chrome/test/chromedriver/server/chromedriver_server.cc
+++ b/chrome/test/chromedriver/server/chromedriver_server.cc
@@ -52,7 +52,7 @@ class HttpServer : public net::HttpServer::Delegate {
virtual ~HttpServer() {}
- bool Start(int port, bool allow_remote) {
+ bool Start(uint16 port, bool allow_remote) {
std::string binding_ip = kLocalHostAddress;
if (allow_remote)
binding_ip = "0.0.0.0";
@@ -154,7 +154,7 @@ void StopServerOnIOThread() {
delete server;
}
-void StartServerOnIOThread(int port,
+void StartServerOnIOThread(uint16 port,
bool allow_remote,
const HttpRequestHandlerFunc& handle_request_func) {
scoped_ptr<HttpServer> temp_server(new HttpServer(handle_request_func));
@@ -165,7 +165,7 @@ void StartServerOnIOThread(int port,
lazy_tls_server.Pointer()->Set(temp_server.release());
}
-void RunServer(int port,
+void RunServer(uint16 port,
bool allow_remote,
const std::vector<std::string>& whitelisted_ips,
const std::string& url_base,
@@ -219,7 +219,7 @@ int main(int argc, char *argv[]) {
#endif
// Parse command line flags.
- int port = 9515;
+ uint16 port = 9515;
int adb_port = 5037;
bool allow_remote = false;
std::vector<std::string> whitelisted_ips;
@@ -253,10 +253,14 @@ int main(int argc, char *argv[]) {
return 0;
}
if (cmd_line->HasSwitch("port")) {
- if (!base::StringToInt(cmd_line->GetSwitchValueASCII("port"), &port)) {
+ int cmd_line_port;
+ if (!base::StringToInt(cmd_line->GetSwitchValueASCII("port"),
+ &cmd_line_port) ||
+ cmd_line_port < 0 || cmd_line_port > 65535) {
printf("Invalid port. Exiting...\n");
return 1;
}
+ port = static_cast<uint16>(cmd_line_port);
}
if (cmd_line->HasSwitch("adb-port")) {
if (!base::StringToInt(cmd_line->GetSwitchValueASCII("adb-port"),
@@ -293,7 +297,7 @@ int main(int argc, char *argv[]) {
base::SplitString(whitelist, ',', &whitelisted_ips);
}
if (!cmd_line->HasSwitch("silent")) {
- printf("Starting ChromeDriver %s on port %d\n", kChromeDriverVersion, port);
+ printf("Starting ChromeDriver %s on port %u\n", kChromeDriverVersion, port);
if (!allow_remote) {
printf("Only local connections are allowed.\n");
} else if (!whitelisted_ips.empty()) {
« no previous file with comments | « chrome/test/chromedriver/net/websocket.cc ('k') | chromecast/browser/devtools/remote_debugging_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698