| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/browser/devtools/remote_debugging_server.h" | 5 #include "chromecast/browser/devtools/remote_debugging_server.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.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 "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chromecast/base/pref_names.h" | 15 #include "chromecast/base/pref_names.h" |
| 16 #include "chromecast/browser/cast_browser_process.h" | 16 #include "chromecast/browser/cast_browser_process.h" |
| 17 #include "chromecast/browser/devtools/cast_devtools_delegate.h" | 17 #include "chromecast/browser/devtools/cast_devtools_delegate.h" |
| 18 #include "chromecast/common/cast_content_client.h" | 18 #include "chromecast/common/cast_content_client.h" |
| 19 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/devtools_agent_host.h" | 21 #include "content/public/browser/devtools_agent_host.h" |
| 22 #include "content/public/browser/devtools_socket_factory.h" | 22 #include "content/public/browser/devtools_socket_factory.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/user_agent.h" | 24 #include "content/public/common/user_agent.h" |
| 25 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
| 26 #include "net/log/net_log_source.h" |
| 26 #include "net/socket/tcp_server_socket.h" | 27 #include "net/socket/tcp_server_socket.h" |
| 27 | 28 |
| 28 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 29 #include "content/public/browser/android/devtools_auth.h" | 30 #include "content/public/browser/android/devtools_auth.h" |
| 30 #include "net/socket/unix_domain_server_socket_posix.h" | 31 #include "net/socket/unix_domain_server_socket_posix.h" |
| 31 #endif // defined(OS_ANDROID) | 32 #endif // defined(OS_ANDROID) |
| 32 | 33 |
| 33 namespace chromecast { | 34 namespace chromecast { |
| 34 namespace shell { | 35 namespace shell { |
| 35 | 36 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #else | 73 #else |
| 73 class TCPServerSocketFactory : public content::DevToolsSocketFactory { | 74 class TCPServerSocketFactory : public content::DevToolsSocketFactory { |
| 74 public: | 75 public: |
| 75 TCPServerSocketFactory(const std::string& address, uint16_t port) | 76 TCPServerSocketFactory(const std::string& address, uint16_t port) |
| 76 : address_(address), port_(port) {} | 77 : address_(address), port_(port) {} |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 // content::DevToolsSocketFactory. | 80 // content::DevToolsSocketFactory. |
| 80 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { | 81 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { |
| 81 std::unique_ptr<net::ServerSocket> socket( | 82 std::unique_ptr<net::ServerSocket> socket( |
| 82 new net::TCPServerSocket(nullptr, net::NetLog::Source())); | 83 new net::TCPServerSocket(nullptr, net::NetLogSource())); |
| 83 if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK) | 84 if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK) |
| 84 return std::unique_ptr<net::ServerSocket>(); | 85 return std::unique_ptr<net::ServerSocket>(); |
| 85 | 86 |
| 86 return socket; | 87 return socket; |
| 87 } | 88 } |
| 88 | 89 |
| 89 std::unique_ptr<net::ServerSocket> CreateForTethering( | 90 std::unique_ptr<net::ServerSocket> CreateForTethering( |
| 90 std::string* name) override { | 91 std::string* name) override { |
| 91 return nullptr; | 92 return nullptr; |
| 92 } | 93 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 LOG(INFO) << "Devtools started: port=" << port_; | 167 LOG(INFO) << "Devtools started: port=" << port_; |
| 167 } else if (!enabled && is_started_) { | 168 } else if (!enabled && is_started_) { |
| 168 LOG(INFO) << "Stop devtools: port=" << port_; | 169 LOG(INFO) << "Stop devtools: port=" << port_; |
| 169 is_started_ = false; | 170 is_started_ = false; |
| 170 content::DevToolsAgentHost::StopRemoteDebuggingServer(); | 171 content::DevToolsAgentHost::StopRemoteDebuggingServer(); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 } // namespace shell | 175 } // namespace shell |
| 175 } // namespace chromecast | 176 } // namespace chromecast |
| OLD | NEW |