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

Side by Side Diff: headless/lib/headless_content_main_delegate.cc

Issue 2836823002: Fix DCHECH errors on Windows (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/headless_content_main_delegate.h" 5 #include "headless/lib/headless_content_main_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } else { 91 } else {
92 command_line->AppendSwitch(switches::kDisableGpu); 92 command_line->AppendSwitch(switches::kDisableGpu);
93 } 93 }
94 94
95 SetContentClient(&content_client_); 95 SetContentClient(&content_client_);
96 return false; 96 return false;
97 } 97 }
98 98
99 void HeadlessContentMainDelegate::InitLogging( 99 void HeadlessContentMainDelegate::InitLogging(
100 const base::CommandLine& command_line) { 100 const base::CommandLine& command_line) {
101 const std::string process_type =
102 command_line.GetSwitchValueASCII(switches::kProcessType);
101 #if !defined(OS_WIN) 103 #if !defined(OS_WIN)
102 if (!command_line.HasSwitch(switches::kEnableLogging)) 104 if (!command_line.HasSwitch(switches::kEnableLogging))
103 return; 105 return;
104 #endif 106 #else
107 // Child processes in Windows are not able to initialize logging.
108 if (!process_type.empty())
109 return;
110 #endif // !defined(OS_WIN)
105 111
106 logging::LoggingDestination log_mode; 112 logging::LoggingDestination log_mode;
107 base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log")); 113 base::FilePath log_filename(FILE_PATH_LITERAL("chrome_debug.log"));
108 if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr") { 114 if (command_line.GetSwitchValueASCII(switches::kEnableLogging) == "stderr") {
109 log_mode = logging::LOG_TO_SYSTEM_DEBUG_LOG; 115 log_mode = logging::LOG_TO_SYSTEM_DEBUG_LOG;
110 } else { 116 } else {
111 base::FilePath custom_filename( 117 base::FilePath custom_filename(
112 command_line.GetSwitchValuePath(switches::kEnableLogging)); 118 command_line.GetSwitchValuePath(switches::kEnableLogging));
113 if (custom_filename.empty()) { 119 if (custom_filename.empty()) {
114 log_mode = logging::LOG_TO_ALL; 120 log_mode = logging::LOG_TO_ALL;
(...skipping 24 matching lines...) Expand all
139 } else { 145 } else {
140 log_path = log_filename; 146 log_path = log_filename;
141 } 147 }
142 148
143 std::string filename; 149 std::string filename;
144 std::unique_ptr<base::Environment> env(base::Environment::Create()); 150 std::unique_ptr<base::Environment> env(base::Environment::Create());
145 if (env->GetVar(kLogFileName, &filename) && !filename.empty()) { 151 if (env->GetVar(kLogFileName, &filename) && !filename.empty()) {
146 log_path = base::FilePath::FromUTF8Unsafe(filename); 152 log_path = base::FilePath::FromUTF8Unsafe(filename);
147 } 153 }
148 154
149 const std::string process_type =
150 command_line.GetSwitchValueASCII(switches::kProcessType);
151
152 settings.logging_dest = log_mode; 155 settings.logging_dest = log_mode;
153 settings.log_file = log_path.value().c_str(); 156 settings.log_file = log_path.value().c_str();
154 settings.lock_log = logging::DONT_LOCK_LOG_FILE; 157 settings.lock_log = logging::DONT_LOCK_LOG_FILE;
155 settings.delete_old = process_type.empty() ? logging::DELETE_OLD_LOG_FILE 158 settings.delete_old = process_type.empty() ? logging::DELETE_OLD_LOG_FILE
156 : logging::APPEND_TO_OLD_LOG_FILE; 159 : logging::APPEND_TO_OLD_LOG_FILE;
157 bool success = logging::InitLogging(settings); 160 bool success = logging::InitLogging(settings);
158 DCHECK(success); 161 DCHECK(success);
159 } 162 }
160 163
161 void HeadlessContentMainDelegate::InitCrashReporter( 164 void HeadlessContentMainDelegate::InitCrashReporter(
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 HeadlessContentMainDelegate::CreateContentRendererClient() { 294 HeadlessContentMainDelegate::CreateContentRendererClient() {
292 #if defined(CHROME_MULTIPLE_DLL_BROWSER) 295 #if defined(CHROME_MULTIPLE_DLL_BROWSER)
293 return nullptr; 296 return nullptr;
294 #else 297 #else
295 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>(); 298 renderer_client_ = base::MakeUnique<HeadlessContentRendererClient>();
296 return renderer_client_.get(); 299 return renderer_client_.get();
297 #endif 300 #endif
298 } 301 }
299 302
300 } // namespace headless 303 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_browser_impl.cc ('k') | headless/public/headless_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698