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

Side by Side Diff: chrome/browser/sync/engine/get_commit_ids_command.h

Issue 9699057: [Sync] Move 'sync' target to sync/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Tim's comments Created 8 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
6 #define CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
7 #pragma once
8
9 #include <utility>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "chrome/browser/sync/engine/syncer_command.h"
14 #include "chrome/browser/sync/engine/syncer_util.h"
15 #include "chrome/browser/sync/sessions/ordered_commit_set.h"
16 #include "chrome/browser/sync/sessions/sync_session.h"
17
18 using std::pair;
19 using std::vector;
20
21 namespace browser_sync {
22
23 class GetCommitIdsCommand : public SyncerCommand {
24 friend class SyncerTest;
25
26 public:
27 explicit GetCommitIdsCommand(int commit_batch_size);
28 virtual ~GetCommitIdsCommand();
29
30 // SyncerCommand implementation.
31 virtual SyncerError ExecuteImpl(sessions::SyncSession* session) OVERRIDE;
32
33 // Builds a vector of IDs that should be committed.
34 void BuildCommitIds(syncable::WriteTransaction* write_transaction,
35 const ModelSafeRoutingInfo& routes,
36 const std::set<int64>& ready_unsynced_set);
37
38 // Fill |ready_unsynced_set| with all entries from |unsynced_handles| that
39 // are ready to commit.
40 // An entry is not considered ready for commit if any are true:
41 // 1. It's in conflict.
42 // 2. It requires encryption (either the type is encrypted but a passphrase
43 // is missing from the cryptographer, or the entry itself wasn't properly
44 // encrypted).
45 // 3. It's type is currently throttled.
46 // 4. It's a delete but has not been committed.
47 void FilterUnreadyEntries(
48 syncable::BaseTransaction* trans,
49 syncable::ModelTypeSet throttled_types,
50 syncable::ModelTypeSet encrypted_types,
51 bool passphrase_missing,
52 const syncable::Directory::UnsyncedMetaHandles& unsynced_handles,
53 std::set<int64>* ready_unsynced_set);
54
55 private:
56 // Add all the uncommitted parents (and their predecessors) of |item| to
57 // |result| if they are ready to commit. Entries are added in root->child
58 // order and predecessor->successor order.
59 // Returns values:
60 // False: if a dependent item was in conflict, and hence no child cannot be
61 // committed.
62 // True: if all parents and their predecessors were checked for commit
63 // readiness and were added to |result| as necessary.
64 bool AddUncommittedParentsAndTheirPredecessors(
65 syncable::BaseTransaction* trans,
66 const ModelSafeRoutingInfo& routes,
67 const std::set<int64>& ready_unsynced_set,
68 const syncable::Entry& item,
69 sessions::OrderedCommitSet* result) const;
70
71 // OrderedCommitSet helpers for adding predecessors in order.
72
73 // Adds |item| to |result| if it's ready for committing and was not already
74 // present.
75 // Prereq: |item| is unsynced.
76 // Returns values:
77 // False: if |item| was in conflict.
78 // True: if |item| was checked for commit readiness and added to |result|
79 // as necessary.
80 bool AddItem(const std::set<int64>& ready_unsynced_set,
81 const syncable::Entry& item,
82 sessions::OrderedCommitSet* result) const;
83
84 // Adds item and all it's unsynced predecessors to |result| as necessary, as
85 // long as no item was in conflict.
86 // Return values:
87 // False: if there was an entry in conflict.
88 // True: if all entries were checked for commit readiness and added to
89 // |result| as necessary.
90 bool AddItemThenPredecessors(syncable::BaseTransaction* trans,
91 const std::set<int64>& ready_unsynced_set,
92 const syncable::Entry& item,
93 sessions::OrderedCommitSet* result) const;
94
95 // Appends all commit ready predecessors of |item|, followed by |item| itself,
96 // to |ordered_commit_set_|, iff item and all its predecessors not in
97 // conflict.
98 // Return values:
99 // False: if there was an entry in conflict.
100 // True: if all entries were checked for commit readiness and added to
101 // |result| as necessary.
102 bool AddPredecessorsThenItem(syncable::BaseTransaction* trans,
103 const ModelSafeRoutingInfo& routes,
104 const std::set<int64>& ready_unsynced_set,
105 const syncable::Entry& item,
106 sessions::OrderedCommitSet* result) const;
107
108 bool IsCommitBatchFull() const;
109
110 void AddCreatesAndMoves(syncable::WriteTransaction* write_transaction,
111 const ModelSafeRoutingInfo& routes,
112 const std::set<int64>& ready_unsynced_set);
113
114 void AddDeletes(syncable::WriteTransaction* write_transaction,
115 const std::set<int64>& ready_unsynced_set);
116
117 scoped_ptr<sessions::OrderedCommitSet> ordered_commit_set_;
118
119 int requested_commit_batch_size_;
120
121 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand);
122 };
123
124 } // namespace browser_sync
125
126 #endif // CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/download_updates_command_unittest.cc ('k') | chrome/browser/sync/engine/get_commit_ids_command.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698