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

Side by Side Diff: chrome/test/chromedriver/server/chromedriver_server.cc

Issue 1879863002: Reland of [chromedriver] Listen on IPv6 on IPv6-only hosts (part 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better logging Created 4 years, 8 months 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 | « chrome/test/chromedriver/net/websocket.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <locale> 9 #include <locale>
10 #include <memory> 10 #include <memory>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 explicit HttpServer(const HttpRequestHandlerFunc& handle_request_func) 70 explicit HttpServer(const HttpRequestHandlerFunc& handle_request_func)
71 : handle_request_func_(handle_request_func), 71 : handle_request_func_(handle_request_func),
72 weak_factory_(this) {} 72 weak_factory_(this) {}
73 73
74 ~HttpServer() override {} 74 ~HttpServer() override {}
75 75
76 bool Start(uint16_t port, bool allow_remote) { 76 bool Start(uint16_t port, bool allow_remote) {
77 std::unique_ptr<net::ServerSocket> server_socket( 77 std::unique_ptr<net::ServerSocket> server_socket(
78 new net::TCPServerSocket(NULL, net::NetLog::Source())); 78 new net::TCPServerSocket(NULL, net::NetLog::Source()));
79 if (ListenOnIPv4(server_socket.get(), port, allow_remote) != net::OK) { 79 if (ListenOnIPv4(server_socket.get(), port, allow_remote) != net::OK) {
80 // If we fail to listen on IPv4, try using an IPv6 address. This will work 80 // This will work on an IPv6-only host, but we will be IPv4-only on
81 // on an IPv6-only host, but we will be IPv4-only on dual-stack hosts. 81 // dual-stack hosts.
82 // TODO(samuong): change this to listen on both IPv4 and IPv6. 82 // TODO(samuong): change this to listen on both IPv4 and IPv6.
83 if (ListenOnIPv6(server_socket.get(), port, allow_remote) != net::OK) 83 VLOG(0) << "listen on IPv4 failed, trying IPv6";
84 if (ListenOnIPv6(server_socket.get(), port, allow_remote) != net::OK) {
85 VLOG(1) << "listen on both IPv4 and IPv6 failed, giving up";
84 return false; 86 return false;
87 }
85 } 88 }
86 server_.reset(new net::HttpServer(std::move(server_socket), this)); 89 server_.reset(new net::HttpServer(std::move(server_socket), this));
87 net::IPEndPoint address; 90 net::IPEndPoint address;
88 return server_->GetLocalAddress(&address) == net::OK; 91 return server_->GetLocalAddress(&address) == net::OK;
89 } 92 }
90 93
91 // Overridden from net::HttpServer::Delegate: 94 // Overridden from net::HttpServer::Delegate:
92 void OnConnect(int connection_id) override { 95 void OnConnect(int connection_id) override {
93 server_->SetSendBufferSize(connection_id, kBufferSize); 96 server_->SetSendBufferSize(connection_id, kBufferSize);
94 server_->SetReceiveBufferSize(connection_id, kBufferSize); 97 server_->SetReceiveBufferSize(connection_id, kBufferSize);
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 330 }
328 331
329 if (!InitLogging()) { 332 if (!InitLogging()) {
330 printf("Unable to initialize logging. Exiting...\n"); 333 printf("Unable to initialize logging. Exiting...\n");
331 return 1; 334 return 1;
332 } 335 }
333 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port, 336 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port,
334 std::move(port_server)); 337 std::move(port_server));
335 return 0; 338 return 0;
336 } 339 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/net/websocket.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698