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

Side by Side Diff: chrome/browser/google/google_update_settings_posix.cc

Issue 372473004: Retrieve client_id from GoogleUpdateSettings when its missing from Local State. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put dependency back for installer_util_nacl_win64 fixes compile?! Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/installer/util/google_update_settings.h" 5 #include "chrome/installer/util/google_update_settings.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 return base::WriteFile(consent_file, c_str, size) == size; 60 return base::WriteFile(consent_file, c_str, size) == size;
61 } 61 }
62 } else { 62 } else {
63 g_posix_client_id.Get().clear(); 63 g_posix_client_id.Get().clear();
64 return base::DeleteFile(consent_file, false); 64 return base::DeleteFile(consent_file, false);
65 } 65 }
66 return true; 66 return true;
67 } 67 }
68 68
69 // static 69 // static
70 bool GoogleUpdateSettings::LoadMetricsClientId(std::string* metrics_id) { 70 // TODO(gab): Implement storing/loading for all ClientInfo fields on POSIX.
71 scoped_ptr<metrics::ClientInfo> GoogleUpdateSettings::LoadMetricsClientInfo() {
72 scoped_ptr<metrics::ClientInfo> client_info(new metrics::ClientInfo);
73
71 base::AutoLock lock(g_posix_client_id_lock.Get()); 74 base::AutoLock lock(g_posix_client_id_lock.Get());
72 *metrics_id = g_posix_client_id.Get(); 75 if (g_posix_client_id.Get().empty())
73 return true; 76 return scoped_ptr<metrics::ClientInfo>();
77 client_info->client_id = g_posix_client_id.Get();
78
79 return client_info.Pass();
74 } 80 }
75 81
76 // static 82 // static
77 bool GoogleUpdateSettings::StoreMetricsClientId(const std::string& client_id) { 83 // TODO(gab): Implement storing/loading for all ClientInfo fields on POSIX.
84 void GoogleUpdateSettings::StoreMetricsClientInfo(
85 const metrics::ClientInfo& client_info) {
78 // Make sure that user has consented to send crashes. 86 // Make sure that user has consented to send crashes.
79 if (!GoogleUpdateSettings::GetCollectStatsConsent()) 87 if (!GoogleUpdateSettings::GetCollectStatsConsent())
80 return false; 88 return;
81 89
82 { 90 {
83 // Since user has consented, write the metrics id to the file. 91 // Since user has consented, write the metrics id to the file.
84 base::AutoLock lock(g_posix_client_id_lock.Get()); 92 base::AutoLock lock(g_posix_client_id_lock.Get());
85 g_posix_client_id.Get() = client_id; 93 g_posix_client_id.Get() = client_info.client_id;
86 } 94 }
87 return GoogleUpdateSettings::SetCollectStatsConsent(true); 95 GoogleUpdateSettings::SetCollectStatsConsent(true);
88 } 96 }
89 97
90 // GetLastRunTime and SetLastRunTime are not implemented for posix. Their 98 // GetLastRunTime and SetLastRunTime are not implemented for posix. Their
91 // current return values signal failure which the caller is designed to 99 // current return values signal failure which the caller is designed to
92 // handle. 100 // handle.
93 101
94 // static 102 // static
95 int GoogleUpdateSettings::GetLastRunTime() { 103 int GoogleUpdateSettings::GetLastRunTime() {
96 return -1; 104 return -1;
97 } 105 }
98 106
99 // static 107 // static
100 bool GoogleUpdateSettings::SetLastRunTime() { 108 bool GoogleUpdateSettings::SetLastRunTime() {
101 return false; 109 return false;
102 } 110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698