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

Side by Side Diff: sync/sessions/session_state.h

Issue 11190013: sync: Remove UpdateProgress and related code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Formatting improvements Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « sync/engine/update_applicator.cc ('k') | sync/sessions/session_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The 'sessions' namespace comprises all the pieces of state that are 5 // The 'sessions' namespace comprises all the pieces of state that are
6 // combined to form a SyncSession instance. In that way, it can be thought of 6 // combined to form a SyncSession instance. In that way, it can be thought of
7 // as an extension of the SyncSession type itself. Session scoping gives 7 // as an extension of the SyncSession type itself. Session scoping gives
8 // context to things like "conflict progress", "update progress", etc, and the 8 // context to things like "conflict progress", "update progress", etc, and the
9 // separation this file provides allows clients to only include the parts they 9 // separation this file provides allows clients to only include the parts they
10 // need rather than the entire session stack. 10 // need rather than the entire session stack.
11 11
12 #ifndef SYNC_SESSIONS_SESSION_STATE_H_ 12 #ifndef SYNC_SESSIONS_SESSION_STATE_H_
13 #define SYNC_SESSIONS_SESSION_STATE_H_ 13 #define SYNC_SESSIONS_SESSION_STATE_H_
14 14
15 #include <set> 15 #include <set>
16 #include <vector>
17 16
18 #include "sync/engine/syncer_types.h"
19 #include "sync/protocol/sync.pb.h"
20 #include "sync/syncable/syncable_id.h" 17 #include "sync/syncable/syncable_id.h"
21 18
22 namespace syncer { 19 namespace syncer {
23 namespace sessions { 20 namespace sessions {
24 21
25 typedef std::pair<VerifyResult, sync_pb::SyncEntity> VerifiedUpdate;
26 typedef std::pair<UpdateAttemptResponse, syncable::Id> AppliedUpdate;
27
28 // Tracks update application and verification.
29 class UpdateProgress {
30 public:
31 UpdateProgress();
32 ~UpdateProgress();
33
34 void AddVerifyResult(const VerifyResult& verify_result,
35 const sync_pb::SyncEntity& entity);
36
37 // Log a successful or failing update attempt.
38 void AddAppliedUpdate(const UpdateAttemptResponse& response,
39 const syncable::Id& id);
40
41 // Various iterators.
42 std::vector<AppliedUpdate>::iterator AppliedUpdatesBegin();
43 std::vector<VerifiedUpdate>::const_iterator VerifiedUpdatesBegin() const;
44 std::vector<AppliedUpdate>::const_iterator AppliedUpdatesEnd() const;
45 std::vector<VerifiedUpdate>::const_iterator VerifiedUpdatesEnd() const;
46
47 // Returns the number of update application attempts. This includes both
48 // failures and successes.
49 int AppliedUpdatesSize() const { return applied_updates_.size(); }
50 int VerifiedUpdatesSize() const { return verified_updates_.size(); }
51 bool HasVerifiedUpdates() const { return !verified_updates_.empty(); }
52 bool HasAppliedUpdates() const { return !applied_updates_.empty(); }
53 void ClearVerifiedUpdates() { verified_updates_.clear(); }
54
55 // Count the number of successful update applications that have happend this
56 // cycle. Note that if an item is successfully applied twice, it will be
57 // double counted here.
58 int SuccessfullyAppliedUpdateCount() const;
59
60 // Returns true if at least one update application failed due to a conflict
61 // during this sync cycle.
62 bool HasConflictingUpdates() const;
63
64 private:
65 // Container for updates that passed verification.
66 std::vector<VerifiedUpdate> verified_updates_;
67
68 // Stores the result of the various ApplyUpdate attempts we've made.
69 // May contain duplicate entries.
70 std::vector<AppliedUpdate> applied_updates_;
71 };
72
73 // Grouping of all state that applies to a single ModelSafeGroup. 22 // Grouping of all state that applies to a single ModelSafeGroup.
74 struct PerModelSafeGroupState { 23 struct PerModelSafeGroupState {
75 explicit PerModelSafeGroupState(); 24 explicit PerModelSafeGroupState();
76 ~PerModelSafeGroupState(); 25 ~PerModelSafeGroupState();
77 26
78 UpdateProgress update_progress;
79 std::set<syncable::Id> simple_conflict_ids; 27 std::set<syncable::Id> simple_conflict_ids;
80 }; 28 };
81 29
82 } // namespace sessions 30 } // namespace sessions
83 } // namespace syncer 31 } // namespace syncer
84 32
85 #endif // SYNC_SESSIONS_SESSION_STATE_H_ 33 #endif // SYNC_SESSIONS_SESSION_STATE_H_
OLDNEW
« no previous file with comments | « sync/engine/update_applicator.cc ('k') | sync/sessions/session_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698