| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 void FakeInvalidationStateTracker::SetBootstrapData( | 59 void FakeInvalidationStateTracker::SetBootstrapData( |
| 60 const std::string& data) { | 60 const std::string& data) { |
| 61 bootstrap_data_ = data; | 61 bootstrap_data_ = data; |
| 62 } | 62 } |
| 63 | 63 |
| 64 std::string FakeInvalidationStateTracker::GetBootstrapData() const { | 64 std::string FakeInvalidationStateTracker::GetBootstrapData() const { |
| 65 return bootstrap_data_; | 65 return bootstrap_data_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void FakeInvalidationStateTracker::Clear() { |
| 69 invalidator_client_id_ = ""; |
| 70 state_map_ = InvalidationStateMap(); |
| 71 bootstrap_data_ = ""; |
| 72 } |
| 73 |
| 68 void FakeInvalidationStateTracker::GenerateAckHandles( | 74 void FakeInvalidationStateTracker::GenerateAckHandles( |
| 69 const ObjectIdSet& ids, | 75 const ObjectIdSet& ids, |
| 70 const scoped_refptr<base::TaskRunner>& task_runner, | 76 const scoped_refptr<base::TaskRunner>& task_runner, |
| 71 base::Callback<void(const AckHandleMap&)> callback) { | 77 base::Callback<void(const AckHandleMap&)> callback) { |
| 72 AckHandleMap ack_handles; | 78 AckHandleMap ack_handles; |
| 73 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { | 79 for (ObjectIdSet::const_iterator it = ids.begin(); it != ids.end(); ++it) { |
| 74 state_map_[*it].expected = AckHandle::CreateUnique(); | 80 state_map_[*it].expected = AckHandle::CreateUnique(); |
| 75 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected)); | 81 ack_handles.insert(std::make_pair(*it, state_map_[*it].expected)); |
| 76 } | 82 } |
| 77 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles))) | 83 if (!task_runner->PostTask(FROM_HERE, base::Bind(callback, ack_handles))) |
| 78 ADD_FAILURE(); | 84 ADD_FAILURE(); |
| 79 } | 85 } |
| 80 | 86 |
| 81 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id, | 87 void FakeInvalidationStateTracker::Acknowledge(const invalidation::ObjectId& id, |
| 82 const AckHandle& ack_handle) { | 88 const AckHandle& ack_handle) { |
| 83 InvalidationStateMap::iterator it = state_map_.find(id); | 89 InvalidationStateMap::iterator it = state_map_.find(id); |
| 84 if (it == state_map_.end()) | 90 if (it == state_map_.end()) |
| 85 ADD_FAILURE(); | 91 ADD_FAILURE(); |
| 86 it->second.current = ack_handle; | 92 it->second.current = ack_handle; |
| 87 } | 93 } |
| 88 | 94 |
| 89 } // namespace syncer | 95 } // namespace syncer |
| OLD | NEW |