| Index: sync/test/mock_invalidation_tracker.cc
|
| diff --git a/sync/test/mock_invalidation_tracker.cc b/sync/test/mock_invalidation_tracker.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6e816a63e1694f80440a0c79a6b64d5c4eb754db
|
| --- /dev/null
|
| +++ b/sync/test/mock_invalidation_tracker.cc
|
| @@ -0,0 +1,63 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "sync/test/mock_invalidation_tracker.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "sync/test/trackable_mock_invalidation.h"
|
| +
|
| +namespace syncer {
|
| +
|
| +scoped_ptr<TrackableMockInvalidation>
|
| +MockInvalidationTracker::IssueUnknownVersionInvalidation() {
|
| + return scoped_ptr<TrackableMockInvalidation>(
|
| + new TrackableMockInvalidation(true, -1, std::string(), this, next_id_++));
|
| +}
|
| +
|
| +scoped_ptr<TrackableMockInvalidation>
|
| +MockInvalidationTracker::IssueInvalidation(int64 version,
|
| + const std::string& payload) {
|
| + return scoped_ptr<TrackableMockInvalidation>(
|
| + new TrackableMockInvalidation(false, version, payload, this, next_id_++));
|
| +}
|
| +
|
| +MockInvalidationTracker::MockInvalidationTracker() : next_id_(0) {
|
| +}
|
| +
|
| +MockInvalidationTracker::~MockInvalidationTracker() {
|
| +}
|
| +
|
| +void MockInvalidationTracker::Acknowledge(int invalidation_id) {
|
| + acknowledged_.insert(invalidation_id);
|
| +}
|
| +
|
| +void MockInvalidationTracker::Drop(int invalidation_id) {
|
| + dropped_.insert(invalidation_id);
|
| +}
|
| +
|
| +bool MockInvalidationTracker::IsUnacked(int invalidation_id) const {
|
| + DCHECK_LE(invalidation_id, next_id_);
|
| + return !IsAcknowledged(invalidation_id) && !IsDropped(invalidation_id);
|
| +}
|
| +
|
| +bool MockInvalidationTracker::IsAcknowledged(int invalidation_id) const {
|
| + DCHECK_LE(invalidation_id, next_id_);
|
| + return acknowledged_.find(invalidation_id) != acknowledged_.end();
|
| +}
|
| +
|
| +bool MockInvalidationTracker::IsDropped(int invalidation_id) const {
|
| + DCHECK_LE(invalidation_id, next_id_);
|
| + return dropped_.find(invalidation_id) != dropped_.end();
|
| +}
|
| +
|
| +bool MockInvalidationTracker::AllInvalidationsAccountedFor() const {
|
| + for (int i = 0; i < next_id_; ++i) {
|
| + if (IsUnacked(i)) {
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +} // namespace syncer
|
|
|