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

Side by Side Diff: headless/lib/browser/headless_devtools.cc

Issue 2300703005: DevTools: merge devtools_http_handler into content - it is used in all the embedders anyways. (Closed)
Patch Set: for_landing! Created 4 years, 3 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 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 "components/devtools_http_handler/devtools_http_handler.h" 12 #include "content/public/browser/devtools_agent_host.h"
13 #include "components/devtools_http_handler/devtools_http_handler_delegate.h"
14 #include "content/public/browser/devtools_frontend_host.h" 13 #include "content/public/browser/devtools_frontend_host.h"
15 #include "content/public/browser/devtools_socket_factory.h" 14 #include "content/public/browser/devtools_socket_factory.h"
16 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
17 #include "headless/grit/headless_lib_resources.h" 16 #include "headless/grit/headless_lib_resources.h"
18 #include "headless/public/headless_browser.h" 17 #include "headless/public/headless_browser.h"
19 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
20 #include "net/socket/tcp_server_socket.h" 19 #include "net/socket/tcp_server_socket.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
22 21
23 using devtools_http_handler::DevToolsHttpHandler;
24
25 namespace headless { 22 namespace headless {
26 23
27 namespace { 24 namespace {
28 25
29 const int kBackLog = 10; 26 const int kBackLog = 10;
30 27
31 class TCPServerSocketFactory : public content::DevToolsSocketFactory { 28 class TCPServerSocketFactory : public content::DevToolsSocketFactory {
32 public: 29 public:
33 explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint) 30 explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint)
34 : endpoint_(endpoint) { 31 : endpoint_(endpoint) {
(...skipping 14 matching lines...) Expand all
49 std::unique_ptr<net::ServerSocket> CreateForTethering( 46 std::unique_ptr<net::ServerSocket> CreateForTethering(
50 std::string* out_name) override { 47 std::string* out_name) override {
51 return nullptr; 48 return nullptr;
52 } 49 }
53 50
54 net::IPEndPoint endpoint_; 51 net::IPEndPoint endpoint_;
55 52
56 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); 53 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
57 }; 54 };
58 55
59 class HeadlessDevToolsDelegate
60 : public devtools_http_handler::DevToolsHttpHandlerDelegate {
61 public:
62 HeadlessDevToolsDelegate();
63 ~HeadlessDevToolsDelegate() override;
64
65 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation:
66 std::string GetDiscoveryPageHTML() override;
67 std::string GetFrontendResource(const std::string& path) override;
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(HeadlessDevToolsDelegate);
71 };
72
73 HeadlessDevToolsDelegate::HeadlessDevToolsDelegate() {}
74
75 HeadlessDevToolsDelegate::~HeadlessDevToolsDelegate() {}
76
77 std::string HeadlessDevToolsDelegate::GetDiscoveryPageHTML() {
78 return ResourceBundle::GetSharedInstance().GetRawDataResource(
79 IDR_HEADLESS_LIB_DEVTOOLS_DISCOVERY_PAGE).as_string();
80 }
81
82 std::string HeadlessDevToolsDelegate::GetFrontendResource(
83 const std::string& path) {
84 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
85 }
86
87 } // namespace 56 } // namespace
88 57
89 std::unique_ptr<DevToolsHttpHandler> CreateLocalDevToolsHttpHandler( 58 void StartLocalDevToolsHttpHandler(
90 HeadlessBrowser::Options* options) { 59 HeadlessBrowser::Options* options) {
91 const net::IPEndPoint& endpoint = options->devtools_endpoint; 60 const net::IPEndPoint& endpoint = options->devtools_endpoint;
92 std::unique_ptr<content::DevToolsSocketFactory> socket_factory( 61 std::unique_ptr<content::DevToolsSocketFactory> socket_factory(
93 new TCPServerSocketFactory(endpoint)); 62 new TCPServerSocketFactory(endpoint));
94 return base::MakeUnique<DevToolsHttpHandler>( 63 content::DevToolsAgentHost::StartRemoteDebuggingServer(
95 std::move(socket_factory), std::string(), new HeadlessDevToolsDelegate(), 64 std::move(socket_factory), std::string(),
96 options->user_data_dir, // TODO(altimin): Figure a proper value for this. 65 options->user_data_dir, // TODO(altimin): Figure a proper value for this.
97 base::FilePath(), std::string(), options->user_agent); 66 base::FilePath(), std::string(), options->user_agent);
98 } 67 }
99 68
69 void StopLocalDevToolsHttpHandler() {
70 content::DevToolsAgentHost::StopRemoteDebuggingServer();
71 }
72
100 } // namespace headless 73 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_devtools.h ('k') | headless/lib/browser/headless_devtools_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698