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/headless_content_main_delegate.h" | 5 #include "headless/lib/headless_content_main_delegate.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | |
9 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
10 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
15 #include "components/crash/content/app/breakpad_linux.h" | 16 #include "components/crash/content/app/breakpad_linux.h" |
16 #include "content/public/browser/browser_main_runner.h" | 17 #include "content/public/browser/browser_main_runner.h" |
17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
18 #include "headless/lib/browser/headless_browser_impl.h" | 19 #include "headless/lib/browser/headless_browser_impl.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 121 |
121 base::FilePath log_path; | 122 base::FilePath log_path; |
122 logging::LoggingSettings settings; | 123 logging::LoggingSettings settings; |
123 | 124 |
124 if (PathService::Get(base::DIR_MODULE, &log_path)) { | 125 if (PathService::Get(base::DIR_MODULE, &log_path)) { |
125 log_path = log_path.Append(log_filename); | 126 log_path = log_path.Append(log_filename); |
126 } else { | 127 } else { |
127 log_path = log_filename; | 128 log_path = log_filename; |
128 } | 129 } |
129 | 130 |
131 std::string filename; | |
132 std::unique_ptr<base::Environment> env(base::Environment::Create()); | |
133 if (env->HasVar("CHROME_LOG_FILE") && | |
Sami
2017/03/08 10:38:14
nit: no need to call HasVar since GetVar will just
irisu
2017/03/08 23:56:08
Done.
| |
134 env->GetVar("CHROME_LOG_FILE", &filename) && !filename.empty()) { | |
Sami
2017/03/08 10:38:13
Could you make this a named constant at the top of
irisu
2017/03/08 23:56:08
Done.
| |
135 log_path = base::FilePath::FromUTF8Unsafe(filename); | |
136 } | |
137 | |
130 const std::string process_type = | 138 const std::string process_type = |
131 command_line.GetSwitchValueASCII(switches::kProcessType); | 139 command_line.GetSwitchValueASCII(switches::kProcessType); |
132 | 140 |
133 settings.logging_dest = log_mode; | 141 settings.logging_dest = log_mode; |
134 settings.log_file = log_path.value().c_str(); | 142 settings.log_file = log_path.value().c_str(); |
135 settings.lock_log = logging::DONT_LOCK_LOG_FILE; | 143 settings.lock_log = logging::DONT_LOCK_LOG_FILE; |
136 settings.delete_old = process_type.empty() ? logging::DELETE_OLD_LOG_FILE | 144 settings.delete_old = process_type.empty() ? logging::DELETE_OLD_LOG_FILE |
137 : logging::APPEND_TO_OLD_LOG_FILE; | 145 : logging::APPEND_TO_OLD_LOG_FILE; |
138 bool success = logging::InitLogging(settings); | 146 bool success = logging::InitLogging(settings); |
139 DCHECK(success); | 147 DCHECK(success); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 #endif | 258 #endif |
251 } | 259 } |
252 | 260 |
253 content::ContentBrowserClient* | 261 content::ContentBrowserClient* |
254 HeadlessContentMainDelegate::CreateContentBrowserClient() { | 262 HeadlessContentMainDelegate::CreateContentBrowserClient() { |
255 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get())); | 263 browser_client_.reset(new HeadlessContentBrowserClient(browser_.get())); |
256 return browser_client_.get(); | 264 return browser_client_.get(); |
257 } | 265 } |
258 | 266 |
259 } // namespace headless | 267 } // namespace headless |
OLD | NEW |