Update V8 to version 4.7.58.
[chromium-blink-merge.git] / sync / test / mock_invalidation_tracker.cc
blob6e816a63e1694f80440a0c79a6b64d5c4eb754db
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
3 // found in the LICENSE file.
5 #include "sync/test/mock_invalidation_tracker.h"
7 #include "base/logging.h"
8 #include "sync/test/trackable_mock_invalidation.h"
10 namespace syncer {
12 scoped_ptr<TrackableMockInvalidation>
13 MockInvalidationTracker::IssueUnknownVersionInvalidation() {
14 return scoped_ptr<TrackableMockInvalidation>(
15 new TrackableMockInvalidation(true, -1, std::string(), this, next_id_++));
18 scoped_ptr<TrackableMockInvalidation>
19 MockInvalidationTracker::IssueInvalidation(int64 version,
20 const std::string& payload) {
21 return scoped_ptr<TrackableMockInvalidation>(
22 new TrackableMockInvalidation(false, version, payload, this, next_id_++));
25 MockInvalidationTracker::MockInvalidationTracker() : next_id_(0) {
28 MockInvalidationTracker::~MockInvalidationTracker() {
31 void MockInvalidationTracker::Acknowledge(int invalidation_id) {
32 acknowledged_.insert(invalidation_id);
35 void MockInvalidationTracker::Drop(int invalidation_id) {
36 dropped_.insert(invalidation_id);
39 bool MockInvalidationTracker::IsUnacked(int invalidation_id) const {
40 DCHECK_LE(invalidation_id, next_id_);
41 return !IsAcknowledged(invalidation_id) && !IsDropped(invalidation_id);
44 bool MockInvalidationTracker::IsAcknowledged(int invalidation_id) const {
45 DCHECK_LE(invalidation_id, next_id_);
46 return acknowledged_.find(invalidation_id) != acknowledged_.end();
49 bool MockInvalidationTracker::IsDropped(int invalidation_id) const {
50 DCHECK_LE(invalidation_id, next_id_);
51 return dropped_.find(invalidation_id) != dropped_.end();
54 bool MockInvalidationTracker::AllInvalidationsAccountedFor() const {
55 for (int i = 0; i < next_id_; ++i) {
56 if (IsUnacked(i)) {
57 return false;
60 return true;
63 } // namespace syncer