Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: chrome/browser/sync/invalidations/invalidator_storage.cc

Issue 12092091: Separate sync and invalidation client IDs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 : pref_service_(pref_service) { 97 : pref_service_(pref_service) {
98 // TODO(tim): Create a Mock instead of maintaining the if(!pref_service_) case 98 // TODO(tim): Create a Mock instead of maintaining the if(!pref_service_) case
99 // throughout this file. This is a problem now due to lack of injection at 99 // throughout this file. This is a problem now due to lack of injection at
100 // ProfileSyncService. Bug 130176. 100 // ProfileSyncService. Bug 130176.
101 if (pref_service_) { 101 if (pref_service_) {
102 pref_service_->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions, 102 pref_service_->RegisterListPref(prefs::kInvalidatorMaxInvalidationVersions,
103 PrefServiceSyncable::UNSYNCABLE_PREF); 103 PrefServiceSyncable::UNSYNCABLE_PREF);
104 pref_service_->RegisterStringPref(prefs::kInvalidatorInvalidationState, 104 pref_service_->RegisterStringPref(prefs::kInvalidatorInvalidationState,
105 std::string(), 105 std::string(),
106 PrefServiceSyncable::UNSYNCABLE_PREF); 106 PrefServiceSyncable::UNSYNCABLE_PREF);
107 pref_service_->RegisterStringPref(prefs::kInvalidatorInvalidatorClientId,
108 std::string(),
109 PrefServiceSyncable::UNSYNCABLE_PREF);
107 110
108 MigrateMaxInvalidationVersionsPref(); 111 MigrateMaxInvalidationVersionsPref();
109 } 112 }
110 } 113 }
111 114
112 InvalidatorStorage::~InvalidatorStorage() { 115 InvalidatorStorage::~InvalidatorStorage() {
113 } 116 }
114 117
115 InvalidationStateMap InvalidatorStorage::GetAllInvalidationStates() const { 118 InvalidationStateMap InvalidatorStorage::GetAllInvalidationStates() const {
116 DCHECK(thread_checker_.CalledOnValidThread()); 119 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 252 }
250 invalidation::ObjectId id; 253 invalidation::ObjectId id;
251 if (!syncer::RealModelTypeToObjectId(model_type, &id)) { 254 if (!syncer::RealModelTypeToObjectId(model_type, &id)) {
252 DLOG(WARNING) << "Invalid model type: " << model_type; 255 DLOG(WARNING) << "Invalid model type: " << model_type;
253 continue; 256 continue;
254 } 257 }
255 (*map)[id].version = max_version; 258 (*map)[id].version = max_version;
256 } 259 }
257 } 260 }
258 261
262 void InvalidatorStorage::SetInvalidatorClientId(const std::string& client_id) {
263 DCHECK(thread_checker_.CalledOnValidThread());
264 pref_service_->SetString(prefs::kInvalidatorInvalidatorClientId, client_id);
265 }
266
267 std::string InvalidatorStorage::GetInvalidatorClientId() const {
268 return pref_service_ ?
269 pref_service_->GetString(prefs::kInvalidatorInvalidatorClientId) : "";
270 }
271
259 void InvalidatorStorage::SetBootstrapData(const std::string& data) { 272 void InvalidatorStorage::SetBootstrapData(const std::string& data) {
260 DCHECK(thread_checker_.CalledOnValidThread()); 273 DCHECK(thread_checker_.CalledOnValidThread());
261 std::string base64_data; 274 std::string base64_data;
262 base::Base64Encode(data, &base64_data); 275 base::Base64Encode(data, &base64_data);
263 pref_service_->SetString(prefs::kInvalidatorInvalidationState, 276 pref_service_->SetString(prefs::kInvalidatorInvalidationState,
264 base64_data); 277 base64_data);
265 } 278 }
266 279
267 std::string InvalidatorStorage::GetBootstrapData() const { 280 std::string InvalidatorStorage::GetBootstrapData() const {
268 std::string base64_data(pref_service_ ? 281 std::string base64_data(pref_service_ ?
269 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : ""); 282 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : "");
270 std::string data; 283 std::string data;
271 base::Base64Decode(base64_data, &data); 284 base::Base64Decode(base64_data, &data);
272 return data; 285 return data;
273 } 286 }
274 287
275 void InvalidatorStorage::Clear() { 288 void InvalidatorStorage::Clear() {
276 DCHECK(thread_checker_.CalledOnValidThread()); 289 DCHECK(thread_checker_.CalledOnValidThread());
277 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions); 290 pref_service_->ClearPref(prefs::kInvalidatorMaxInvalidationVersions);
291 pref_service_->ClearPref(prefs::kInvalidatorInvalidatorClientId);
278 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); 292 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState);
279 } 293 }
280 294
281 void InvalidatorStorage::GenerateAckHandles( 295 void InvalidatorStorage::GenerateAckHandles(
282 const syncer::ObjectIdSet& ids, 296 const syncer::ObjectIdSet& ids,
283 const scoped_refptr<base::TaskRunner>& task_runner, 297 const scoped_refptr<base::TaskRunner>& task_runner,
284 const base::Callback<void(const syncer::AckHandleMap&)> callback) { 298 const base::Callback<void(const syncer::AckHandleMap&)> callback) {
285 DCHECK(thread_checker_.CalledOnValidThread()); 299 DCHECK(thread_checker_.CalledOnValidThread());
286 CHECK(pref_service_); 300 CHECK(pref_service_);
287 InvalidationStateMap state_map = GetAllInvalidationStates(); 301 InvalidationStateMap state_map = GetAllInvalidationStates();
(...skipping 27 matching lines...) Expand all
315 return; 329 return;
316 it->second.current = ack_handle; 330 it->second.current = ack_handle;
317 331
318 base::ListValue state_map_list; 332 base::ListValue state_map_list;
319 SerializeToList(state_map, &state_map_list); 333 SerializeToList(state_map, &state_map_list);
320 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions, 334 pref_service_->Set(prefs::kInvalidatorMaxInvalidationVersions,
321 state_map_list); 335 state_map_list);
322 } 336 }
323 337
324 } // namespace browser_sync 338 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/invalidations/invalidator_storage.h ('k') | chrome/browser/sync/profile_sync_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698