| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // TODO(ananta/scottmg) | 5 // TODO(ananta/scottmg) |
| 6 // Add test coverage for Crashpad. | 6 // Add test coverage for Crashpad. |
| 7 #include "chrome/app/chrome_crash_reporter_client_win.h" | 7 #include "chrome/app/chrome_crash_reporter_client_win.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| 11 #include <assert.h> | 11 #include <assert.h> |
| 12 #include <shellapi.h> | 12 #include <shellapi.h> |
| 13 | 13 |
| 14 #include <iterator> | 14 #include <iterator> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> |
| 17 | 18 |
| 18 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 19 #include "base/debug/crash_logging.h" | 20 #include "base/debug/crash_logging.h" |
| 20 #include "base/debug/leak_annotations.h" | 21 #include "base/debug/leak_annotations.h" |
| 21 #include "base/format_macros.h" | 22 #include "base/format_macros.h" |
| 22 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 23 #include "chrome/common/chrome_result_codes.h" | 24 #include "chrome/common/chrome_result_codes.h" |
| 24 #include "chrome/install_static/install_util.h" | 25 #include "chrome/install_static/install_util.h" |
| 25 #include "chrome/install_static/user_data_dir.h" | 26 #include "chrome/install_static/user_data_dir.h" |
| 26 #include "components/crash/content/app/crashpad.h" | 27 #include "components/crash/content/app/crashpad.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 234 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
| 234 static ChromeCrashReporterClient* instance = nullptr; | 235 static ChromeCrashReporterClient* instance = nullptr; |
| 235 if (instance) | 236 if (instance) |
| 236 return; | 237 return; |
| 237 | 238 |
| 238 instance = new ChromeCrashReporterClient(); | 239 instance = new ChromeCrashReporterClient(); |
| 239 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 240 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
| 240 | 241 |
| 241 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( | 242 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( |
| 242 ::GetCommandLine(), install_static::kProcessType); | 243 ::GetCommandLine(), install_static::kProcessType); |
| 244 std::wstring user_data_dir; |
| 245 if (install_static::CurrentProcessNeedsProfileDir()) |
| 246 user_data_dir = install_static::GetUserDataDirectory(); |
| 243 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor | 247 // Don't set up Crashpad crash reporting in the Crashpad handler itself, nor |
| 244 // in the fallback crash handler for the Crashpad handler process. | 248 // in the fallback crash handler for the Crashpad handler process. |
| 245 if (process_type != install_static::kCrashpadHandler && | 249 if (process_type != install_static::kCrashpadHandler && |
| 246 process_type != install_static::kFallbackHandler) { | 250 process_type != install_static::kFallbackHandler) { |
| 247 crash_reporter::SetCrashReporterClient(instance); | 251 crash_reporter::SetCrashReporterClient(instance); |
| 248 crash_reporter::InitializeCrashpadWithEmbeddedHandler( | 252 crash_reporter::InitializeCrashpadWithEmbeddedHandler( |
| 249 process_type.empty(), install_static::UTF16ToUTF8(process_type)); | 253 process_type.empty(), install_static::UTF16ToUTF8(process_type), |
| 254 install_static::UTF16ToUTF8(user_data_dir)); |
| 250 } | 255 } |
| 251 } | 256 } |
| 252 #endif // NACL_WIN64 | 257 #endif // NACL_WIN64 |
| 253 | 258 |
| 254 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 259 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
| 255 base::string16* crash_dir) { | 260 base::string16* crash_dir) { |
| 256 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 261 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
| 257 // location to write breakpad crash dumps can be set. | 262 // location to write breakpad crash dumps can be set. |
| 258 *crash_dir = | 263 *crash_dir = |
| 259 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 264 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 352 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
| 348 // location to write breakpad crash dumps can be set. | 353 // location to write breakpad crash dumps can be set. |
| 349 // If this environment variable exists, then for the time being, | 354 // If this environment variable exists, then for the time being, |
| 350 // short-circuit how it's handled on Windows. Honoring this | 355 // short-circuit how it's handled on Windows. Honoring this |
| 351 // variable is required in order to symbolize stack traces in | 356 // variable is required in order to symbolize stack traces in |
| 352 // Telemetry based tests: http://crbug.com/561763. | 357 // Telemetry based tests: http://crbug.com/561763. |
| 353 if (GetAlternativeCrashDumpLocation(crash_dir)) | 358 if (GetAlternativeCrashDumpLocation(crash_dir)) |
| 354 return true; | 359 return true; |
| 355 | 360 |
| 356 *crash_dir = install_static::GetCrashDumpLocation(); | 361 *crash_dir = install_static::GetCrashDumpLocation(); |
| 357 return true; | 362 return !crash_dir->empty(); |
| 358 } | 363 } |
| 359 | 364 |
| 360 bool ChromeCrashReporterClient::GetCrashMetricsLocation( | 365 bool ChromeCrashReporterClient::GetCrashMetricsLocation( |
| 361 base::string16* metrics_dir) { | 366 base::string16* metrics_dir) { |
| 362 return install_static::GetUserDataDirectory(metrics_dir, nullptr); | 367 *metrics_dir = install_static::GetUserDataDirectory(); |
| 368 return !metrics_dir->empty(); |
| 363 } | 369 } |
| 364 | 370 |
| 365 // TODO(ananta) | 371 // TODO(ananta) |
| 366 // This function should be removed when the new crash key map implementation | 372 // This function should be removed when the new crash key map implementation |
| 367 // lands. | 373 // lands. |
| 368 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 374 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
| 369 return RegisterCrashKeysHelper(); | 375 return RegisterCrashKeysHelper(); |
| 370 } | 376 } |
| 371 | 377 |
| 372 bool ChromeCrashReporterClient::IsRunningUnattended() { | 378 bool ChromeCrashReporterClient::IsRunningUnattended() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 414 |
| 409 return base::RandDouble() < probability; | 415 return base::RandDouble() < probability; |
| 410 } | 416 } |
| 411 | 417 |
| 412 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 418 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
| 413 const std::string& process_type) { | 419 const std::string& process_type) { |
| 414 // This is not used by Crashpad (at least on Windows). | 420 // This is not used by Crashpad (at least on Windows). |
| 415 NOTREACHED(); | 421 NOTREACHED(); |
| 416 return true; | 422 return true; |
| 417 } | 423 } |
| OLD | NEW |