OLD | NEW |
---|---|
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 "components/crash/core/common/crash_keys.h" | 5 #include "components/crash/core/common/crash_keys.h" |
6 | 6 |
7 #include "base/debug/crash_logging.h" | 7 #include "base/debug/crash_logging.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 | 12 |
13 namespace crash_keys { | 13 namespace crash_keys { |
14 | 14 |
15 #if defined(OS_MACOSX) | 15 #if defined(OS_MACOSX) |
16 // Crashpad owns the "guid" key. Chrome's metrics client ID is a separate ID | 16 // Crashpad owns the "guid" key. Chrome's metrics client ID is a separate ID |
17 // carried in a distinct "metrics_client_id" field. | 17 // carried in a distinct "metrics_client_id" field. |
18 const char kMetricsClientId[] = "metrics_client_id"; | 18 const char kMetricsClientId[] = "metrics_client_id"; |
19 #elif defined(OS_WIN) // TODO(scottmg): While transitioning to Crashpad. | |
20 const char kMetricsClientId[] = "metrics_client_id"; | |
21 const char kClientId[] = "guid"; | |
Mark Mentovai
2015/11/19 22:21:38
Crashpad owns the "guid" key, what’s this about?
scottmg
2015/11/20 19:52:48
The Breakpad-using targets use this file too (cont
Mark Mentovai
2015/11/20 20:00:23
scottmg wrote:
scottmg
2015/11/20 21:30:10
Done.
| |
19 #else | 22 #else |
20 const char kClientId[] = "guid"; | 23 const char kClientId[] = "guid"; |
21 #endif | 24 #endif |
22 | 25 |
23 const char kChannel[] = "channel"; | 26 const char kChannel[] = "channel"; |
24 | 27 |
25 const char kNumVariations[] = "num-experiments"; | 28 const char kNumVariations[] = "num-experiments"; |
26 const char kVariations[] = "variations"; | 29 const char kVariations[] = "variations"; |
27 | 30 |
28 const char kBug464926CrashKey[] = "bug-464926-info"; | 31 const char kBug464926CrashKey[] = "bug-464926-info"; |
29 | 32 |
30 #if defined(OS_MACOSX) | 33 #if defined(OS_MACOSX) |
31 namespace mac { | 34 namespace mac { |
32 | 35 |
33 const char kZombie[] = "zombie"; | 36 const char kZombie[] = "zombie"; |
34 const char kZombieTrace[] = "zombie_dealloc_bt"; | 37 const char kZombieTrace[] = "zombie_dealloc_bt"; |
35 | 38 |
36 } // namespace mac | 39 } // namespace mac |
37 #endif | 40 #endif |
38 | 41 |
39 void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid) { | 42 void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid) { |
40 std::string stripped_guid(metrics_client_guid); | 43 std::string stripped_guid(metrics_client_guid); |
41 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. | 44 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. |
42 base::ReplaceSubstringsAfterOffset( | 45 base::ReplaceSubstringsAfterOffset( |
43 &stripped_guid, 0, "-", base::StringPiece()); | 46 &stripped_guid, 0, "-", base::StringPiece()); |
44 if (stripped_guid.empty()) | 47 if (stripped_guid.empty()) |
45 return; | 48 return; |
46 | 49 |
47 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) || defined(OS_WIN) |
48 // The crash client ID is maintained by Crashpad and is distinct from the | 51 // The crash client ID is maintained by Crashpad and is distinct from the |
49 // metrics client ID, which is carried in its own key. | 52 // metrics client ID, which is carried in its own key. |
50 base::debug::SetCrashKeyValue(kMetricsClientId, stripped_guid); | 53 base::debug::SetCrashKeyValue(kMetricsClientId, stripped_guid); |
51 #else | 54 #else |
52 // The crash client ID is set by the application when Breakpad is in use. | 55 // The crash client ID is set by the application when Breakpad is in use. |
53 // The same ID as the metrics client ID is used. | 56 // The same ID as the metrics client ID is used. |
54 base::debug::SetCrashKeyValue(kClientId, stripped_guid); | 57 base::debug::SetCrashKeyValue(kClientId, stripped_guid); |
55 #endif | 58 #endif |
56 } | 59 } |
57 | 60 |
58 void ClearMetricsClientId() { | 61 void ClearMetricsClientId() { |
59 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) || defined(OS_WIN) |
60 // Crashpad always monitors for crashes, but doesn't upload them when | 63 // Crashpad always monitors for crashes, but doesn't upload them when |
61 // crash reporting is disabled. The preference to upload crash reports is | 64 // crash reporting is disabled. The preference to upload crash reports is |
62 // linked to the preference for metrics reporting. When metrics reporting is | 65 // linked to the preference for metrics reporting. When metrics reporting is |
63 // disabled, don't put the metrics client ID into crash dumps. This way, crash | 66 // disabled, don't put the metrics client ID into crash dumps. This way, crash |
64 // reports that are saved but not uploaded will not have a metrics client ID | 67 // reports that are saved but not uploaded will not have a metrics client ID |
65 // from the time that metrics reporting was disabled even if they are uploaded | 68 // from the time that metrics reporting was disabled even if they are uploaded |
66 // by user action at a later date. | 69 // by user action at a later date. |
67 // | 70 // |
68 // Breakpad cannot be enabled or disabled without an application restart, and | 71 // Breakpad cannot be enabled or disabled without an application restart, and |
69 // it needs to use the metrics client ID as its stable crash client ID, so | 72 // it needs to use the metrics client ID as its stable crash client ID, so |
(...skipping 16 matching lines...) Expand all Loading... | |
86 if (variations_string.size() + variation.size() >= kLargeSize) | 89 if (variations_string.size() + variation.size() >= kLargeSize) |
87 break; | 90 break; |
88 variations_string += variation; | 91 variations_string += variation; |
89 variations_string += ","; | 92 variations_string += ","; |
90 } | 93 } |
91 | 94 |
92 base::debug::SetCrashKeyValue(kVariations, variations_string); | 95 base::debug::SetCrashKeyValue(kVariations, variations_string); |
93 } | 96 } |
94 | 97 |
95 } // namespace crash_keys | 98 } // namespace crash_keys |
OLD | NEW |