| OLD | NEW |
| 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 Loading... |
| 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::RetrieveMetricsID(std::string* metrics_id) { | 70 // TODO(gab): Implement |installation_date| saving/retrieval on POSIX. |
| 71 bool GoogleUpdateSettings::RetrieveMetricsInfo(std::string* metrics_id, |
| 72 int64* /* installation_date */) { |
| 71 base::AutoLock lock(g_posix_client_id_lock.Get()); | 73 base::AutoLock lock(g_posix_client_id_lock.Get()); |
| 72 *metrics_id = g_posix_client_id.Get(); | 74 *metrics_id = g_posix_client_id.Get(); |
| 73 return true; | 75 return true; |
| 74 } | 76 } |
| 75 | 77 |
| 76 // static | 78 // static |
| 77 bool GoogleUpdateSettings::SaveMetricsID(const std::string& client_id) { | 79 // TODO(gab): Implement |installation_date| saving/retrieval on POSIX. |
| 80 bool GoogleUpdateSettings::SaveMetricsInfo( |
| 81 const std::string& client_id, |
| 82 const base::Time& /* installation_date */) { |
| 78 // Make sure that user has consented to send crashes. | 83 // Make sure that user has consented to send crashes. |
| 79 if (!GoogleUpdateSettings::GetCollectStatsConsent()) | 84 if (!GoogleUpdateSettings::GetCollectStatsConsent()) |
| 80 return false; | 85 return false; |
| 81 | 86 |
| 82 { | 87 { |
| 83 // Since user has consented, write the metrics id to the file. | 88 // Since user has consented, write the metrics id to the file. |
| 84 base::AutoLock lock(g_posix_client_id_lock.Get()); | 89 base::AutoLock lock(g_posix_client_id_lock.Get()); |
| 85 g_posix_client_id.Get() = client_id; | 90 g_posix_client_id.Get() = client_id; |
| 86 } | 91 } |
| 87 return GoogleUpdateSettings::SetCollectStatsConsent(true); | 92 return GoogleUpdateSettings::SetCollectStatsConsent(true); |
| 88 } | 93 } |
| 89 | 94 |
| 90 // GetLastRunTime and SetLastRunTime are not implemented for posix. Their | 95 // GetLastRunTime and SetLastRunTime are not implemented for posix. Their |
| 91 // current return values signal failure which the caller is designed to | 96 // current return values signal failure which the caller is designed to |
| 92 // handle. | 97 // handle. |
| 93 | 98 |
| 94 // static | 99 // static |
| 95 int GoogleUpdateSettings::GetLastRunTime() { | 100 int GoogleUpdateSettings::GetLastRunTime() { |
| 96 return -1; | 101 return -1; |
| 97 } | 102 } |
| 98 | 103 |
| 99 // static | 104 // static |
| 100 bool GoogleUpdateSettings::SetLastRunTime() { | 105 bool GoogleUpdateSettings::SetLastRunTime() { |
| 101 return false; | 106 return false; |
| 102 } | 107 } |
| OLD | NEW |