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

Unified Diff: chrome/browser/google_update_settings_linux.cc

Issue 118096: Generate GUIDs for users who wish to upload crash reports. Include it in cra... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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
« no previous file with comments | « chrome/app/breakpad_linux.cc ('k') | chrome/browser/renderer_host/render_crash_handler_host_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_update_settings_linux.cc
===================================================================
--- chrome/browser/google_update_settings_linux.cc (revision 17371)
+++ chrome/browser/google_update_settings_linux.cc (working copy)
@@ -7,17 +7,27 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/rand_util.h"
+#include "base/string_util.h"
#include "chrome/common/chrome_paths.h"
+namespace google_update {
+std::string linux_guid;
+}
+
// 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() {
FilePath consent_file;
PathService::Get(chrome::DIR_USER_DATA, &consent_file);
consent_file = consent_file.Append(kConsentToSendStats);
- return file_util::PathExists(consent_file);
+ bool r = file_util::ReadFileToString(consent_file,
+ &google_update::linux_guid);
+ google_update::linux_guid.resize(kGuidLen, '0');
+ return r;
}
// static
@@ -28,10 +38,21 @@
return false;
FilePath consent_file = consent_dir.AppendASCII(kConsentToSendStats);
- if (consented)
- return file_util::WriteFile(consent_file, "", 0) == 0;
- else
+ if (consented) {
+ uint64 random;
+ google_update::linux_guid.clear();
+ for (int i = 0; i < 2; i++) {
+ random = base::RandUint64();
+ google_update::linux_guid += HexEncode(&random, sizeof(uint64));
+ }
+ const char* c_str = google_update::linux_guid.c_str();
+ return file_util::WriteFile(consent_file, c_str, kGuidLen) == kGuidLen;
+ }
+ else {
+ google_update::linux_guid .clear();
+ google_update::linux_guid.resize(kGuidLen, '0');
return file_util::Delete(consent_file, false);
+ }
}
// static
« no previous file with comments | « chrome/app/breakpad_linux.cc ('k') | chrome/browser/renderer_host/render_crash_handler_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698