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

Side by Side Diff: sync/test/mock_invalidation_tracker.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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
« no previous file with comments | « sync/test/mock_invalidation_tracker.h ('k') | sync/test/null_directory_change_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "sync/test/mock_invalidation_tracker.h"
6
7 #include <stdint.h>
8
9 #include "base/logging.h"
10 #include "sync/test/trackable_mock_invalidation.h"
11
12 namespace syncer {
13
14 std::unique_ptr<TrackableMockInvalidation>
15 MockInvalidationTracker::IssueUnknownVersionInvalidation() {
16 return std::unique_ptr<TrackableMockInvalidation>(
17 new TrackableMockInvalidation(true, -1, std::string(), this, next_id_++));
18 }
19
20 std::unique_ptr<TrackableMockInvalidation>
21 MockInvalidationTracker::IssueInvalidation(int64_t version,
22 const std::string& payload) {
23 return std::unique_ptr<TrackableMockInvalidation>(
24 new TrackableMockInvalidation(false, version, payload, this, next_id_++));
25 }
26
27 MockInvalidationTracker::MockInvalidationTracker() : next_id_(0) {
28 }
29
30 MockInvalidationTracker::~MockInvalidationTracker() {
31 }
32
33 void MockInvalidationTracker::Acknowledge(int invalidation_id) {
34 acknowledged_.insert(invalidation_id);
35 }
36
37 void MockInvalidationTracker::Drop(int invalidation_id) {
38 dropped_.insert(invalidation_id);
39 }
40
41 bool MockInvalidationTracker::IsUnacked(int invalidation_id) const {
42 DCHECK_LE(invalidation_id, next_id_);
43 return !IsAcknowledged(invalidation_id) && !IsDropped(invalidation_id);
44 }
45
46 bool MockInvalidationTracker::IsAcknowledged(int invalidation_id) const {
47 DCHECK_LE(invalidation_id, next_id_);
48 return acknowledged_.find(invalidation_id) != acknowledged_.end();
49 }
50
51 bool MockInvalidationTracker::IsDropped(int invalidation_id) const {
52 DCHECK_LE(invalidation_id, next_id_);
53 return dropped_.find(invalidation_id) != dropped_.end();
54 }
55
56 bool MockInvalidationTracker::AllInvalidationsAccountedFor() const {
57 for (int i = 0; i < next_id_; ++i) {
58 if (IsUnacked(i)) {
59 return false;
60 }
61 }
62 return true;
63 }
64
65 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/test/mock_invalidation_tracker.h ('k') | sync/test/null_directory_change_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698