diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:31:03 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 22:31:03 +0000 |
commit | 157d547807a2b9d0e42f17636ffc39336a9a62f6 (patch) | |
tree | 9ae45f8dcd0a5298b39c44dd94d07219200e73c1 /chrome/browser/google_update_settings_posix.cc | |
parent | 23ffe4da52705ce6fd12d3aa3e178c2b5dd79598 (diff) | |
download | chromium_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/browser/google_update_settings_posix.cc')
-rwxr-xr-x[-rw-r--r--] | chrome/browser/google_update_settings_posix.cc | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/chrome/browser/google_update_settings_posix.cc b/chrome/browser/google_update_settings_posix.cc index defe492..ff5bb4c 100644..100755 --- a/chrome/browser/google_update_settings_posix.cc +++ b/chrome/browser/google_update_settings_posix.cc @@ -13,41 +13,29 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" -#if !defined(OS_MACOSX) namespace google_update { -std::string linux_guid; +std::string posix_guid; } -#endif // !OS_MACOSX // File name used in the user data dir to indicate consent. static const char kConsentToSendStats[] = "Consent To Send Stats"; -static const int kGuidLen = sizeof(uint64) * 4; // 128 bits -> 32 bytes hex. // static bool GoogleUpdateSettings::GetCollectStatsConsent() { bool forced_enable = CommandLine::ForCurrentProcess()-> HasSwitch(switches::kEnableCrashReporter); -#if defined(OS_MACOSX) - std::string linux_guid; -#else - using google_update::linux_guid; -#endif // OS_MACOSX FilePath consent_file; PathService::Get(chrome::DIR_USER_DATA, &consent_file); consent_file = consent_file.Append(kConsentToSendStats); - bool consented = file_util::ReadFileToString(consent_file, &linux_guid); - linux_guid.resize(kGuidLen, '0'); + std::string tmp_guid; + bool consented = file_util::ReadFileToString(consent_file, &tmp_guid); + if (forced_enable || consented) + google_update::posix_guid.assign(tmp_guid); return forced_enable || consented; } // static bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { -#if defined(OS_MACOSX) - std::string linux_guid; -#else - using google_update::linux_guid; -#endif // OS_MACOSX - FilePath consent_dir; PathService::Get(chrome::DIR_USER_DATA, &consent_dir); if (!file_util::DirectoryExists(consent_dir)) @@ -55,17 +43,29 @@ bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { FilePath consent_file = consent_dir.AppendASCII(kConsentToSendStats); if (consented) { - uint64 random; - linux_guid.clear(); - for (int i = 0; i < 2; i++) { - random = base::RandUint64(); - linux_guid += HexEncode(&random, sizeof(uint64)); + if ((!file_util::PathExists(consent_file)) || + (file_util::PathExists(consent_file) && + !google_update::posix_guid.empty())) { + const char* c_str = google_update::posix_guid.c_str(); + int size = google_update::posix_guid.size(); + return file_util::WriteFile(consent_file, c_str, size) == size; } - const char* c_str = linux_guid.c_str(); - return file_util::WriteFile(consent_file, c_str, kGuidLen) == kGuidLen; } else { - linux_guid .clear(); - linux_guid.resize(kGuidLen, '0'); + google_update::posix_guid.clear(); return file_util::Delete(consent_file, false); } + return true; +} + +bool GoogleUpdateSettings::SetMetricsId(const std::wstring& client_id) { + // Make sure that user has consented to send crashes. + FilePath consent_dir; + PathService::Get(chrome::DIR_USER_DATA, &consent_dir); + if (!file_util::DirectoryExists(consent_dir) || + !GoogleUpdateSettings::GetCollectStatsConsent()) + return false; + + // Since user has consented, write the metrics id to the file. + google_update::posix_guid = WideToASCII(client_id); + return GoogleUpdateSettings::SetCollectStatsConsent(true); } |