| 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/invalidation/invalidator_storage.h" | 5 #include "chrome/browser/invalidation/invalidator_storage.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "components/user_prefs/pref_registry_syncable.h" | 18 #include "components/user_prefs/pref_registry_syncable.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 const char kInvalidatorMaxInvalidationVersions[] = | 22 const char kInvalidatorMaxInvalidationVersions[] = |
| 23 "invalidator.max_invalidation_versions"; | 23 "invalidator.max_invalidation_versions"; |
| 24 | 24 |
| 25 | 25 |
| 26 bool ValueToUnackedInvalidationStorageMap( | 26 bool ValueToUnackedInvalidationStorageMap( |
| 27 const ListValue& value, | 27 const base::ListValue& value, |
| 28 syncer::UnackedInvalidationsMap* map) { | 28 syncer::UnackedInvalidationsMap* map) { |
| 29 for (size_t i = 0; i != value.GetSize(); ++i) { | 29 for (size_t i = 0; i != value.GetSize(); ++i) { |
| 30 invalidation::ObjectId invalid_id; | 30 invalidation::ObjectId invalid_id; |
| 31 syncer::UnackedInvalidationSet storage(invalid_id); | 31 syncer::UnackedInvalidationSet storage(invalid_id); |
| 32 const base::DictionaryValue* dict; | 32 const base::DictionaryValue* dict; |
| 33 if (!value.GetDictionary(i, &dict) || !storage.ResetFromValue(*dict)) { | 33 if (!value.GetDictionary(i, &dict) || !storage.ResetFromValue(*dict)) { |
| 34 DLOG(WARNING) << "Failed to parse ObjectState at position " << i; | 34 DLOG(WARNING) << "Failed to parse ObjectState at position " << i; |
| 35 return false; | 35 return false; |
| 36 } | 36 } |
| 37 map->insert(std::make_pair(storage.object_id(), storage)); | 37 map->insert(std::make_pair(storage.object_id(), storage)); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 void InvalidatorStorage::Clear() { | 129 void InvalidatorStorage::Clear() { |
| 130 DCHECK(thread_checker_.CalledOnValidThread()); | 130 DCHECK(thread_checker_.CalledOnValidThread()); |
| 131 pref_service_->ClearPref(prefs::kInvalidatorSavedInvalidations); | 131 pref_service_->ClearPref(prefs::kInvalidatorSavedInvalidations); |
| 132 pref_service_->ClearPref(prefs::kInvalidatorClientId); | 132 pref_service_->ClearPref(prefs::kInvalidatorClientId); |
| 133 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); | 133 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace invalidation | 136 } // namespace invalidation |
| OLD | NEW |