| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/invalidation/mock_ack_handler.h" | 5 #include "components/invalidation/mock_ack_handler.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "components/invalidation/ack_handle.h" | 8 #include "components/invalidation/ack_handle.h" |
| 9 #include "components/invalidation/invalidation.h" | 9 #include "components/invalidation/invalidation.h" |
| 10 | 10 |
| 11 namespace syncer { | 11 namespace syncer { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 struct AckHandleMatcher { | 15 struct AckHandleMatcher { |
| 16 AckHandleMatcher(const AckHandle& handle); | 16 AckHandleMatcher(const AckHandle& handle); |
| 17 bool operator()(const syncer::Invalidation& invalidation) const; | 17 bool operator()(const syncer::Invalidation& invalidation) const; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 MockAckHandler::MockAckHandler() {} | 32 MockAckHandler::MockAckHandler() {} |
| 33 | 33 |
| 34 MockAckHandler::~MockAckHandler() {} | 34 MockAckHandler::~MockAckHandler() {} |
| 35 | 35 |
| 36 void MockAckHandler::RegisterInvalidation(Invalidation* invalidation) { | 36 void MockAckHandler::RegisterInvalidation(Invalidation* invalidation) { |
| 37 unacked_invalidations_.push_back(*invalidation); | 37 unacked_invalidations_.push_back(*invalidation); |
| 38 invalidation->SetAckHandler(AsWeakPtr(), base::MessageLoopProxy::current()); | 38 invalidation->SetAckHandler(AsWeakPtr(), base::ThreadTaskRunnerHandle::Get()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void MockAckHandler::RegisterUnsentInvalidation(Invalidation* invalidation) { | 41 void MockAckHandler::RegisterUnsentInvalidation(Invalidation* invalidation) { |
| 42 unsent_invalidations_.push_back(*invalidation); | 42 unsent_invalidations_.push_back(*invalidation); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool MockAckHandler::IsUnacked(const Invalidation& invalidation) const { | 45 bool MockAckHandler::IsUnacked(const Invalidation& invalidation) const { |
| 46 AckHandleMatcher matcher(invalidation.ack_handle()); | 46 AckHandleMatcher matcher(invalidation.ack_handle()); |
| 47 InvalidationVector::const_iterator it = std::find_if( | 47 InvalidationVector::const_iterator it = std::find_if( |
| 48 unacked_invalidations_.begin(), | 48 unacked_invalidations_.begin(), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 matcher); | 111 matcher); |
| 112 if (it != unacked_invalidations_.end()) { | 112 if (it != unacked_invalidations_.end()) { |
| 113 dropped_invalidations_.push_back(*it); | 113 dropped_invalidations_.push_back(*it); |
| 114 unacked_invalidations_.erase(it); | 114 unacked_invalidations_.erase(it); |
| 115 } | 115 } |
| 116 unrecovered_drop_events_.erase(id); | 116 unrecovered_drop_events_.erase(id); |
| 117 unrecovered_drop_events_.insert(std::make_pair(id, handle)); | 117 unrecovered_drop_events_.insert(std::make_pair(id, handle)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace syncer | 120 } // namespace syncer |
| OLD | NEW |