OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ | 5 #ifndef CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ |
6 #define CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ | 6 #define CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 15 matching lines...) Expand all Loading... |
26 public: | 26 public: |
27 explicit GetCommitIdsCommand(int commit_batch_size); | 27 explicit GetCommitIdsCommand(int commit_batch_size); |
28 virtual ~GetCommitIdsCommand(); | 28 virtual ~GetCommitIdsCommand(); |
29 | 29 |
30 // SyncerCommand implementation. | 30 // SyncerCommand implementation. |
31 virtual void ExecuteImpl(sessions::SyncSession* session) OVERRIDE; | 31 virtual void ExecuteImpl(sessions::SyncSession* session) OVERRIDE; |
32 | 32 |
33 // Builds a vector of IDs that should be committed. | 33 // Builds a vector of IDs that should be committed. |
34 void BuildCommitIds(const vector<int64>& unsynced_handles, | 34 void BuildCommitIds(const vector<int64>& unsynced_handles, |
35 syncable::WriteTransaction* write_transaction, | 35 syncable::WriteTransaction* write_transaction, |
36 const ModelSafeRoutingInfo& routes); | 36 const ModelSafeRoutingInfo& routes, |
| 37 const syncable::ModelTypeSet& throttled_types); |
37 | 38 |
38 // TODO(chron): Remove writes from this iterator. As a warning, this | 39 // TODO(chron): Remove writes from this iterator. As a warning, this |
39 // iterator causes writes to entries and so isn't a pure iterator. | 40 // iterator causes writes to entries and so isn't a pure iterator. |
40 // It will do Put(IS_UNSYNCED). Refactor this out later. | 41 // It will do Put(IS_UNSYNCED). Refactor this out later. |
41 class CommitMetahandleIterator { | 42 class CommitMetahandleIterator { |
42 public: | 43 public: |
43 // TODO(chron): Cache ValidateCommitEntry responses across iterators to save | 44 // TODO(chron): Cache ValidateCommitEntry responses across iterators to save |
44 // UTF8 conversion and filename checking | 45 // UTF8 conversion and filename checking |
45 CommitMetahandleIterator(const vector<int64>& unsynced_handles, | 46 CommitMetahandleIterator(const vector<int64>& unsynced_handles, |
46 syncable::WriteTransaction* write_transaction, | 47 syncable::WriteTransaction* write_transaction, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 syncable::WriteTransaction* const write_transaction_; | 103 syncable::WriteTransaction* const write_transaction_; |
103 vector<int64>::const_iterator handle_iterator_; | 104 vector<int64>::const_iterator handle_iterator_; |
104 vector<int64>::const_iterator unsynced_handles_end_; | 105 vector<int64>::const_iterator unsynced_handles_end_; |
105 sessions::OrderedCommitSet* commit_set_; | 106 sessions::OrderedCommitSet* commit_set_; |
106 | 107 |
107 DISALLOW_COPY_AND_ASSIGN(CommitMetahandleIterator); | 108 DISALLOW_COPY_AND_ASSIGN(CommitMetahandleIterator); |
108 }; | 109 }; |
109 | 110 |
110 private: | 111 private: |
111 // Removes all entries not ready for commit from |unsynced_handles|. | 112 // Removes all entries not ready for commit from |unsynced_handles|. |
112 // An entry is considered unready for commit if it's in conflict or requires | 113 // An entry is considered unready for commit if: |
113 // (re)encryption. Any datatype requiring encryption while the cryptographer | 114 // 1. It's in conflict or requires (re)encryption. Any datatype requiring |
114 // is missing a passphrase is considered unready for commit. | 115 // encryption while the cryptographer is missing a passphrase is |
| 116 // considered unready for commit. |
| 117 // 2. Its type is currently throttled. |
115 void FilterUnreadyEntries( | 118 void FilterUnreadyEntries( |
116 syncable::BaseTransaction* trans, | 119 syncable::BaseTransaction* trans, |
| 120 const syncable::ModelTypeSet& throttled_types, |
117 syncable::Directory::UnsyncedMetaHandles* unsynced_handles); | 121 syncable::Directory::UnsyncedMetaHandles* unsynced_handles); |
118 | 122 |
119 void AddUncommittedParentsAndTheirPredecessors( | 123 void AddUncommittedParentsAndTheirPredecessors( |
120 syncable::BaseTransaction* trans, | 124 syncable::BaseTransaction* trans, |
121 syncable::Id parent_id, | 125 syncable::Id parent_id, |
122 const ModelSafeRoutingInfo& routes); | 126 const ModelSafeRoutingInfo& routes, |
| 127 const syncable::ModelTypeSet& throttled_types); |
123 | 128 |
124 // OrderedCommitSet helpers for adding predecessors in order. | 129 // OrderedCommitSet helpers for adding predecessors in order. |
125 // TODO(ncarter): Refactor these so that the |result| parameter goes away, | 130 // TODO(ncarter): Refactor these so that the |result| parameter goes away, |
126 // and AddItem doesn't need to consider two OrderedCommitSets. | 131 // and AddItem doesn't need to consider two OrderedCommitSets. |
127 bool AddItem(syncable::Entry* item, sessions::OrderedCommitSet* result); | 132 bool AddItem(syncable::Entry* item, |
| 133 const syncable::ModelTypeSet& throttled_types, |
| 134 sessions::OrderedCommitSet* result); |
128 bool AddItemThenPredecessors(syncable::BaseTransaction* trans, | 135 bool AddItemThenPredecessors(syncable::BaseTransaction* trans, |
| 136 const syncable::ModelTypeSet& throttled_types, |
129 syncable::Entry* item, | 137 syncable::Entry* item, |
130 syncable::IndexedBitField inclusion_filter, | 138 syncable::IndexedBitField inclusion_filter, |
131 sessions::OrderedCommitSet* result); | 139 sessions::OrderedCommitSet* result); |
132 void AddPredecessorsThenItem(syncable::BaseTransaction* trans, | 140 void AddPredecessorsThenItem(syncable::BaseTransaction* trans, |
| 141 const syncable::ModelTypeSet& throttled_types, |
133 syncable::Entry* item, | 142 syncable::Entry* item, |
134 syncable::IndexedBitField inclusion_filter, | 143 syncable::IndexedBitField inclusion_filter, |
135 const ModelSafeRoutingInfo& routes); | 144 const ModelSafeRoutingInfo& routes); |
136 | 145 |
137 bool IsCommitBatchFull(); | 146 bool IsCommitBatchFull(); |
138 | 147 |
139 void AddCreatesAndMoves(const vector<int64>& unsynced_handles, | 148 void AddCreatesAndMoves(const vector<int64>& unsynced_handles, |
140 syncable::WriteTransaction* write_transaction, | 149 syncable::WriteTransaction* write_transaction, |
141 const ModelSafeRoutingInfo& routes); | 150 const ModelSafeRoutingInfo& routes, |
| 151 const syncable::ModelTypeSet& throttled_types); |
142 | 152 |
143 void AddDeletes(const vector<int64>& unsynced_handles, | 153 void AddDeletes(const vector<int64>& unsynced_handles, |
144 syncable::WriteTransaction* write_transaction); | 154 syncable::WriteTransaction* write_transaction); |
145 | 155 |
146 scoped_ptr<sessions::OrderedCommitSet> ordered_commit_set_; | 156 scoped_ptr<sessions::OrderedCommitSet> ordered_commit_set_; |
147 | 157 |
148 int requested_commit_batch_size_; | 158 int requested_commit_batch_size_; |
149 bool passphrase_missing_; | 159 bool passphrase_missing_; |
150 syncable::ModelTypeSet encrypted_types_; | 160 syncable::ModelTypeSet encrypted_types_; |
151 | 161 |
152 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand); | 162 DISALLOW_COPY_AND_ASSIGN(GetCommitIdsCommand); |
153 }; | 163 }; |
154 | 164 |
155 } // namespace browser_sync | 165 } // namespace browser_sync |
156 | 166 |
157 #endif // CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ | 167 #endif // CHROME_BROWSER_SYNC_ENGINE_GET_COMMIT_IDS_COMMAND_H_ |
OLD | NEW |