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

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

Issue 12847003: Separate invalidator and sync client ID (part 2/2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sync_listen_notifications utility Created 7 years, 9 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 50 void FakeInvalidationStateTracker::SetInvalidatorClientId(
51 const std::string& client_id) { 51 const std::string& client_id) {
52 Clear();
52 invalidator_client_id_ = client_id; 53 invalidator_client_id_ = client_id;
53 } 54 }
54 55
55 std::string FakeInvalidationStateTracker::GetInvalidatorClientId() const { 56 std::string FakeInvalidationStateTracker::GetInvalidatorClientId() const {
56 return invalidator_client_id_; 57 return invalidator_client_id_;
57 } 58 }
58 59
59 void FakeInvalidationStateTracker::SetBootstrapData( 60 void FakeInvalidationStateTracker::SetBootstrapData(
60 const std::string& data) { 61 const std::string& data) {
61 bootstrap_data_ = data; 62 bootstrap_data_ = data;
62 } 63 }
63 64
64 std::string FakeInvalidationStateTracker::GetBootstrapData() const { 65 std::string FakeInvalidationStateTracker::GetBootstrapData() const {
65 return bootstrap_data_; 66 return bootstrap_data_;
66 } 67 }
67 68
69 void FakeInvalidationStateTracker::Clear() {
70 invalidator_client_id_ = "";
71 state_map_ = InvalidationStateMap();
72 bootstrap_data_ = "";
73 }
74
68 void FakeInvalidationStateTracker::GenerateAckHandles( 75 void FakeInvalidationStateTracker::GenerateAckHandles(
69 const ObjectIdSet& ids, 76 const ObjectIdSet& ids,
70 const scoped_refptr<base::TaskRunner>& task_runner, 77 const scoped_refptr<base::TaskRunner>& task_runner,
71 base::Callback<void(const AckHandleMap&)> callback) { 78 base::Callback<void(const AckHandleMap&)> callback) {
72 AckHandleMap ack_handles; 79 AckHandleMap ack_handles;
73 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { 80 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) {
74 state_map_[*it].expected = AckHandle::CreateUnique(); 81 state_map_[*it].expected = AckHandle::CreateUnique();
75 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected)); 82 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected));
76 } 83 }
77 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles))) 84 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles)))
78 ADD_FAILURE(); 85 ADD_FAILURE();
79 } 86 }
80 87
81 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id, 88 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id,
82 const AckHandle& ack_handle) { 89 const AckHandle& ack_handle) {
83 InvalidationStateMap::iterator it = state_map_.find(id); 90 InvalidationStateMap::iterator it = state_map_.find(id);
84 if (it == state_map_.end()) 91 if (it == state_map_.end())
85 ADD_FAILURE(); 92 ADD_FAILURE();
86 it->second.current = ack_handle; 93 it->second.current = ack_handle;
87 } 94 }
88 95
89 } // namespace syncer 96 } // 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