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

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

Issue 10824140: Add InvalidationStateTracker::Forget() to erase an entry from storage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_client target Created 8 years, 3 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 "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(
18 const invalidation::ObjectId& id) const {
19 InvalidationVersionMap::const_iterator it = versions_.find(id);
20 return (it == versions_.end()) ? kMinVersion : it->second;
21 }
22
17 InvalidationVersionMap 23 InvalidationVersionMap
18 FakeInvalidationStateTracker::GetAllMaxVersions() const { 24 FakeInvalidationStateTracker::GetAllMaxVersions() const {
19 return versions_; 25 return versions_;
20 } 26 }
21 27
22 void FakeInvalidationStateTracker::SetMaxVersion( 28 void FakeInvalidationStateTracker::SetMaxVersion(
23 const invalidation::ObjectId& id, int64 max_version) { 29 const invalidation::ObjectId& id, int64 max_version) {
24 InvalidationVersionMap::const_iterator it = versions_.find(id); 30 InvalidationVersionMap::const_iterator it = versions_.find(id);
25 if ((it != versions_.end()) && (max_version <= it->second)) { 31 if ((it != versions_.end()) && (max_version <= it->second)) {
26 ADD_FAILURE(); 32 ADD_FAILURE();
27 return; 33 return;
28 } 34 }
29 versions_[id] = max_version; 35 versions_[id] = max_version;
30 } 36 }
31 37
32 int64 FakeInvalidationStateTracker::GetMaxVersion( 38 void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) {
33 const invalidation::ObjectId& id) const { 39 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
34 InvalidationVersionMap::const_iterator it = versions_.find(id); 40 versions_.erase(*it);
35 return (it == versions_.end()) ? kMinVersion : it->second; 41 }
36 } 42 }
37 43
38 void FakeInvalidationStateTracker::SetInvalidationState( 44 void FakeInvalidationStateTracker::SetInvalidationState(
39 const std::string& state) { 45 const std::string& state) {
40 state_ = state; 46 state_ = state;
41 } 47 }
42 48
43 std::string FakeInvalidationStateTracker::GetInvalidationState() const { 49 std::string FakeInvalidationStateTracker::GetInvalidationState() const {
44 return state_; 50 return state_;
45 } 51 }
46 52
47 } // namespace syncer 53 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/fake_invalidation_state_tracker.h ('k') | sync/notifier/invalidation_state_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698