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

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

Issue 10451060: sync: migrate invalidation state from syncable::Directory to InvalidationStorage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include order Created 8 years, 6 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/logging.h" 8 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
12 13
13 using sync_notifier::InvalidationVersionMap; 14 using sync_notifier::InvalidationVersionMap;
14 15
15 namespace browser_sync { 16 namespace browser_sync {
16 17
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // DictionaryValue. 109 // DictionaryValue.
109 for (InvalidationVersionMap::const_iterator it = map.begin(); 110 for (InvalidationVersionMap::const_iterator it = map.begin();
110 it != map.end(); ++it) { 111 it != map.end(); ++it) {
111 to_dict->SetString( 112 to_dict->SetString(
112 base::IntToString(it->first), 113 base::IntToString(it->first),
113 base::Int64ToString(it->second)); 114 base::Int64ToString(it->second));
114 } 115 }
115 } 116 }
116 117
117 std::string InvalidatorStorage::GetInvalidationState() const { 118 std::string InvalidatorStorage::GetInvalidationState() const {
118 DLOG(WARNING) << "TODO(tim): Wire this up. Bug 124140."; 119 std::string utf8_state(pref_service_ ?
119 return pref_service_ ? 120 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : "");
120 pref_service_->GetString(prefs::kInvalidatorInvalidationState) : ""; 121 std::string state_data;
122 base::Base64Decode(utf8_state, &state_data);
123 return state_data;
121 } 124 }
122 125
123 void InvalidatorStorage::SetInvalidationState(const std::string& state) { 126 void InvalidatorStorage::SetInvalidationState(const std::string& state) {
124 DLOG(WARNING) << "TODO(tim): Wire this up. Bug 124140.";
125 DCHECK(non_thread_safe_.CalledOnValidThread()); 127 DCHECK(non_thread_safe_.CalledOnValidThread());
128 std::string utf8_state;
129 base::Base64Encode(state, &utf8_state);
126 pref_service_->SetString(prefs::kInvalidatorInvalidationState, 130 pref_service_->SetString(prefs::kInvalidatorInvalidationState,
127 state); 131 utf8_state);
128 } 132 }
129 133
130 void InvalidatorStorage::Clear() { 134 void InvalidatorStorage::Clear() {
131 DCHECK(non_thread_safe_.CalledOnValidThread()); 135 DCHECK(non_thread_safe_.CalledOnValidThread());
132 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState); 136 pref_service_->ClearPref(prefs::kInvalidatorInvalidationState);
133 pref_service_->ClearPref(prefs::kSyncMaxInvalidationVersions); 137 pref_service_->ClearPref(prefs::kSyncMaxInvalidationVersions);
134 } 138 }
135 139
136 } // namespace browser_sync 140 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698