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

Side by Side Diff: sync/notifier/fake_invalidation_state_tracker.cc

Issue 11229015: Add the InvalidationState struct to bundle local state about invalidations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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
« no previous file with comments | « sync/notifier/fake_invalidation_state_tracker.h ('k') | sync/notifier/invalidation_notifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "sync/notifier/fake_invalidation_state_tracker.h" 5 #include "sync/notifier/fake_invalidation_state_tracker.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace syncer { 9 namespace syncer {
10 10
11 const int64 FakeInvalidationStateTracker::kMinVersion = kint64min; 11 const int64 FakeInvalidationStateTracker::kMinVersion = kint64min;
12 12
13 FakeInvalidationStateTracker::FakeInvalidationStateTracker() {} 13 FakeInvalidationStateTracker::FakeInvalidationStateTracker() {}
14 14
15 FakeInvalidationStateTracker::~FakeInvalidationStateTracker() {} 15 FakeInvalidationStateTracker::~FakeInvalidationStateTracker() {}
16 16
17 int64 FakeInvalidationStateTracker::GetMaxVersion( 17 int64 FakeInvalidationStateTracker::GetMaxVersion(
18 const invalidation::ObjectId& id) const { 18 const invalidation::ObjectId& id) const {
19 InvalidationVersionMap::const_iterator it = versions_.find(id); 19 InvalidationStateMap::const_iterator it = state_map_.find(id);
20 return (it == versions_.end()) ? kMinVersion : it->second; 20 return (it == state_map_.end()) ? kMinVersion : it->second.version;
21 } 21 }
22 22
23 InvalidationVersionMap 23 InvalidationStateMap
24 FakeInvalidationStateTracker::GetAllMaxVersions() const { 24 FakeInvalidationStateTracker::GetAllInvalidationStates() const {
25 return versions_; 25 return state_map_;
26 } 26 }
27 27
28 void FakeInvalidationStateTracker::SetMaxVersion( 28 void FakeInvalidationStateTracker::SetMaxVersion(
29 const invalidation::ObjectId& id, int64 max_version) { 29 const invalidation::ObjectId& id, int64 max_version) {
30 InvalidationVersionMap::const_iterator it = versions_.find(id); 30 InvalidationStateMap::const_iterator it = state_map_.find(id);
31 if ((it != versions_.end()) && (max_version <= it->second)) { 31 if ((it != state_map_.end()) && (max_version <= it->second.version)) {
32 ADD_FAILURE(); 32 ADD_FAILURE();
33 return; 33 return;
34 } 34 }
35 versions_[id] = max_version; 35 state_map_[id].version = max_version;
36 } 36 }
37 37
38 void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) { 38 void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) {
39 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { 39 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
40 versions_.erase(*it); 40 state_map_.erase(*it);
41 } 41 }
42 } 42 }
43 43
44 void FakeInvalidationStateTracker::SetBootstrapData( 44 void FakeInvalidationStateTracker::SetBootstrapData(
45 const std::string& data) { 45 const std::string& data) {
46 bootstrap_data_ = data; 46 bootstrap_data_ = data;
47 } 47 }
48 48
49 std::string FakeInvalidationStateTracker::GetBootstrapData() const { 49 std::string FakeInvalidationStateTracker::GetBootstrapData() const {
50 return bootstrap_data_; 50 return bootstrap_data_;
51 } 51 }
52 52
53 } // namespace syncer 53 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/fake_invalidation_state_tracker.h ('k') | sync/notifier/invalidation_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698