Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: chrome/common/crash_keys.cc

Issue 1000203007: Set a "metrics_client_id" crash key instead of "guid" on Mac OS X (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, don't include useless switches Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #endif 48 #endif
49 49
50 // Guarantees for crash key sizes. 50 // Guarantees for crash key sizes.
51 static_assert(kSmallSize <= kSingleChunkLength, 51 static_assert(kSmallSize <= kSingleChunkLength,
52 "crash key chunk size too small"); 52 "crash key chunk size too small");
53 #if defined(OS_MACOSX) 53 #if defined(OS_MACOSX)
54 static_assert(kMediumSize <= kSingleChunkLength, 54 static_assert(kMediumSize <= kSingleChunkLength,
55 "mac has medium size crash key chunks"); 55 "mac has medium size crash key chunks");
56 #endif 56 #endif
57 57
58 #if defined(OS_MACOSX)
59 // Crashpad owns the "guid" key. Chrome's metrics client ID is a separate ID
60 // carried in a distinct "metrics_client_id" field.
61 const char kMetricsClientId[] = "metrics_client_id";
62 #else
58 const char kClientId[] = "guid"; 63 const char kClientId[] = "guid";
64 #endif
59 65
60 const char kChannel[] = "channel"; 66 const char kChannel[] = "channel";
61 67
62 const char kActiveURL[] = "url-chunk"; 68 const char kActiveURL[] = "url-chunk";
63 69
64 const char kFontKeyName[] = "font_key_name"; 70 const char kFontKeyName[] = "font_key_name";
65 71
66 const char kSwitch[] = "switch-%" PRIuS; 72 const char kSwitch[] = "switch-%" PRIuS;
67 const char kNumSwitches[] = "num-switches"; 73 const char kNumSwitches[] = "num-switches";
68 74
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 122
117 #if defined(KASKO) 123 #if defined(KASKO)
118 const char kKaskoGuid[] = "kasko-guid"; 124 const char kKaskoGuid[] = "kasko-guid";
119 const char kKaskoEquivalentGuid[] = "kasko-equivalent-guid"; 125 const char kKaskoEquivalentGuid[] = "kasko-equivalent-guid";
120 #endif 126 #endif
121 127
122 size_t RegisterChromeCrashKeys() { 128 size_t RegisterChromeCrashKeys() {
123 // The following keys may be chunked by the underlying crash logging system, 129 // The following keys may be chunked by the underlying crash logging system,
124 // but ultimately constitute a single key-value pair. 130 // but ultimately constitute a single key-value pair.
125 base::debug::CrashKey fixed_keys[] = { 131 base::debug::CrashKey fixed_keys[] = {
132 #if defined(OS_MACOSX)
133 { kMetricsClientId, kSmallSize },
134 #else
126 { kClientId, kSmallSize }, 135 { kClientId, kSmallSize },
136 #endif
127 { kChannel, kSmallSize }, 137 { kChannel, kSmallSize },
128 { kActiveURL, kLargeSize }, 138 { kActiveURL, kLargeSize },
129 { kNumSwitches, kSmallSize }, 139 { kNumSwitches, kSmallSize },
130 { kNumVariations, kSmallSize }, 140 { kNumVariations, kSmallSize },
131 { kVariations, kLargeSize }, 141 { kVariations, kLargeSize },
132 { kNumExtensionsCount, kSmallSize }, 142 { kNumExtensionsCount, kSmallSize },
133 { kShutdownType, kSmallSize }, 143 { kShutdownType, kSmallSize },
134 #if !defined(OS_ANDROID) 144 #if !defined(OS_ANDROID)
135 { kGPUVendorID, kSmallSize }, 145 { kGPUVendorID, kSmallSize },
136 { kGPUDeviceID, kSmallSize }, 146 { kGPUDeviceID, kSmallSize },
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 DCHECK_GT(n, 0); 237 DCHECK_GT(n, 0);
228 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize }; 238 base::debug::CrashKey crash_key = { formatted_keys[i], kSmallSize };
229 keys.push_back(crash_key); 239 keys.push_back(crash_key);
230 } 240 }
231 } 241 }
232 242
233 return base::debug::InitCrashKeys(&keys.at(0), keys.size(), 243 return base::debug::InitCrashKeys(&keys.at(0), keys.size(),
234 kSingleChunkLength); 244 kSingleChunkLength);
235 } 245 }
236 246
247 #if defined(OS_MACOSX)
248
249 void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid) {
250 std::string stripped_guid(metrics_client_guid);
251 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY.
252 ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", "");
253 if (stripped_guid.empty())
254 return;
255
256 base::debug::SetCrashKeyValue(kMetricsClientId, stripped_guid);
257 }
258
259 void ClearMetricsClientId() {
260 base::debug::ClearCrashKey(kMetricsClientId);
261 }
262
263 #else
264
237 void SetCrashClientIdFromGUID(const std::string& client_guid) { 265 void SetCrashClientIdFromGUID(const std::string& client_guid) {
238 std::string stripped_guid(client_guid); 266 std::string stripped_guid(client_guid);
239 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. 267 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY.
240 ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", ""); 268 ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", "");
241 if (stripped_guid.empty()) 269 if (stripped_guid.empty())
242 return; 270 return;
243 271
244 base::debug::SetCrashKeyValue(kClientId, stripped_guid); 272 base::debug::SetCrashKeyValue(kClientId, stripped_guid);
245 } 273 }
246 274
275 #endif
276
247 static bool IsBoringSwitch(const std::string& flag) { 277 static bool IsBoringSwitch(const std::string& flag) {
248 #if defined(OS_WIN) 278 #if defined(OS_WIN)
249 return StartsWithASCII(flag, "--channel=", true) || 279 return StartsWithASCII(flag, "--channel=", true) ||
250 280
251 // No point to including this since we already have a ptype field. 281 // No point to including this since we already have a ptype field.
252 StartsWithASCII(flag, "--type=", true) || 282 StartsWithASCII(flag, "--type=", true) ||
253 283
254 // Not particularly interesting 284 // Not particularly interesting
255 StartsWithASCII(flag, "--flash-broker=", true) || 285 StartsWithASCII(flag, "--flash-broker=", true) ||
256 286
257 // Just about everything has this, don't bother. 287 // Just about everything has this, don't bother.
258 StartsWithASCII(flag, "/prefetch:", true) || 288 StartsWithASCII(flag, "/prefetch:", true) ||
259 289
260 // We handle the plugin path separately since it is usually too big 290 // We handle the plugin path separately since it is usually too big
261 // to fit in the switches (limited to 63 characters). 291 // to fit in the switches (limited to 63 characters).
262 StartsWithASCII(flag, "--plugin-path=", true) || 292 StartsWithASCII(flag, "--plugin-path=", true) ||
263 293
264 // This is too big so we end up truncating it anyway. 294 // This is too big so we end up truncating it anyway.
265 StartsWithASCII(flag, "--force-fieldtrials=", true) || 295 StartsWithASCII(flag, "--force-fieldtrials=", true) ||
266 296
267 // These surround the flags that were added by about:flags, it lets 297 // These surround the flags that were added by about:flags, it lets
268 // you distinguish which flags were added manually via the command 298 // you distinguish which flags were added manually via the command
269 // line versus those added through about:flags. For the most part 299 // line versus those added through about:flags. For the most part
270 // we don't care how an option was enabled, so we strip these. 300 // we don't care how an option was enabled, so we strip these.
271 // (If you need to know can always look at the PEB). 301 // (If you need to know can always look at the PEB).
272 flag == "--flag-switches-begin" || 302 flag == "--flag-switches-begin" ||
273 flag == "--flag-switches-end"; 303 flag == "--flag-switches-end";
304 #elif defined(OS_MACOSX)
305 // These are carried in their own fields.
306 return StartsWithASCII(flag, "--channel=", true) ||
307 StartsWithASCII(flag, "--type=", true) ||
308 StartsWithASCII(flag, "--metrics-client-id=", true);
274 #elif defined(OS_CHROMEOS) 309 #elif defined(OS_CHROMEOS)
275 static const char* const kIgnoreSwitches[] = { 310 static const char* const kIgnoreSwitches[] = {
276 ::switches::kEnableLogging, 311 ::switches::kEnableLogging,
277 ::switches::kFlagSwitchesBegin, 312 ::switches::kFlagSwitchesBegin,
278 ::switches::kFlagSwitchesEnd, 313 ::switches::kFlagSwitchesEnd,
279 ::switches::kLoggingLevel, 314 ::switches::kLoggingLevel,
280 ::switches::kPpapiFlashArgs, 315 ::switches::kPpapiFlashArgs,
281 ::switches::kPpapiFlashPath, 316 ::switches::kPpapiFlashPath,
282 ::switches::kRegisterPepperPlugins, 317 ::switches::kRegisterPepperPlugins,
283 ::switches::kUIPrioritizeInGpuProcess, 318 ::switches::kUIPrioritizeInGpuProcess,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 438 }
404 439
405 ScopedPrinterInfo::~ScopedPrinterInfo() { 440 ScopedPrinterInfo::~ScopedPrinterInfo() {
406 for (size_t i = 0; i < kPrinterInfoCount; ++i) { 441 for (size_t i = 0; i < kPrinterInfoCount; ++i) {
407 std::string key = base::StringPrintf(kPrinterInfo, i + 1); 442 std::string key = base::StringPrintf(kPrinterInfo, i + 1);
408 base::debug::ClearCrashKey(key); 443 base::debug::ClearCrashKey(key);
409 } 444 }
410 } 445 }
411 446
412 } // namespace crash_keys 447 } // namespace crash_keys
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698