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 | 17 |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/debug/crash_logging.h" | 19 #include "base/debug/crash_logging.h" |
20 #include "base/debug/leak_annotations.h" | 20 #include "base/debug/leak_annotations.h" |
21 #include "base/format_macros.h" | 21 #include "base/format_macros.h" |
| 22 #include "base/rand_util.h" |
22 #include "chrome/common/chrome_result_codes.h" | 23 #include "chrome/common/chrome_result_codes.h" |
23 #include "chrome/install_static/install_details.h" | 24 #include "chrome/install_static/install_details.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" |
27 #include "components/crash/core/common/crash_keys.h" | 28 #include "components/crash/core/common/crash_keys.h" |
| 29 #include "components/version_info/channel.h" |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 // TODO(ananta) | 33 // TODO(ananta) |
32 // When the new crash key map implementation lands, we should remove the | 34 // When the new crash key map implementation lands, we should remove the |
33 // constants defined below, the RegisterCrashKeysHelper function, the | 35 // constants defined below, the RegisterCrashKeysHelper function, the |
34 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface | 36 // RegisterCrashKeys function in the crash_keys::CrashReporterClient interface |
35 // and the snprintf function defined here. | 37 // and the snprintf function defined here. |
36 constexpr char kActiveURL[] = "url-chunk"; | 38 constexpr char kActiveURL[] = "url-chunk"; |
37 constexpr char kFontKeyName[] = "font_key_name"; | 39 constexpr char kFontKeyName[] = "font_key_name"; |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 400 } |
399 | 401 |
400 bool ChromeCrashReporterClient::GetCollectStatsConsent() { | 402 bool ChromeCrashReporterClient::GetCollectStatsConsent() { |
401 return install_static::GetCollectStatsConsent(); | 403 return install_static::GetCollectStatsConsent(); |
402 } | 404 } |
403 | 405 |
404 bool ChromeCrashReporterClient::GetCollectStatsInSample() { | 406 bool ChromeCrashReporterClient::GetCollectStatsInSample() { |
405 return install_static::GetCollectStatsInSample(); | 407 return install_static::GetCollectStatsInSample(); |
406 } | 408 } |
407 | 409 |
| 410 bool ChromeCrashReporterClient::ShouldMonitorCrashHandlerExpensively() { |
| 411 // The expensive mechanism dedicates a process to be crashpad_handler's own |
| 412 // crashpad_handler. In Chrome builds for official release, scale back on |
| 413 // this in the more stable channels. There's a fallback crash handler that |
| 414 // can catch crashes when this expensive mechanism isn't used, although the |
| 415 // fallback crash handler has different characteristics so it's desirable to |
| 416 // use the expensive mechanism at least some of the time. |
| 417 double probability = 0.5; |
| 418 #if defined(GOOGLE_CHROME_BUILD) && defined(OFFICIAL_BUILD) |
| 419 switch (install_static::InstallDetails::Get().GetChannel()) { |
| 420 case version_info::Channel::STABLE: |
| 421 return false; |
| 422 |
| 423 case version_info::Channel::BETA: |
| 424 probability = 0.1; |
| 425 break; |
| 426 |
| 427 case version_info::Channel::DEV: |
| 428 probability = 0.25; |
| 429 break; |
| 430 |
| 431 case version_info::Channel::CANARY: |
| 432 case version_info::Channel::UNKNOWN: |
| 433 break; |
| 434 } |
| 435 #endif |
| 436 |
| 437 return base::RandDouble() < probability; |
| 438 } |
| 439 |
408 bool ChromeCrashReporterClient::EnableBreakpadForProcess( | 440 bool ChromeCrashReporterClient::EnableBreakpadForProcess( |
409 const std::string& process_type) { | 441 const std::string& process_type) { |
410 // This is not used by Crashpad (at least on Windows). | 442 // This is not used by Crashpad (at least on Windows). |
411 NOTREACHED(); | 443 NOTREACHED(); |
412 return true; | 444 return true; |
413 } | 445 } |
OLD | NEW |