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

Side by Side Diff: sync/notifier/fake_invalidation_state_tracker.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
« no previous file with comments | « sync/notifier/fake_invalidation_state_tracker.h ('k') | sync/notifier/fake_invalidator.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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 29 matching lines...) Expand all
40 } 40 }
41 state_map_[id].version = max_version; 41 state_map_[id].version = max_version;
42 } 42 }
43 43
44 void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) { 44 void FakeInvalidationStateTracker::Forget(const ObjectIdSet& ids) {
45 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { 45 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
46 state_map_.erase(*it); 46 state_map_.erase(*it);
47 } 47 }
48 } 48 }
49 49
50 void FakeInvalidationStateTracker::SetInvalidatorClientId(
51 const std::string& client_id) {
52 invalidator_client_id_ = client_id;
53 }
54
55 std::string FakeInvalidationStateTracker::GetInvalidatorClientId() const {
56 return invalidator_client_id_;
57 }
58
50 void FakeInvalidationStateTracker::SetBootstrapData( 59 void FakeInvalidationStateTracker::SetBootstrapData(
51 const std::string& data) { 60 const std::string& data) {
52 bootstrap_data_ = data; 61 bootstrap_data_ = data;
53 } 62 }
54 63
55 std::string FakeInvalidationStateTracker::GetBootstrapData() const { 64 std::string FakeInvalidationStateTracker::GetBootstrapData() const {
56 return bootstrap_data_; 65 return bootstrap_data_;
57 } 66 }
58 67
68 void FakeInvalidationStateTracker::Clear() {
69 invalidator_client_id_ = "";
70 state_map_ = InvalidationStateMap();
71 bootstrap_data_ = "";
72 }
73
59 void FakeInvalidationStateTracker::GenerateAckHandles( 74 void FakeInvalidationStateTracker::GenerateAckHandles(
60 const ObjectIdSet& ids, 75 const ObjectIdSet& ids,
61 const scoped_refptr<base::TaskRunner>& task_runner, 76 const scoped_refptr<base::TaskRunner>& task_runner,
62 base::Callback<void(const AckHandleMap&)> callback) { 77 base::Callback<void(const AckHandleMap&)> callback) {
63 AckHandleMap ack_handles; 78 AckHandleMap ack_handles;
64 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { 79 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
65 state_map_[*it].expected = AckHandle::CreateUnique(); 80 state_map_[*it].expected = AckHandle::CreateUnique();
66 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected)); 81 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected));
67 } 82 }
68 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles))) 83 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles)))
69 ADD_FAILURE(); 84 ADD_FAILURE();
70 } 85 }
71 86
72 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id, 87 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id,
73 const AckHandle& ack_handle) { 88 const AckHandle& ack_handle) {
74 InvalidationStateMap::iterator it = state_map_.find(id); 89 InvalidationStateMap::iterator it = state_map_.find(id);
75 if (it == state_map_.end()) 90 if (it == state_map_.end())
76 ADD_FAILURE(); 91 ADD_FAILURE();
77 it->second.current = ack_handle; 92 it->second.current = ack_handle;
78 } 93 }
79 94
80 } // namespace syncer 95 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/notifier/fake_invalidation_state_tracker.h ('k') | sync/notifier/fake_invalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698