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_browser_main_parts.h" | 5 #include "headless/lib/browser/headless_browser_main_parts.h" |
6 | 6 |
| 7 #include "base/command_line.h" |
| 8 #include "content/public/common/content_switches.h" |
7 #include "headless/lib/browser/headless_browser_context_impl.h" | 9 #include "headless/lib/browser/headless_browser_context_impl.h" |
8 #include "headless/lib/browser/headless_browser_impl.h" | 10 #include "headless/lib/browser/headless_browser_impl.h" |
9 #include "headless/lib/browser/headless_devtools.h" | 11 #include "headless/lib/browser/headless_devtools.h" |
| 12 #include "headless/lib/browser/headless_net_log.h" |
10 #include "headless/lib/browser/headless_screen.h" | 13 #include "headless/lib/browser/headless_screen.h" |
11 | 14 |
12 namespace headless { | 15 namespace headless { |
13 | 16 |
14 HeadlessBrowserMainParts::HeadlessBrowserMainParts(HeadlessBrowserImpl* browser) | 17 HeadlessBrowserMainParts::HeadlessBrowserMainParts(HeadlessBrowserImpl* browser) |
15 : browser_(browser) | 18 : browser_(browser) |
16 , devtools_http_handler_started_(false) {} | 19 , devtools_http_handler_started_(false) {} |
17 | 20 |
18 HeadlessBrowserMainParts::~HeadlessBrowserMainParts() {} | 21 HeadlessBrowserMainParts::~HeadlessBrowserMainParts() {} |
19 | 22 |
20 void HeadlessBrowserMainParts::PreMainMessageLoopRun() { | 23 void HeadlessBrowserMainParts::PreMainMessageLoopRun() { |
| 24 const base::CommandLine* command_line = |
| 25 base::CommandLine::ForCurrentProcess(); |
| 26 if (command_line->HasSwitch(switches::kLogNetLog)) { |
| 27 base::FilePath log_path = |
| 28 command_line->GetSwitchValuePath(switches::kLogNetLog); |
| 29 net_log_.reset(new HeadlessNetLog(log_path)); |
| 30 } |
| 31 |
21 if (browser_->options()->devtools_endpoint.address().IsValid()) { | 32 if (browser_->options()->devtools_endpoint.address().IsValid()) { |
22 StartLocalDevToolsHttpHandler(browser_->options()); | 33 StartLocalDevToolsHttpHandler(browser_->options()); |
23 devtools_http_handler_started_ = true; | 34 devtools_http_handler_started_ = true; |
24 } | 35 } |
25 browser_->PlatformInitialize(); | 36 browser_->PlatformInitialize(); |
26 } | 37 } |
27 | 38 |
28 void HeadlessBrowserMainParts::PostMainMessageLoopRun() { | 39 void HeadlessBrowserMainParts::PostMainMessageLoopRun() { |
29 if (devtools_http_handler_started_) { | 40 if (devtools_http_handler_started_) { |
30 StopLocalDevToolsHttpHandler(); | 41 StopLocalDevToolsHttpHandler(); |
31 devtools_http_handler_started_ = false; | 42 devtools_http_handler_started_ = false; |
32 } | 43 } |
33 } | 44 } |
34 | 45 |
35 } // namespace headless | 46 } // namespace headless |
OLD | NEW |