Commit e26258c0 authored by Sean Topping's avatar Sean Topping Committed by Commit Bot

[Chromecast] Support IPv6 for Devtools server

Bug: internal b/114464714
Test: CQ, verify Devtools is accessible on IPv4 and IPv6
Change-Id: I716643bb4c51cedaa0375ab51a9809246ecb64ab
Reviewed-on: https://chromium-review.googlesource.com/c/1309101
Commit-Queue: Sean Topping <seantopping@chromium.org>
Reviewed-by: default avatarSergey Volk <servolk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604991}
parent 67f2fded
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/log/net_log_source.h" #include "net/log/net_log_source.h"
#include "net/socket/tcp_server_socket.h" #include "net/socket/tcp_server_socket.h"
...@@ -75,15 +77,16 @@ class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory { ...@@ -75,15 +77,16 @@ class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory {
#else #else
class TCPServerSocketFactory : public content::DevToolsSocketFactory { class TCPServerSocketFactory : public content::DevToolsSocketFactory {
public: public:
TCPServerSocketFactory(const std::string& address, uint16_t port) explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint)
: address_(address), port_(port) {} : endpoint_(endpoint) {}
private: private:
// content::DevToolsSocketFactory. // content::DevToolsSocketFactory.
std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
std::unique_ptr<net::ServerSocket> socket( std::unique_ptr<net::ServerSocket> socket(
new net::TCPServerSocket(nullptr, net::NetLogSource())); new net::TCPServerSocket(nullptr, net::NetLogSource()));
if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK)
if (socket->Listen(endpoint_, kBackLog) != net::OK)
return std::unique_ptr<net::ServerSocket>(); return std::unique_ptr<net::ServerSocket>();
return socket; return socket;
...@@ -94,8 +97,7 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory { ...@@ -94,8 +97,7 @@ class TCPServerSocketFactory : public content::DevToolsSocketFactory {
return nullptr; return nullptr;
} }
std::string address_; const net::IPEndPoint endpoint_;
uint16_t port_;
DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
}; };
...@@ -113,8 +115,9 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory( ...@@ -113,8 +115,9 @@ std::unique_ptr<content::DevToolsSocketFactory> CreateSocketFactory(
return std::unique_ptr<content::DevToolsSocketFactory>( return std::unique_ptr<content::DevToolsSocketFactory>(
new UnixDomainServerSocketFactory(socket_name)); new UnixDomainServerSocketFactory(socket_name));
#else #else
net::IPEndPoint endpoint(net::IPAddress::IPv6AllZeros(), port);
return std::unique_ptr<content::DevToolsSocketFactory>( return std::unique_ptr<content::DevToolsSocketFactory>(
new TCPServerSocketFactory("0.0.0.0", port)); new TCPServerSocketFactory(endpoint));
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment