blob: cd998004b879f5c09fff28eaad33994c0111f2f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// Copyright (c) 2012 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/sessions/session_state.h"
#include <set>
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
using std::set;
using std::vector;
namespace syncer {
namespace sessions {
ConflictProgress::ConflictProgress()
: num_server_conflicting_items(0), num_hierarchy_conflicting_items(0),
num_encryption_conflicting_items(0) {
}
ConflictProgress::~ConflictProgress() {
}
bool ConflictProgress::HasSimpleConflictItem(const syncable::Id& id) const {
return simple_conflicting_item_ids_.count(id) > 0;
}
std::set<syncable::Id>::const_iterator
ConflictProgress::SimpleConflictingItemsBegin() const {
return simple_conflicting_item_ids_.begin();
}
std::set<syncable::Id>::const_iterator
ConflictProgress::SimpleConflictingItemsEnd() const {
return simple_conflicting_item_ids_.end();
}
void ConflictProgress::AddSimpleConflictingItemById(
const syncable::Id& the_id) {
simple_conflicting_item_ids_.insert(the_id);
}
void ConflictProgress::EraseSimpleConflictingItemById(
const syncable::Id& the_id) {
simple_conflicting_item_ids_.erase(the_id);
}
void ConflictProgress::AddEncryptionConflictingItemById(
const syncable::Id& the_id) {
std::pair<std::set<syncable::Id>::iterator, bool> ret =
unresolvable_conflicting_item_ids_.insert(the_id);
if (ret.second) {
num_encryption_conflicting_items++;
}
unresolvable_conflicting_item_ids_.insert(the_id);
}
void ConflictProgress::AddHierarchyConflictingItemById(
const syncable::Id& the_id) {
std::pair<std::set<syncable::Id>::iterator, bool> ret =
unresolvable_conflicting_item_ids_.insert(the_id);
if (ret.second) {
num_hierarchy_conflicting_items++;
}
}
void ConflictProgress::AddServerConflictingItemById(
const syncable::Id& the_id) {
std::pair<std::set<syncable::Id>::iterator, bool> ret =
unresolvable_conflicting_item_ids_.insert(the_id);
if (ret.second) {
num_server_conflicting_items++;
}
}
UpdateProgress::UpdateProgress() {}
UpdateProgress::~UpdateProgress() {}
void UpdateProgress::AddVerifyResult(const VerifyResult& verify_result,
const sync_pb::SyncEntity& entity) {
verified_updates_.push_back(std::make_pair(verify_result, entity));
}
void UpdateProgress::AddAppliedUpdate(const UpdateAttemptResponse& response,
const syncable::Id& id) {
applied_updates_.push_back(std::make_pair(response, id));
}
std::vector<AppliedUpdate>::iterator UpdateProgress::AppliedUpdatesBegin() {
return applied_updates_.begin();
}
std::vector<VerifiedUpdate>::const_iterator
UpdateProgress::VerifiedUpdatesBegin() const {
return verified_updates_.begin();
}
std::vector<AppliedUpdate>::const_iterator
UpdateProgress::AppliedUpdatesEnd() const {
return applied_updates_.end();
}
std::vector<VerifiedUpdate>::const_iterator
UpdateProgress::VerifiedUpdatesEnd() const {
return verified_updates_.end();
}
int UpdateProgress::SuccessfullyAppliedUpdateCount() const {
int count = 0;
for (std::vector<AppliedUpdate>::const_iterator it =
applied_updates_.begin();
it != applied_updates_.end();
++it) {
if (it->first == SUCCESS)
count++;
}
return count;
}
// Returns true if at least one update application failed due to a conflict
// during this sync cycle.
bool UpdateProgress::HasConflictingUpdates() const {
std::vector<AppliedUpdate>::const_iterator it;
for (it = applied_updates_.begin(); it != applied_updates_.end(); ++it) {
if (it->first != SUCCESS) {
return true;
}
}
return false;
}
PerModelSafeGroupState::PerModelSafeGroupState() {
}
PerModelSafeGroupState::~PerModelSafeGroupState() {
}
} // namespace sessions
} // namespace syncer
|