| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/sync/invalidations/invalidator_storage.h" | 5 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "sync/internal_api/public/syncable/model_type.h" | 14 #include "sync/internal_api/public/syncable/model_type.h" |
| 15 | 15 |
| 16 using csync::InvalidationVersionMap; | 16 using syncer::InvalidationVersionMap; |
| 17 | 17 |
| 18 namespace browser_sync { | 18 namespace browser_sync { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kSourceKey[] = "source"; | 22 const char kSourceKey[] = "source"; |
| 23 const char kNameKey[] = "name"; | 23 const char kNameKey[] = "name"; |
| 24 const char kMaxVersionKey[] = "max-version"; | 24 const char kMaxVersionKey[] = "max-version"; |
| 25 | 25 |
| 26 bool ValueToObjectIdAndVersion(const DictionaryValue& value, | 26 bool ValueToObjectIdAndVersion(const DictionaryValue& value, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 std::string max_version_str; | 196 std::string max_version_str; |
| 197 CHECK(max_versions_dict->GetString(*it, &max_version_str)); | 197 CHECK(max_versions_dict->GetString(*it, &max_version_str)); |
| 198 int64 max_version = 0; | 198 int64 max_version = 0; |
| 199 if (!base::StringToInt64(max_version_str, &max_version)) { | 199 if (!base::StringToInt64(max_version_str, &max_version)) { |
| 200 LOG(WARNING) << "Invalid max invalidation version for " | 200 LOG(WARNING) << "Invalid max invalidation version for " |
| 201 << syncable::ModelTypeToString(model_type) << ": " | 201 << syncable::ModelTypeToString(model_type) << ": " |
| 202 << max_version_str; | 202 << max_version_str; |
| 203 continue; | 203 continue; |
| 204 } | 204 } |
| 205 invalidation::ObjectId id; | 205 invalidation::ObjectId id; |
| 206 if (!csync::RealModelTypeToObjectId(model_type, &id)) { | 206 if (!syncer::RealModelTypeToObjectId(model_type, &id)) { |
| 207 DLOG(WARNING) << "Invalid model type: " << model_type; | 207 DLOG(WARNING) << "Invalid model type: " << model_type; |
| 208 continue; | 208 continue; |
| 209 } | 209 } |
| 210 (*map)[id] = max_version; | 210 (*map)[id] = max_version; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 std::string InvalidatorStorage::GetInvalidationState() const { | 214 std::string InvalidatorStorage::GetInvalidationState() const { |
| 215 std::string utf8_state(pref_service_ ? | 215 std::string utf8_state(pref_service_ ? |
| 216 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : ""); | 216 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : ""); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 227 utf8_state); | 227 utf8_state); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void InvalidatorStorage::Clear() { | 230 void InvalidatorStorage::Clear() { |
| 231 DCHECK(thread_checker_.CalledOnValidThread()); | 231 DCHECK(thread_checker_.CalledOnValidThread()); |
| 232 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions); | 232 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions); |
| 233 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); | 233 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace browser_sync | 236 } // namespace browser_sync |
| OLD | NEW |