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 <assert.h> | 9 #include <assert.h> |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 #if !defined(NACL_WIN64) | 245 #if !defined(NACL_WIN64) |
246 // static | 246 // static |
247 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { | 247 void ChromeCrashReporterClient::InitializeCrashReportingForProcess() { |
248 static ChromeCrashReporterClient* instance = nullptr; | 248 static ChromeCrashReporterClient* instance = nullptr; |
249 if (instance) | 249 if (instance) |
250 return; | 250 return; |
251 | 251 |
252 instance = new ChromeCrashReporterClient(); | 252 instance = new ChromeCrashReporterClient(); |
253 ANNOTATE_LEAKING_OBJECT_PTR(instance); | 253 ANNOTATE_LEAKING_OBJECT_PTR(instance); |
254 | 254 |
255 std::string process_type = install_static::GetSwitchValueFromCommandLine( | 255 std::wstring process_type = install_static::GetSwitchValueFromCommandLine( |
256 ::GetCommandLineA(), install_static::kProcessType); | 256 ::GetCommandLine(), install_static::kProcessType); |
257 if (process_type != install_static::kCrashpadHandler) { | 257 if (process_type != install_static::kCrashpadHandler) { |
258 crash_reporter::SetCrashReporterClient(instance); | 258 crash_reporter::SetCrashReporterClient(instance); |
259 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), | 259 crash_reporter::InitializeCrashpadWithEmbeddedHandler( |
260 process_type); | 260 process_type.empty(), install_static::UTF16ToUTF8(process_type)); |
261 } | 261 } |
262 } | 262 } |
263 #endif // NACL_WIN64 | 263 #endif // NACL_WIN64 |
264 | 264 |
265 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( | 265 bool ChromeCrashReporterClient::GetAlternativeCrashDumpLocation( |
266 base::string16* crash_dir) { | 266 base::string16* crash_dir) { |
267 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 267 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
268 // location to write breakpad crash dumps can be set. | 268 // location to write breakpad crash dumps can be set. |
269 *crash_dir = | 269 *crash_dir = |
270 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); | 270 install_static::GetEnvironmentString16(L"BREAKPAD_DUMP_LOCATION"); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 base::string16* crash_dir) { | 366 base::string16* crash_dir) { |
367 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate | 367 // By setting the BREAKPAD_DUMP_LOCATION environment variable, an alternate |
368 // location to write breakpad crash dumps can be set. | 368 // location to write breakpad crash dumps can be set. |
369 // If this environment variable exists, then for the time being, | 369 // If this environment variable exists, then for the time being, |
370 // short-circuit how it's handled on Windows. Honoring this | 370 // short-circuit how it's handled on Windows. Honoring this |
371 // variable is required in order to symbolize stack traces in | 371 // variable is required in order to symbolize stack traces in |
372 // Telemetry based tests: http://crbug.com/561763. | 372 // Telemetry based tests: http://crbug.com/561763. |
373 if (GetAlternativeCrashDumpLocation(crash_dir)) | 373 if (GetAlternativeCrashDumpLocation(crash_dir)) |
374 return true; | 374 return true; |
375 | 375 |
376 // TODO(scottmg): Consider supporting --user-data-dir. See | 376 return install_static::GetCrashDumpLocation(crash_dir); |
377 // https://crbug.com/565446. | |
378 return install_static::GetDefaultCrashDumpLocation(crash_dir); | |
379 } | 377 } |
380 | 378 |
381 bool ChromeCrashReporterClient::GetCrashMetricsLocation( | 379 bool ChromeCrashReporterClient::GetCrashMetricsLocation( |
382 base::string16* metrics_dir) { | 380 base::string16* metrics_dir) { |
383 return install_static::GetDefaultUserDataDirectory(metrics_dir); | 381 return install_static::GetUserDataDirectory(metrics_dir); |
384 } | 382 } |
385 | 383 |
386 // TODO(ananta) | 384 // TODO(ananta) |
387 // This function should be removed when the new crash key map implementation | 385 // This function should be removed when the new crash key map implementation |
388 // lands. | 386 // lands. |
389 size_t ChromeCrashReporterClient::RegisterCrashKeys() { | 387 size_t ChromeCrashReporterClient::RegisterCrashKeys() { |
390 return RegisterCrashKeysHelper(); | 388 return RegisterCrashKeysHelper(); |
391 } | 389 } |
392 | 390 |
393 bool ChromeCrashReporterClient::IsRunningUnattended() { | 391 bool ChromeCrashReporterClient::IsRunningUnattended() { |
394 return install_static::HasEnvironmentVariable16(install_static::kHeadless); | 392 return install_static::HasEnvironmentVariable16(install_static::kHeadless); |
395 } | 393 } |
396 | 394 |
397 bool ChromeCrashReporterClient::GetCollectStatsConsent() { | 395 bool ChromeCrashReporterClient::GetCollectStatsConsent() { |
398 return install_static::GetCollectStatsConsent(); | 396 return install_static::GetCollectStatsConsent(); |
399 } | 397 } |
400 | 398 |
401 bool ChromeCrashReporterClient::GetCollectStatsInSample() { | 399 bool ChromeCrashReporterClient::GetCollectStatsInSample() { |
402 return install_static::GetCollectStatsInSample(); | 400 return install_static::GetCollectStatsInSample(); |
403 } | 401 } |
404 | 402 |
405 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 403 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
406 const std::string& process_type) { | 404 const std::string& process_type) { |
407 return process_type == install_static::kRendererProcess || | 405 // This is not used by Crashpad (at least on Windows). |
408 process_type == install_static::kPpapiPluginProcess || | 406 NOTREACHED(); |
409 process_type == install_static::kGpuProcess; | 407 return true; |
410 } | 408 } |
OLD | NEW |