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( | 98 void InvalidatorStorage::RegisterUserPrefs( |
99 user_prefs::PrefRegistrySyncable* registry) { | 99 user_prefs::PrefRegistrySyncable* registry) { |
100 registry->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, | 100 registry->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, |
101 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 101 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
102 registry->RegisterStringPref( | 102 registry->RegisterStringPref( |
103 prefs::kInvalidatorInvalidationState, | 103 prefs::kInvalidatorInvalidationState, |
104 std::string(), | 104 std::string(), |
105 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 105 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
106 registry->RegisterStringPref( | 106 registry->RegisterStringPref( |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (it == state_map.end()) | 338 if (it == state_map.end()) |
339 return; | 339 return; |
340 it->second.current = ack_handle; | 340 it->second.current = ack_handle; |
341 | 341 |
342 base::ListValue state_map_list; | 342 base::ListValue state_map_list; |
343 SerializeToList(state_map, &state_map_list); | 343 SerializeToList(state_map, &state_map_list); |
344 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, | 344 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, |
345 state_map_list); | 345 state_map_list); |
346 } | 346 } |
347 | 347 |
348 } // namespace browser_sync | 348 } // namespace invalidation |
OLD | NEW |