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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/crash_keys.cc
diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc
index 1983f0d73ec93b37ac16d974176d59dfb2611c88..bce2dfcc56c29bd09ee225bd7cc5c5f5c0514917 100644
--- a/chrome/common/crash_keys.cc
+++ b/chrome/common/crash_keys.cc
@@ -55,7 +55,13 @@ static_assert(kMediumSize <= kSingleChunkLength,
"mac has medium size crash key chunks");
#endif
+#if defined(OS_MACOSX)
+// Crashpad owns the "guid" key. Chrome's metrics client ID is a separate ID
+// carried in a distinct "metrics_client_id" field.
+const char kMetricsClientId[] = "metrics_client_id";
+#else
const char kClientId[] = "guid";
+#endif
const char kChannel[] = "channel";
@@ -123,7 +129,11 @@ size_t RegisterChromeCrashKeys() {
// The following keys may be chunked by the underlying crash logging system,
// but ultimately constitute a single key-value pair.
base::debug::CrashKey fixed_keys[] = {
+#if defined(OS_MACOSX)
+ { kMetricsClientId, kSmallSize },
+#else
{ kClientId, kSmallSize },
+#endif
{ kChannel, kSmallSize },
{ kActiveURL, kLargeSize },
{ kNumSwitches, kSmallSize },
@@ -234,6 +244,24 @@ size_t RegisterChromeCrashKeys() {
kSingleChunkLength);
}
+#if defined(OS_MACOSX)
+
+void SetMetricsClientIdFromGUID(const std::string& metrics_client_guid) {
+ std::string stripped_guid(metrics_client_guid);
+ // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY.
+ ReplaceSubstringsAfterOffset(&stripped_guid, 0, "-", "");
+ if (stripped_guid.empty())
+ return;
+
+ base::debug::SetCrashKeyValue(kMetricsClientId, stripped_guid);
+}
+
+void ClearMetricsClientId() {
+ base::debug::ClearCrashKey(kMetricsClientId);
+}
+
+#else
+
void SetCrashClientIdFromGUID(const std::string& client_guid) {
std::string stripped_guid(client_guid);
// Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY.
@@ -244,6 +272,8 @@ void SetCrashClientIdFromGUID(const std::string& client_guid) {
base::debug::SetCrashKeyValue(kClientId, stripped_guid);
}
+#endif
+
static bool IsBoringSwitch(const std::string& flag) {
#if defined(OS_WIN)
return StartsWithASCII(flag, "--channel=", true) ||
@@ -271,6 +301,11 @@ static bool IsBoringSwitch(const std::string& flag) {
// (If you need to know can always look at the PEB).
flag == "--flag-switches-begin" ||
flag == "--flag-switches-end";
+#elif defined(OS_MACOSX)
+ // These are carried in their own fields.
+ return StartsWithASCII(flag, "--channel=", true) ||
+ StartsWithASCII(flag, "--type=", true) ||
+ StartsWithASCII(flag, "--metrics-client-id=", true);
#elif defined(OS_CHROMEOS)
static const char* const kIgnoreSwitches[] = {
::switches::kEnableLogging,

Powered by Google App Engine
This is Rietveld 408576698