OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/common/crash_keys.h" | 5 #include "chrome/common/crash_keys.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/installer/util/google_update_settings.h" | |
15 | 14 |
16 #if defined(OS_MACOSX) | 15 #if defined(OS_MACOSX) |
17 #include "breakpad/src/common/simple_string_dictionary.h" | 16 #include "breakpad/src/common/simple_string_dictionary.h" |
18 #elif defined(OS_WIN) | 17 #elif defined(OS_WIN) |
19 #include "breakpad/src/client/windows/common/ipc_protocol.h" | 18 #include "breakpad/src/client/windows/common/ipc_protocol.h" |
20 #elif defined(OS_CHROMEOS) | 19 #elif defined(OS_CHROMEOS) |
21 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
22 #include "gpu/command_buffer/service/gpu_switches.h" | 21 #include "gpu/command_buffer/service/gpu_switches.h" |
23 #include "ui/gl/gl_switches.h" | 22 #include "ui/gl/gl_switches.h" |
24 #endif | 23 #endif |
(...skipping 24 matching lines...) Expand all Loading... |
49 #endif | 48 #endif |
50 | 49 |
51 // Guarantees for crash key sizes. | 50 // Guarantees for crash key sizes. |
52 COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, | 51 COMPILE_ASSERT(kSmallSize <= kSingleChunkLength, |
53 crash_key_chunk_size_too_small); | 52 crash_key_chunk_size_too_small); |
54 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
55 COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, | 54 COMPILE_ASSERT(kMediumSize <= kSingleChunkLength, |
56 mac_has_medium_size_crash_key_chunks); | 55 mac_has_medium_size_crash_key_chunks); |
57 #endif | 56 #endif |
58 | 57 |
59 const char kClientID[] = "guid"; | 58 const char kClientId[] = "guid"; |
60 | 59 |
61 const char kChannel[] = "channel"; | 60 const char kChannel[] = "channel"; |
62 | 61 |
63 const char kActiveURL[] = "url-chunk"; | 62 const char kActiveURL[] = "url-chunk"; |
64 | 63 |
65 const char kSwitch[] = "switch-%" PRIuS; | 64 const char kSwitch[] = "switch-%" PRIuS; |
66 const char kNumSwitches[] = "num-switches"; | 65 const char kNumSwitches[] = "num-switches"; |
67 | 66 |
68 const char kNumVariations[] = "num-experiments"; | 67 const char kNumVariations[] = "num-experiments"; |
69 const char kVariations[] = "variations"; | 68 const char kVariations[] = "variations"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const char kZombie[] = "zombie"; | 111 const char kZombie[] = "zombie"; |
113 const char kZombieTrace[] = "zombie_dealloc_bt"; | 112 const char kZombieTrace[] = "zombie_dealloc_bt"; |
114 | 113 |
115 } // namespace mac | 114 } // namespace mac |
116 #endif | 115 #endif |
117 | 116 |
118 size_t RegisterChromeCrashKeys() { | 117 size_t RegisterChromeCrashKeys() { |
119 // The following keys may be chunked by the underlying crash logging system, | 118 // The following keys may be chunked by the underlying crash logging system, |
120 // but ultimately constitute a single key-value pair. | 119 // but ultimately constitute a single key-value pair. |
121 base::debug::CrashKey fixed_keys[] = { | 120 base::debug::CrashKey fixed_keys[] = { |
122 { kClientID, kSmallSize }, | 121 { kClientId, kSmallSize }, |
123 { kChannel, kSmallSize }, | 122 { kChannel, kSmallSize }, |
124 { kActiveURL, kLargeSize }, | 123 { kActiveURL, kLargeSize }, |
125 { kNumSwitches, kSmallSize }, | 124 { kNumSwitches, kSmallSize }, |
126 { kNumVariations, kSmallSize }, | 125 { kNumVariations, kSmallSize }, |
127 { kVariations, kLargeSize }, | 126 { kVariations, kLargeSize }, |
128 { kNumExtensionsCount, kSmallSize }, | 127 { kNumExtensionsCount, kSmallSize }, |
129 { kNumberOfViews, kSmallSize }, | 128 { kNumberOfViews, kSmallSize }, |
130 { kShutdownType, kSmallSize }, | 129 { kShutdownType, kSmallSize }, |
131 #if !defined(OS_ANDROID) | 130 #if !defined(OS_ANDROID) |
132 { kGPUVendorID, kSmallSize }, | 131 { kGPUVendorID, kSmallSize }, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 DCHECK_GT(n, 0); | 217 DCHECK_GT(n, 0); |
219 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; | 218 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; |
220 keys.push_back(crash_key); | 219 keys.push_back(crash_key); |
221 } | 220 } |
222 } | 221 } |
223 | 222 |
224 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), | 223 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), |
225 kSingleChunkLength); | 224 kSingleChunkLength); |
226 } | 225 } |
227 | 226 |
228 void SetClientID(const std::string& client_id) { | 227 void SetCrashClientIdFromGUID(const std::string& client_guid) { |
229 std::string guid(client_id); | 228 std::string stripped_guid(client_guid); |
230 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. | 229 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. |
231 ReplaceSubstringsAfterOffset(&guid, 0, "-", ""); | 230 ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", ""); |
232 if (guid.empty()) | 231 if (stripped_guid.empty()) |
233 return; | 232 return; |
234 | 233 |
235 base::debug::SetCrashKeyValue(kClientID, guid); | 234 base::debug::SetCrashKeyValue(kClientId, stripped_guid); |
236 GoogleUpdateSettings::SetMetricsId(guid); | |
237 } | 235 } |
238 | 236 |
239 static bool IsBoringSwitch(const std::string& flag) { | 237 static bool IsBoringSwitch(const std::string& flag) { |
240 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
241 return StartsWithASCII(flag, "--channel=", true) || | 239 return StartsWithASCII(flag, "--channel=", true) || |
242 | 240 |
243 // No point to including this since we already have a ptype field. | 241 // No point to including this since we already have a ptype field. |
244 StartsWithASCII(flag, "--type=", true) || | 242 StartsWithASCII(flag, "--type=", true) || |
245 | 243 |
246 // Not particularly interesting | 244 // Not particularly interesting |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 393 } |
396 | 394 |
397 ScopedPrinterInfo::~ScopedPrinterInfo() { | 395 ScopedPrinterInfo::~ScopedPrinterInfo() { |
398 for (size_t i = 0; i < kPrinterInfoCount; ++i) { | 396 for (size_t i = 0; i < kPrinterInfoCount; ++i) { |
399 std::string key = base::StringPrintf(kPrinterInfo, i + 1); | 397 std::string key = base::StringPrintf(kPrinterInfo, i + 1); |
400 base::debug::ClearCrashKey(key); | 398 base::debug::ClearCrashKey(key); |
401 } | 399 } |
402 } | 400 } |
403 | 401 |
404 } // namespace crash_keys | 402 } // namespace crash_keys |
OLD | NEW |