| 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" | |
| 9 #include "headless/lib/browser/headless_browser_context_impl.h" | 7 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 10 #include "headless/lib/browser/headless_browser_impl.h" | 8 #include "headless/lib/browser/headless_browser_impl.h" |
| 11 #include "headless/lib/browser/headless_devtools.h" | 9 #include "headless/lib/browser/headless_devtools.h" |
| 12 #include "headless/lib/browser/headless_net_log.h" | |
| 13 #include "headless/lib/browser/headless_screen.h" | 10 #include "headless/lib/browser/headless_screen.h" |
| 14 | 11 |
| 15 namespace headless { | 12 namespace headless { |
| 16 | 13 |
| 17 HeadlessBrowserMainParts::HeadlessBrowserMainParts(HeadlessBrowserImpl* browser) | 14 HeadlessBrowserMainParts::HeadlessBrowserMainParts(HeadlessBrowserImpl* browser) |
| 18 : browser_(browser) | 15 : browser_(browser) |
| 19 , devtools_http_handler_started_(false) {} | 16 , devtools_http_handler_started_(false) {} |
| 20 | 17 |
| 21 HeadlessBrowserMainParts::~HeadlessBrowserMainParts() {} | 18 HeadlessBrowserMainParts::~HeadlessBrowserMainParts() {} |
| 22 | 19 |
| 23 void HeadlessBrowserMainParts::PreMainMessageLoopRun() { | 20 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 | |
| 32 if (browser_->options()->devtools_endpoint.address().IsValid()) { | 21 if (browser_->options()->devtools_endpoint.address().IsValid()) { |
| 33 StartLocalDevToolsHttpHandler(browser_->options()); | 22 StartLocalDevToolsHttpHandler(browser_->options()); |
| 34 devtools_http_handler_started_ = true; | 23 devtools_http_handler_started_ = true; |
| 35 } | 24 } |
| 36 browser_->PlatformInitialize(); | 25 browser_->PlatformInitialize(); |
| 37 } | 26 } |
| 38 | 27 |
| 39 void HeadlessBrowserMainParts::PostMainMessageLoopRun() { | 28 void HeadlessBrowserMainParts::PostMainMessageLoopRun() { |
| 40 if (devtools_http_handler_started_) { | 29 if (devtools_http_handler_started_) { |
| 41 StopLocalDevToolsHttpHandler(); | 30 StopLocalDevToolsHttpHandler(); |
| 42 devtools_http_handler_started_ = false; | 31 devtools_http_handler_started_ = false; |
| 43 } | 32 } |
| 44 } | 33 } |
| 45 | 34 |
| 46 } // namespace headless | 35 } // namespace headless |
| OLD | NEW |