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

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

Issue 2181413002: [headless] Remove default browser context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes according to Sami's comments Created 4 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 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>
8 #include <utility>
9
7 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
8 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
9 #include "components/devtools_http_handler/devtools_http_handler.h" 12 #include "components/devtools_http_handler/devtools_http_handler.h"
10 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" 13 #include "components/devtools_http_handler/devtools_http_handler_delegate.h"
11 #include "content/public/browser/devtools_frontend_host.h" 14 #include "content/public/browser/devtools_frontend_host.h"
12 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
13 #include "headless/grit/headless_lib_resources.h" 16 #include "headless/grit/headless_lib_resources.h"
14 #include "headless/lib/browser/headless_browser_context_impl.h" 17 #include "headless/public/headless_browser.h"
15 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
16 #include "net/socket/tcp_server_socket.h" 19 #include "net/socket/tcp_server_socket.h"
17 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
18 21
19 using devtools_http_handler::DevToolsHttpHandler; 22 using devtools_http_handler::DevToolsHttpHandler;
20 23
21 namespace headless { 24 namespace headless {
22 25
23 namespace { 26 namespace {
24 27
25 const int kBackLog = 10; 28 const int kBackLog = 10;
26 29
27 class TCPServerSocketFactory : public DevToolsHttpHandler::ServerSocketFactory { 30 class TCPServerSocketFactory : public DevToolsHttpHandler::ServerSocketFactory {
28 public: 31 public:
29 TCPServerSocketFactory(const net::IPEndPoint& endpoint) 32 explicit TCPServerSocketFactory(const net::IPEndPoint& endpoint)
30 : endpoint_(endpoint) { 33 : endpoint_(endpoint) {
31 DCHECK(endpoint_.address().IsValid()); 34 DCHECK(endpoint_.address().IsValid());
32 } 35 }
33 36
34 private: 37 private:
35 // DevToolsHttpHandler::ServerSocketFactory implementation: 38 // DevToolsHttpHandler::ServerSocketFactory implementation:
36 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { 39 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
37 std::unique_ptr<net::ServerSocket> socket( 40 std::unique_ptr<net::ServerSocket> socket(
38 new net::TCPServerSocket(nullptr, net::NetLog::Source())); 41 new net::TCPServerSocket(nullptr, net::NetLog::Source()));
39 if (socket->Listen(endpoint_, kBackLog) != net::OK) 42 if (socket->Listen(endpoint_, kBackLog) != net::OK)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 86 }
84 87
85 content::DevToolsExternalAgentProxyDelegate* 88 content::DevToolsExternalAgentProxyDelegate*
86 HeadlessDevToolsDelegate::HandleWebSocketConnection(const std::string& path) { 89 HeadlessDevToolsDelegate::HandleWebSocketConnection(const std::string& path) {
87 return nullptr; 90 return nullptr;
88 } 91 }
89 92
90 } // namespace 93 } // namespace
91 94
92 std::unique_ptr<DevToolsHttpHandler> CreateLocalDevToolsHttpHandler( 95 std::unique_ptr<DevToolsHttpHandler> CreateLocalDevToolsHttpHandler(
93 HeadlessBrowserContextImpl* browser_context) { 96 HeadlessBrowser::Options* options) {
94 const net::IPEndPoint& endpoint = 97 const net::IPEndPoint& endpoint = options->devtools_endpoint;
95 browser_context->options()->devtools_endpoint;
96 std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory> socket_factory( 98 std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory> socket_factory(
97 new TCPServerSocketFactory(endpoint)); 99 new TCPServerSocketFactory(endpoint));
98 return base::WrapUnique(new DevToolsHttpHandler( 100 return base::WrapUnique(new DevToolsHttpHandler(
99 std::move(socket_factory), std::string(), new HeadlessDevToolsDelegate(), 101 std::move(socket_factory), std::string(), new HeadlessDevToolsDelegate(),
100 browser_context->GetPath(), base::FilePath(), std::string(), 102 options->user_data_dir, // TODO(altimin): Figure a proper value for this.
101 browser_context->options()->user_agent)); 103 base::FilePath(), std::string(), options->user_agent));
102 } 104 }
103 105
104 } // namespace headless 106 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698