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

Unified Diff: content/shell/browser/shell_devtools_delegate.cc

Issue 296053012: Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unittest errors. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/shell_devtools_delegate.cc
diff --git a/content/shell/browser/shell_devtools_delegate.cc b/content/shell/browser/shell_devtools_delegate.cc
index 0f4214f1d42367d51e1edefa89f2d1dd82234b57..fa82b2b5722f90986c26773b29710c818a21b01b 100644
--- a/content/shell/browser/shell_devtools_delegate.cc
+++ b/content/shell/browser/shell_devtools_delegate.cc
@@ -24,12 +24,12 @@
#include "content/public/common/user_agent.h"
#include "content/shell/browser/shell.h"
#include "grit/shell_resources.h"
-#include "net/socket/tcp_listen_socket.h"
+#include "net/socket/tcp_server_socket.h"
#include "ui/base/resource/resource_bundle.h"
#if defined(OS_ANDROID)
#include "content/public/browser/android/devtools_auth.h"
-#include "net/socket/unix_domain_listen_socket_posix.h"
+#include "net/socket/unix_domain_server_socket_posix.h"
#endif
using content::DevToolsAgentHost;
@@ -44,7 +44,45 @@ const char kFrontEndURL[] =
#endif
const char kTargetTypePage[] = "page";
-net::StreamListenSocketFactory* CreateSocketFactory() {
+#if defined(OS_ANDROID)
+class UnixDomainServerSocketFactory
+ : public content::DevToolsHttpHandler::ServerSocketFactory {
+ public:
+ explicit UnixDomainServerSocketFactory(const std::string& socket_name)
+ : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {}
+
+ private:
+ // content::DevToolsHttpHandler::ServerSocketFactory.
+ virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE {
+ return scoped_ptr<net::ServerSocket>(
+ new net::UnixDomainServerSocket(
+ base::Bind(&content::CanUserConnectToDevTools),
+ true));
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory);
+};
+#else
+class TCPServerSocketFactory
+ : public content::DevToolsHttpHandler::ServerSocketFactory {
+ public:
+ TCPServerSocketFactory(const std::string& address, int port, int backlog)
+ : content::DevToolsHttpHandler::ServerSocketFactory(
+ address, port, backlog) {}
+
+ private:
+ // content::DevToolsHttpHandler::ServerSocketFactory.
+ virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE {
+ return scoped_ptr<net::ServerSocket>(
+ new net::TCPServerSocket(NULL, net::NetLog::Source()));
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
+};
+#endif
+
+scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
+CreateSocketFactory() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
#if defined(OS_ANDROID)
std::string socket_name = "content_shell_devtools_remote";
@@ -52,9 +90,8 @@ net::StreamListenSocketFactory* CreateSocketFactory() {
socket_name = command_line.GetSwitchValueASCII(
switches::kRemoteDebuggingSocketName);
}
- return new net::deprecated::
- UnixDomainListenSocketWithAbstractNamespaceFactory(
- socket_name, "", base::Bind(&content::CanUserConnectToDevTools));
+ return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>(
+ new UnixDomainServerSocketFactory(socket_name));
#else
// See if the user specified a port on the command line (useful for
// automation). If not, use an ephemeral port by specifying 0.
@@ -70,7 +107,8 @@ net::StreamListenSocketFactory* CreateSocketFactory() {
DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
}
}
- return new net::TCPListenSocketFactory("127.0.0.1", port);
+ return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>(
+ new TCPServerSocketFactory("127.0.0.1", port, 1));
#endif
}

Powered by Google App Engine
This is Rietveld 408576698