OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "headless/lib/browser/headless_devtools.h" | 5 #include "headless/lib/browser/headless_devtools.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "content/public/browser/devtools_agent_host.h" | 12 #include "content/public/browser/devtools_agent_host.h" |
13 #include "content/public/browser/devtools_frontend_host.h" | 13 #include "content/public/browser/devtools_frontend_host.h" |
14 #include "content/public/browser/devtools_socket_factory.h" | 14 #include "content/public/browser/devtools_socket_factory.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "headless/grit/headless_lib_resources.h" | 16 #include "headless/grit/headless_lib_resources.h" |
17 #include "headless/public/headless_browser.h" | 17 #include "headless/public/headless_browser.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/log/net_log_source.h" |
19 #include "net/socket/tcp_server_socket.h" | 20 #include "net/socket/tcp_server_socket.h" |
20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
21 | 22 |
22 namespace headless { | 23 namespace headless { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 const int kBackLog = 10; | 27 const int kBackLog = 10; |
27 | 28 |
28 class TCPServerSocketFactory : public content::DevToolsSocketFactory { | 29 class TCPServerSocketFactory : public content::DevToolsSocketFactory { |
29 public: | 30 public: |
30 explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint) | 31 explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint) |
31 : endpoint_(endpoint) { | 32 : endpoint_(endpoint) { |
32 DCHECK(endpoint_.address().IsValid()); | 33 DCHECK(endpoint_.address().IsValid()); |
33 } | 34 } |
34 | 35 |
35 private: | 36 private: |
36 // content::DevToolsSocketFactory implementation: | 37 // content::DevToolsSocketFactory implementation: |
37 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { | 38 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { |
38 std::unique_ptr<net::ServerSocket> socket( | 39 std::unique_ptr<net::ServerSocket> socket( |
39 new net::TCPServerSocket(nullptr, net::NetLog::Source())); | 40 new net::TCPServerSocket(nullptr, net::NetLogSource())); |
40 if (socket->Listen(endpoint_, kBackLog) != net::OK) | 41 if (socket->Listen(endpoint_, kBackLog) != net::OK) |
41 return std::unique_ptr<net::ServerSocket>(); | 42 return std::unique_ptr<net::ServerSocket>(); |
42 | 43 |
43 return socket; | 44 return socket; |
44 } | 45 } |
45 | 46 |
46 std::unique_ptr<net::ServerSocket> CreateForTethering( | 47 std::unique_ptr<net::ServerSocket> CreateForTethering( |
47 std::string* out_name) override { | 48 std::string* out_name) override { |
48 return nullptr; | 49 return nullptr; |
49 } | 50 } |
(...skipping 14 matching lines...) Expand all Loading... |
64 std::move(socket_factory), std::string(), | 65 std::move(socket_factory), std::string(), |
65 options->user_data_dir, // TODO(altimin): Figure a proper value for this. | 66 options->user_data_dir, // TODO(altimin): Figure a proper value for this. |
66 base::FilePath(), std::string(), options->user_agent); | 67 base::FilePath(), std::string(), options->user_agent); |
67 } | 68 } |
68 | 69 |
69 void StopLocalDevToolsHttpHandler() { | 70 void StopLocalDevToolsHttpHandler() { |
70 content::DevToolsAgentHost::StopRemoteDebuggingServer(); | 71 content::DevToolsAgentHost::StopRemoteDebuggingServer(); |
71 } | 72 } |
72 | 73 |
73 } // namespace headless | 74 } // namespace headless |
OLD | NEW |