| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/metrics/persisted_logs.h" | 5 #include "components/metrics/persisted_logs.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 PersistedLogs::~PersistedLogs() {} | 91 PersistedLogs::~PersistedLogs() {} |
| 92 | 92 |
| 93 void PersistedLogs::SerializeLogs() const { | 93 void PersistedLogs::SerializeLogs() const { |
| 94 ListPrefUpdate update(local_state_, pref_name_); | 94 ListPrefUpdate update(local_state_, pref_name_); |
| 95 WriteLogsToPrefList(update.Get()); | 95 WriteLogsToPrefList(update.Get()); |
| 96 | 96 |
| 97 // After writing all the logs to the new pref remove old outdated pref. | 97 // After writing all the logs to the new pref remove old outdated pref. |
| 98 // TODO(gayane): Remove when all users are migrated. crbug.com/649440 | 98 // TODO(gayane): Remove when all users are migrated. crbug.com/649440 |
| 99 if (local_state_->HasPrefPath(outdated_pref_name_)) | 99 if (outdated_pref_name_ && local_state_->HasPrefPath(outdated_pref_name_)) |
| 100 local_state_->ClearPref(outdated_pref_name_); | 100 local_state_->ClearPref(outdated_pref_name_); |
| 101 } | 101 } |
| 102 | 102 |
| 103 PersistedLogs::LogReadStatus PersistedLogs::DeserializeLogs() { | 103 PersistedLogs::LogReadStatus PersistedLogs::DeserializeLogs() { |
| 104 // TODO(gayane): Remove the code for reading logs from outdated pref when all | 104 // TODO(gayane): Remove the code for reading logs from outdated pref when all |
| 105 // users are migrated. crbug.com/649440 | 105 // users are migrated. crbug.com/649440 |
| 106 if (local_state_->HasPrefPath(outdated_pref_name_)) { | 106 if (outdated_pref_name_ && local_state_->HasPrefPath(outdated_pref_name_)) { |
| 107 return ReadLogsFromOldFormatPrefList( | 107 return ReadLogsFromOldFormatPrefList( |
| 108 *local_state_->GetList(outdated_pref_name_)); | 108 *local_state_->GetList(outdated_pref_name_)); |
| 109 } | 109 } |
| 110 return ReadLogsFromPrefList(*local_state_->GetList(pref_name_)); | 110 return ReadLogsFromPrefList(*local_state_->GetList(pref_name_)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void PersistedLogs::StoreLog(const std::string& log_data) { | 113 void PersistedLogs::StoreLog(const std::string& log_data) { |
| 114 list_.push_back(LogInfo()); | 114 list_.push_back(LogInfo()); |
| 115 list_.back().Init(metrics_.get(), | 115 list_.back().Init(metrics_.get(), |
| 116 log_data, | 116 log_data, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 !ReadBase64String(list_value, i * 2 + 1, &list_[i].hash)) { | 226 !ReadBase64String(list_value, i * 2 + 1, &list_[i].hash)) { |
| 227 list_.clear(); | 227 list_.clear(); |
| 228 return metrics_->RecordLogReadStatus(LOG_STRING_CORRUPTION); | 228 return metrics_->RecordLogReadStatus(LOG_STRING_CORRUPTION); |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 | 231 |
| 232 return metrics_->RecordLogReadStatus(RECALL_SUCCESS); | 232 return metrics_->RecordLogReadStatus(RECALL_SUCCESS); |
| 233 } | 233 } |
| 234 | 234 |
| 235 } // namespace metrics | 235 } // namespace metrics |
| OLD | NEW |