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

Side by Side Diff: content/shell/browser/shell_devtools_delegate.cc

Issue 497223003: Revert of Replace StreamListenSocket with StreamSocket in HttpServer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 "content/shell/browser/shell_devtools_delegate.h" 5 #include "content/shell/browser/shell_devtools_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/public/browser/devtools_agent_host.h" 15 #include "content/public/browser/devtools_agent_host.h"
16 #include "content/public/browser/devtools_http_handler.h" 16 #include "content/public/browser/devtools_http_handler.h"
17 #include "content/public/browser/devtools_target.h" 17 #include "content/public/browser/devtools_target.h"
18 #include "content/public/browser/favicon_status.h" 18 #include "content/public/browser/favicon_status.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_switches.h" 22 #include "content/public/common/content_switches.h"
23 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
24 #include "content/public/common/user_agent.h" 24 #include "content/public/common/user_agent.h"
25 #include "content/shell/browser/shell.h" 25 #include "content/shell/browser/shell.h"
26 #include "grit/shell_resources.h" 26 #include "grit/shell_resources.h"
27 #include "net/socket/tcp_server_socket.h" 27 #include "net/socket/tcp_listen_socket.h"
28 #include "ui/base/resource/resource_bundle.h" 28 #include "ui/base/resource/resource_bundle.h"
29 29
30 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
31 #include "content/public/browser/android/devtools_auth.h" 31 #include "content/public/browser/android/devtools_auth.h"
32 #include "net/socket/unix_domain_server_socket_posix.h" 32 #include "net/socket/unix_domain_listen_socket_posix.h"
33 #endif 33 #endif
34 34
35 using content::DevToolsAgentHost; 35 using content::DevToolsAgentHost;
36 using content::RenderViewHost; 36 using content::RenderViewHost;
37 using content::WebContents; 37 using content::WebContents;
38 38
39 namespace { 39 namespace {
40 40
41 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
42 const char kFrontEndURL[] = 42 const char kFrontEndURL[] =
43 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; 43 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html";
44 #endif 44 #endif
45 const char kTargetTypePage[] = "page"; 45 const char kTargetTypePage[] = "page";
46 46
47 #if defined(OS_ANDROID) 47 net::StreamListenSocketFactory* CreateSocketFactory() {
48 class UnixDomainServerSocketFactory
49 : public content::DevToolsHttpHandler::ServerSocketFactory {
50 public:
51 explicit UnixDomainServerSocketFactory(const std::string& socket_name)
52 : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {}
53
54 private:
55 // content::DevToolsHttpHandler::ServerSocketFactory.
56 virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE {
57 return scoped_ptr<net::ServerSocket>(
58 new net::UnixDomainServerSocket(
59 base::Bind(&content::CanUserConnectToDevTools),
60 true /* use_abstract_namespace */));
61 }
62
63 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory);
64 };
65 #else
66 class TCPServerSocketFactory
67 : public content::DevToolsHttpHandler::ServerSocketFactory {
68 public:
69 TCPServerSocketFactory(const std::string& address, int port, int backlog)
70 : content::DevToolsHttpHandler::ServerSocketFactory(
71 address, port, backlog) {}
72
73 private:
74 // content::DevToolsHttpHandler::ServerSocketFactory.
75 virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE {
76 return scoped_ptr<net::ServerSocket>(
77 new net::TCPServerSocket(NULL, net::NetLog::Source()));
78 }
79
80 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
81 };
82 #endif
83
84 scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>
85 CreateSocketFactory() {
86 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 48 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
87 #if defined(OS_ANDROID) 49 #if defined(OS_ANDROID)
88 std::string socket_name = "content_shell_devtools_remote"; 50 std::string socket_name = "content_shell_devtools_remote";
89 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { 51 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) {
90 socket_name = command_line.GetSwitchValueASCII( 52 socket_name = command_line.GetSwitchValueASCII(
91 switches::kRemoteDebuggingSocketName); 53 switches::kRemoteDebuggingSocketName);
92 } 54 }
93 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( 55 return new net::deprecated::
94 new UnixDomainServerSocketFactory(socket_name)); 56 UnixDomainListenSocketWithAbstractNamespaceFactory(
57 socket_name, "", base::Bind(&content::CanUserConnectToDevTools));
95 #else 58 #else
96 // See if the user specified a port on the command line (useful for 59 // See if the user specified a port on the command line (useful for
97 // automation). If not, use an ephemeral port by specifying 0. 60 // automation). If not, use an ephemeral port by specifying 0.
98 int port = 0; 61 int port = 0;
99 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { 62 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
100 int temp_port; 63 int temp_port;
101 std::string port_str = 64 std::string port_str =
102 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); 65 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
103 if (base::StringToInt(port_str, &temp_port) && 66 if (base::StringToInt(port_str, &temp_port) &&
104 temp_port > 0 && temp_port < 65535) { 67 temp_port > 0 && temp_port < 65535) {
105 port = temp_port; 68 port = temp_port;
106 } else { 69 } else {
107 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; 70 DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
108 } 71 }
109 } 72 }
110 return scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory>( 73 return new net::TCPListenSocketFactory("127.0.0.1", port);
111 new TCPServerSocketFactory("127.0.0.1", port, 1));
112 #endif 74 #endif
113 } 75 }
114 76
115 class Target : public content::DevToolsTarget { 77 class Target : public content::DevToolsTarget {
116 public: 78 public:
117 explicit Target(WebContents* web_contents); 79 explicit Target(WebContents* web_contents);
118 80
119 virtual std::string GetId() const OVERRIDE { return id_; } 81 virtual std::string GetId() const OVERRIDE { return id_; }
120 virtual std::string GetParentId() const OVERRIDE { return std::string(); } 82 virtual std::string GetParentId() const OVERRIDE { return std::string(); }
121 virtual std::string GetType() const OVERRIDE { return kTargetTypePage; } 83 virtual std::string GetType() const OVERRIDE { return kTargetTypePage; }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 205 }
244 206
245 scoped_ptr<net::StreamListenSocket> 207 scoped_ptr<net::StreamListenSocket>
246 ShellDevToolsDelegate::CreateSocketForTethering( 208 ShellDevToolsDelegate::CreateSocketForTethering(
247 net::StreamListenSocket::Delegate* delegate, 209 net::StreamListenSocket::Delegate* delegate,
248 std::string* name) { 210 std::string* name) {
249 return scoped_ptr<net::StreamListenSocket>(); 211 return scoped_ptr<net::StreamListenSocket>();
250 } 212 }
251 213
252 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/devtools_http_handler.h ('k') | extensions/browser/api/socket/tcp_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698