| OLD | NEW |
| 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_manager_delegate.h" | 5 #include "content/shell/browser/shell_devtools_manager_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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::Bind(&CanUserConnectToDevTools), | 59 base::Bind(&CanUserConnectToDevTools), |
| 60 true /* use_abstract_namespace */)); | 60 true /* use_abstract_namespace */)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); | 63 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); |
| 64 }; | 64 }; |
| 65 #else | 65 #else |
| 66 class TCPServerSocketFactory | 66 class TCPServerSocketFactory |
| 67 : public DevToolsHttpHandler::ServerSocketFactory { | 67 : public DevToolsHttpHandler::ServerSocketFactory { |
| 68 public: | 68 public: |
| 69 TCPServerSocketFactory(const std::string& address, int port, int backlog) | 69 TCPServerSocketFactory(const std::string& address, uint16 port, int backlog) |
| 70 : DevToolsHttpHandler::ServerSocketFactory( | 70 : DevToolsHttpHandler::ServerSocketFactory( |
| 71 address, port, backlog) {} | 71 address, port, backlog) {} |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 // DevToolsHttpHandler::ServerSocketFactory. | 74 // DevToolsHttpHandler::ServerSocketFactory. |
| 75 scoped_ptr<net::ServerSocket> Create() const override { | 75 scoped_ptr<net::ServerSocket> Create() const override { |
| 76 return scoped_ptr<net::ServerSocket>( | 76 return scoped_ptr<net::ServerSocket>( |
| 77 new net::TCPServerSocket(NULL, net::NetLog::Source())); | 77 new net::TCPServerSocket(NULL, net::NetLog::Source())); |
| 78 } | 78 } |
| 79 | 79 |
| 80 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); | 80 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); |
| 81 }; | 81 }; |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> | 84 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> |
| 85 CreateSocketFactory() { | 85 CreateSocketFactory() { |
| 86 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 86 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 87 #if defined(OS_ANDROID) | 87 #if defined(OS_ANDROID) |
| 88 std::string socket_name = "content_shell_devtools_remote"; | 88 std::string socket_name = "content_shell_devtools_remote"; |
| 89 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { | 89 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { |
| 90 socket_name = command_line.GetSwitchValueASCII( | 90 socket_name = command_line.GetSwitchValueASCII( |
| 91 switches::kRemoteDebuggingSocketName); | 91 switches::kRemoteDebuggingSocketName); |
| 92 } | 92 } |
| 93 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( | 93 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( |
| 94 new UnixDomainServerSocketFactory(socket_name)); | 94 new UnixDomainServerSocketFactory(socket_name)); |
| 95 #else | 95 #else |
| 96 // See if the user specified a port on the command line (useful for | 96 // See if the user specified a port on the command line (useful for |
| 97 // automation). If not, use an ephemeral port by specifying 0. | 97 // automation). If not, use an ephemeral port by specifying 0. |
| 98 int port = 0; | 98 uint16 port = 0; |
| 99 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | 99 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { |
| 100 int temp_port; | 100 int temp_port; |
| 101 std::string port_str = | 101 std::string port_str = |
| 102 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | 102 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); |
| 103 if (base::StringToInt(port_str, &temp_port) && | 103 if (base::StringToInt(port_str, &temp_port) && |
| 104 temp_port > 0 && temp_port < 65535) { | 104 temp_port > 0 && temp_port < 65535) { |
| 105 port = temp_port; | 105 port = static_cast<uint16>(temp_port); |
| 106 } else { | 106 } else { |
| 107 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; | 107 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( | 110 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( |
| 111 new TCPServerSocketFactory("127.0.0.1", port, 1)); | 111 new TCPServerSocketFactory("127.0.0.1", port, 1)); |
| 112 #endif | 112 #endif |
| 113 } | 113 } |
| 114 | 114 |
| 115 class Target : public DevToolsTarget { | 115 class Target : public DevToolsTarget { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 void ShellDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) { | 272 void ShellDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) { |
| 273 TargetList targets; | 273 TargetList targets; |
| 274 for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) { | 274 for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) { |
| 275 targets.push_back(new Target(agent_host)); | 275 targets.push_back(new Target(agent_host)); |
| 276 } | 276 } |
| 277 callback.Run(targets); | 277 callback.Run(targets); |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace content | 280 } // namespace content |
| OLD | NEW |