OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/app/breakpad.h" | 5 #include "chrome/app/breakpad.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <tchar.h> | 8 #include <tchar.h> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 return true; | 156 return true; |
157 } | 157 } |
158 | 158 |
159 static DWORD __stdcall InitCrashReporterThread(void* param) { | 159 static DWORD __stdcall InitCrashReporterThread(void* param) { |
160 CrashReporterInfo* info = reinterpret_cast<CrashReporterInfo*>(param); | 160 CrashReporterInfo* info = reinterpret_cast<CrashReporterInfo*>(param); |
161 | 161 |
162 // GetCustomInfo can take a few milliseconds to get the file information, so | 162 // GetCustomInfo can take a few milliseconds to get the file information, so |
163 // we do it here so it can run in a separate thread. | 163 // we do it here so it can run in a separate thread. |
164 info->custom_info = GetCustomInfo(info->dll_path, info->process_type); | 164 info->custom_info = GetCustomInfo(info->dll_path, info->process_type); |
165 | 165 |
166 CommandLine command; | 166 const CommandLine& command = *CommandLine::ForCurrentProcess(); |
167 bool full_dump = command.HasSwitch(switches::kFullMemoryCrashReport); | 167 bool full_dump = command.HasSwitch(switches::kFullMemoryCrashReport); |
168 bool use_crash_service = command.HasSwitch(switches::kNoErrorDialogs) || | 168 bool use_crash_service = command.HasSwitch(switches::kNoErrorDialogs) || |
169 GetEnvironmentVariable(L"CHROME_HEADLESS", NULL, 0); | 169 GetEnvironmentVariable(L"CHROME_HEADLESS", NULL, 0); |
170 | 170 |
171 google_breakpad::ExceptionHandler::MinidumpCallback callback = NULL; | 171 google_breakpad::ExceptionHandler::MinidumpCallback callback = NULL; |
172 | 172 |
173 if (info->process_type == L"browser") { | 173 if (info->process_type == L"browser") { |
174 // We install the post-dump callback only for the browser process. It | 174 // We install the post-dump callback only for the browser process. It |
175 // spawns a new browser process. | 175 // spawns a new browser process. |
176 callback = &DumpDoneCallback; | 176 callback = &DumpDoneCallback; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 delete info; | 232 delete info; |
233 return 0; | 233 return 0; |
234 } | 234 } |
235 | 235 |
236 void InitDefaultCrashCallback() { | 236 void InitDefaultCrashCallback() { |
237 previous_filter = SetUnhandledExceptionFilter(ChromeExceptionFilter); | 237 previous_filter = SetUnhandledExceptionFilter(ChromeExceptionFilter); |
238 } | 238 } |
239 | 239 |
240 void InitCrashReporter(std::wstring dll_path) { | 240 void InitCrashReporter(std::wstring dll_path) { |
241 CommandLine command; | 241 const CommandLine& command = *CommandLine::ForCurrentProcess(); |
242 if (!command.HasSwitch(switches::kDisableBreakpad)) { | 242 if (!command.HasSwitch(switches::kDisableBreakpad)) { |
243 // Disable the message box for assertions. | 243 // Disable the message box for assertions. |
244 _CrtSetReportMode(_CRT_ASSERT, 0); | 244 _CrtSetReportMode(_CRT_ASSERT, 0); |
245 | 245 |
246 // Query the custom_info now because if we do it in the thread it's going to | 246 // Query the custom_info now because if we do it in the thread it's going to |
247 // fail in the sandbox. The thread will delete this object. | 247 // fail in the sandbox. The thread will delete this object. |
248 CrashReporterInfo* info = new CrashReporterInfo; | 248 CrashReporterInfo* info = new CrashReporterInfo; |
249 info->process_type = command.GetSwitchValue(switches::kProcessType); | 249 info->process_type = command.GetSwitchValue(switches::kProcessType); |
250 if (info->process_type.empty()) | 250 if (info->process_type.empty()) |
251 info->process_type = L"browser"; | 251 info->process_type = L"browser"; |
(...skipping 10 matching lines...) Expand all Loading... |
262 } else { | 262 } else { |
263 if (QueueUserWorkItem( | 263 if (QueueUserWorkItem( |
264 &InitCrashReporterThread, info, WT_EXECUTELONGFUNCTION) == 0) { | 264 &InitCrashReporterThread, info, WT_EXECUTELONGFUNCTION) == 0) { |
265 // We failed to queue to the worker pool, initialize in this thread. | 265 // We failed to queue to the worker pool, initialize in this thread. |
266 InitCrashReporterThread(info); | 266 InitCrashReporterThread(info); |
267 } | 267 } |
268 } | 268 } |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
OLD | NEW |