summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 22:31:03 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 22:31:03 +0000
commit157d547807a2b9d0e42f17636ffc39336a9a62f6 (patch)
tree9ae45f8dcd0a5298b39c44dd94d07219200e73c1 /chrome/common
parent23ffe4da52705ce6fd12d3aa3e178c2b5dd79598 (diff)
downloadchromium_src-157d547807a2b9d0e42f17636ffc39336a9a62f6.zip
chromium_src-157d547807a2b9d0e42f17636ffc39336a9a62f6.tar.gz
chromium_src-157d547807a2b9d0e42f17636ffc39336a9a62f6.tar.bz2
Change id that identifies client in crash reports. Whenever metrics service recording is enabled, it sets the client id for crash reporting.
- On Windows this id gets stored in the registry so that we can read it pretty early regardless of the process type. If the id has not been generated (like in the case of first run) we initialize with empty string but the real id gets inserted once metrics service gets initialized. - On Linux we were creating a hash and storing it in 'Consent to Send Stats'. This change replaces that hash with the metrics id. Unlike before calling SetConsentToSendStats doesn't generate a new id, if an id already exists. - On Mac there was no id set. Now we use metrics id as guid for the browser process. For other process types a change is still required to pass that id as command line param to renderers/plugins (like Linux). BUG=23658 TEST=Cause a deliberate crash in Chrome renderer/browser/plugin and make sure the clientID reported to the crash server is the right GUID. Review URL: http://codereview.chromium.org/346007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/child_process_host.cc13
-rw-r--r--chrome/common/child_process_logging.h3
-rw-r--r--chrome/common/child_process_logging_linux.cc12
-rw-r--r--chrome/common/child_process_logging_mac.mm19
-rw-r--r--chrome/common/child_process_logging_win.cc31
-rwxr-xr-x[-rw-r--r--]chrome/common/temp_scaffolding_stubs.cc0
6 files changed, 73 insertions, 5 deletions
diff --git a/chrome/common/child_process_host.cc b/chrome/common/child_process_host.cc
index 69655b4..d4a9eda 100644
--- a/chrome/common/child_process_host.cc
+++ b/chrome/common/child_process_host.cc
@@ -26,14 +26,16 @@
#if defined(OS_LINUX)
#include "base/linux_util.h"
+#endif // OS_LINUX
-// This is defined in chrome/browser/google_update_settings_linux.cc. It's the
+#if defined(OS_POSIX)
+// This is defined in chrome/browser/google_update_settings_posix.cc. It's the
// static string containing the user's unique GUID. We send this in the crash
// report.
namespace google_update {
-extern std::string linux_guid;
+extern std::string posix_guid;
} // namespace google_update
-#endif // OS_LINUX
+#endif // OS_POSIX
namespace {
@@ -111,13 +113,14 @@ void ChildProcessHost::SetCrashReporterCommandLine(CommandLine* command_line) {
const bool unattended = (getenv("CHROME_HEADLESS") != NULL);
if (unattended || GoogleUpdateSettings::GetCollectStatsConsent()) {
command_line->AppendSwitchWithValue(switches::kEnableCrashReporter,
- ASCIIToWide(google_update::linux_guid +
+ ASCIIToWide(google_update::posix_guid +
"," +
base::GetLinuxDistro()));
}
#elif defined(OS_MACOSX)
if (GoogleUpdateSettings::GetCollectStatsConsent())
- command_line->AppendSwitch(switches::kEnableCrashReporter);
+ command_line->AppendSwitchWithValue(switches::kEnableCrashReporter,
+ ASCIIToWide(google_update::posix_guid));
#endif // OS_MACOSX
}
diff --git a/chrome/common/child_process_logging.h b/chrome/common/child_process_logging.h
index 7d1f16f..aa336af 100644
--- a/chrome/common/child_process_logging.h
+++ b/chrome/common/child_process_logging.h
@@ -14,6 +14,9 @@ namespace child_process_logging {
// the URL.
void SetActiveURL(const GURL& url);
+// Sets the Client ID that is used as GUID if a Chrome process crashes.
+void SetClientId(const std::string& client_id);
+
// Simple wrapper class that sets the active URL in it's constructor and clears
// the active URL in the destructor.
class ScopedActiveURLSetter {
diff --git a/chrome/common/child_process_logging_linux.cc b/chrome/common/child_process_logging_linux.cc
index 59b16f6..9b51303 100644
--- a/chrome/common/child_process_logging_linux.cc
+++ b/chrome/common/child_process_logging_linux.cc
@@ -7,6 +7,8 @@
#include <string>
#include "base/logging.h"
+#include "base/string_util.h"
+#include "chrome/installer/util/google_update_settings.h"
#include "googleurl/src/gurl.h"
namespace child_process_logging {
@@ -19,4 +21,14 @@ void SetActiveURL(const GURL& url) {
active_url = url.possibly_invalid_spec();
}
+void SetClientId(const std::string& client_id) {
+ std::string str(client_id);
+ ReplaceSubstringsAfterOffset(&str, 0, "-", "");
+
+ if (str.empty())
+ return;
+
+ std::wstring wstr = ASCIIToWide(str);
+ GoogleUpdateSettings::SetMetricsId(wstr);
+}
} // namespace child_process_logging
diff --git a/chrome/common/child_process_logging_mac.mm b/chrome/common/child_process_logging_mac.mm
index e863239..9e89c01 100644
--- a/chrome/common/child_process_logging_mac.mm
+++ b/chrome/common/child_process_logging_mac.mm
@@ -7,6 +7,7 @@
#import <Foundation/Foundation.h>
#include "base/string_util.h"
+#include "chrome/installer/util/google_update_settings.h"
#include "googleurl/src/gurl.h"
namespace child_process_logging {
@@ -14,6 +15,7 @@ namespace child_process_logging {
const int kMaxNumCrashURLChunks = 8;
const int kMaxNumURLChunkValueLength = 255;
const char *kUrlChunkFormatStr = "url-chunk-%d";
+const char *kGuidParamName = "guid";
static SetCrashKeyValueFuncPtr g_set_key_func;
static ClearCrashKeyValueFuncPtr g_clear_key_func;
@@ -67,9 +69,26 @@ void SetActiveURLImpl(const GURL& url,
}
}
+void SetClientIdImpl(const std::string& client_id,
+ SetCrashKeyValueFuncPtr set_key_func) {
+ NSString *key = [NSString stringWithUTF8String:kGuidParamName];
+ NSString *value = [NSString stringWithUTF8String:client_id.c_str()];
+ set_key_func(key, value);
+}
+
void SetActiveURL(const GURL& url) {
if (g_set_key_func && g_clear_key_func)
SetActiveURLImpl(url, g_set_key_func, g_clear_key_func);
}
+void SetClientId(const std::string& client_id) {
+ std::string str(client_id);
+ ReplaceSubstringsAfterOffset(&str, 0, "-", "");
+
+ if (g_set_key_func)
+ SetClientIdImpl(str, g_set_key_func);
+
+ std::wstring wstr = ASCIIToWide(str);
+ GoogleUpdateSettings::SetMetricsId(wstr);
+}
} // namespace child_process_logging
diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc
index e8ddd02..94b77d8 100644
--- a/chrome/common/child_process_logging_win.cc
+++ b/chrome/common/child_process_logging_win.cc
@@ -8,12 +8,16 @@
#include "base/string_util.h"
#include "chrome/common/chrome_constants.h"
+#include "chrome/installer/util/google_update_settings.h"
#include "googleurl/src/gurl.h"
namespace child_process_logging {
// exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL.
typedef void (__cdecl *MainSetActiveURL)(const wchar_t*);
+// exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetClientId.
+typedef void (__cdecl *MainSetClientId)(const wchar_t*);
+
void SetActiveURL(const GURL& url) {
static MainSetActiveURL set_active_url = NULL;
// note: benign race condition on set_active_url.
@@ -30,4 +34,31 @@ void SetActiveURL(const GURL& url) {
(set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str());
}
+void SetClientId(const std::string& client_id) {
+ std::string str(client_id);
+ // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY.
+ ReplaceSubstringsAfterOffset(&str, 0, "-", "");
+
+ if (str.empty())
+ return;
+
+ std::wstring wstr = ASCIIToWide(str);
+ std::wstring old_wstr;
+ if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) ||
+ wstr != old_wstr)
+ GoogleUpdateSettings::SetMetricsId(wstr);
+
+ static MainSetClientId set_client_id = NULL;
+ if (!set_client_id) {
+ HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
+ if (!exe_module)
+ return;
+ set_client_id = reinterpret_cast<MainSetClientId>(
+ GetProcAddress(exe_module, "SetClientId"));
+ if (!set_client_id)
+ return;
+ }
+ (set_client_id)(wstr.c_str());
+}
+
} // namespace child_process_logging
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index a1dc297..a1dc297 100644..100755
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc