| 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/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 #include "sync/internal_api/public/base/model_type.h" | 19 #include "sync/internal_api/public/base/model_type.h" |
| 20 | 20 |
| 21 using syncer::InvalidationStateMap; | 21 using syncer::InvalidationStateMap; |
| 22 | 22 |
| 23 namespace browser_sync { | |
| 24 | |
| 25 namespace { | 23 namespace { |
| 26 | 24 |
| 27 const char kSourceKey[] = "source"; | 25 const char kSourceKey[] = "source"; |
| 28 const char kNameKey[] = "name"; | 26 const char kNameKey[] = "name"; |
| 29 const char kMaxVersionKey[] = "max-version"; | 27 const char kMaxVersionKey[] = "max-version"; |
| 30 const char kPayloadKey[] = "payload"; | 28 const char kPayloadKey[] = "payload"; |
| 31 const char kCurrentAckHandleKey[] = "current-ack"; | 29 const char kCurrentAckHandleKey[] = "current-ack"; |
| 32 const char kExpectedAckHandleKey[] = "expected-ack"; | 30 const char kExpectedAckHandleKey[] = "expected-ack"; |
| 33 | 31 |
| 34 bool ValueToObjectIdAndState(const DictionaryValue& value, | 32 bool ValueToObjectIdAndState(const DictionaryValue& value, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 value->SetString(kPayloadKey, state.payload); | 85 value->SetString(kPayloadKey, state.payload); |
| 88 if (state.current.IsValid()) | 86 if (state.current.IsValid()) |
| 89 value->Set(kCurrentAckHandleKey, state.current.ToValue().release()); | 87 value->Set(kCurrentAckHandleKey, state.current.ToValue().release()); |
| 90 if (state.expected.IsValid()) | 88 if (state.expected.IsValid()) |
| 91 value->Set(kExpectedAckHandleKey, state.expected.ToValue().release()); | 89 value->Set(kExpectedAckHandleKey, state.expected.ToValue().release()); |
| 92 return value; | 90 return value; |
| 93 } | 91 } |
| 94 | 92 |
| 95 } // namespace | 93 } // namespace |
| 96 | 94 |
| 95 namespace invalidation { |
| 96 |
| 97 // static | 97 // static |
| 98 void InvalidatorStorage::RegisterUserPrefs(PrefRegistrySyncable* registry) { | 98 void InvalidatorStorage::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
| 99 registry->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, | 99 registry->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, |
| 100 PrefRegistrySyncable::UNSYNCABLE_PREF); | 100 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 101 registry->RegisterStringPref(prefs::kInvalidatorInvalidationState, | 101 registry->RegisterStringPref(prefs::kInvalidatorInvalidationState, |
| 102 std::string(), | 102 std::string(), |
| 103 PrefRegistrySyncable::UNSYNCABLE_PREF); | 103 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 104 registry->RegisterStringPref(prefs::kInvalidatorClientId, | 104 registry->RegisterStringPref(prefs::kInvalidatorClientId, |
| 105 std::string(), | 105 std::string(), |
| 106 PrefRegistrySyncable::UNSYNCABLE_PREF); | 106 PrefRegistrySyncable::UNSYNCABLE_PREF); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 if (it == state_map.end()) | 334 if (it == state_map.end()) |
| 335 return; | 335 return; |
| 336 it->second.current = ack_handle; | 336 it->second.current = ack_handle; |
| 337 | 337 |
| 338 base::ListValue state_map_list; | 338 base::ListValue state_map_list; |
| 339 SerializeToList(state_map, &state_map_list); | 339 SerializeToList(state_map, &state_map_list); |
| 340 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, | 340 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, |
| 341 state_map_list); | 341 state_map_list); |
| 342 } | 342 } |
| 343 | 343 |
| 344 } // namespace browser_sync | 344 } // namespace invalidation |
| OLD | NEW |