Index: chrome/browser/sync/engine/get_commit_ids_command.cc |
diff --git a/chrome/browser/sync/engine/get_commit_ids_command.cc b/chrome/browser/sync/engine/get_commit_ids_command.cc |
index 2b17aa7b4cd1f379a714efa621080d8004b79b3a..f088c1d4d547e2d5496ddfcf43909afdea514837 100644 |
--- a/chrome/browser/sync/engine/get_commit_ids_command.cc |
+++ b/chrome/browser/sync/engine/get_commit_ids_command.cc |
@@ -43,16 +43,20 @@ void GetCommitIdsCommand::ExecuteImpl(SyncSession* session) { |
encrypted_types_ = cryptographer->GetEncryptedTypes(); |
passphrase_missing_ = cryptographer->has_pending_keys(); |
}; |
+ |
+ const syncable::ModelTypeSet& throttled_types = |
+ session->context()->GetThrottledTypes(); |
// We filter out all unready entries from the set of unsynced handles to |
// ensure we don't trigger useless sync cycles attempting to retry due to |
// there being work to do. (see ScheduleNextSync in sync_scheduler) |
FilterUnreadyEntries(session->write_transaction(), |
+ throttled_types, |
&all_unsynced_handles); |
StatusController* status = session->mutable_status_controller(); |
status->set_unsynced_handles(all_unsynced_handles); |
BuildCommitIds(status->unsynced_handles(), session->write_transaction(), |
- session->routing_info()); |
+ session->routing_info(), throttled_types); |
const vector<syncable::Id>& verified_commit_ids = |
ordered_commit_set_->GetAllCommitIds(); |
@@ -65,13 +69,15 @@ void GetCommitIdsCommand::ExecuteImpl(SyncSession* session) { |
namespace { |
-// An entry ready for commit is defined as one not in conflict (SERVER_VERSION |
-// == BASE_VERSION || SERVER_VERSION == 0) and not requiring encryption |
-// (any entry containing an encrypted datatype while the cryptographer requires |
-// a passphrase is not ready for commit.) |
+// An entry ready for commit is defined as: |
+// 1. Not in conflict (SERVER_VERSION == BASE_VERSION || SERVER_VERSION == 0) |
+// and not requiring encryption (any entry containing an encrypted datatype |
+// while the cryptographer requires a passphrase is not ready for commit.) |
+// 2. Its type is not currently throttled. |
bool IsEntryReadyForCommit(const syncable::ModelTypeSet& encrypted_types, |
bool passphrase_missing, |
- const syncable::Entry& entry) { |
+ const syncable::Entry& entry, |
+ const syncable::ModelTypeSet& throttled_types) { |
if (!entry.Get(syncable::IS_UNSYNCED)) |
return false; |
@@ -87,7 +93,8 @@ bool IsEntryReadyForCommit(const syncable::ModelTypeSet& encrypted_types, |
return false; |
} |
- if (encrypted_types.count(entry.GetModelType()) > 0 && |
+ syncable::ModelType type = entry.GetModelType(); |
+ if (encrypted_types.count(type) > 0 && |
(passphrase_missing || |
syncable::EntryNeedsEncryption(encrypted_types, entry))) { |
// This entry requires encryption but is not properly encrypted (possibly |
@@ -99,6 +106,10 @@ bool IsEntryReadyForCommit(const syncable::ModelTypeSet& encrypted_types, |
return false; |
} |
+ // Look at the throttled types. |
+ if (throttled_types.count(type) > 0) |
+ return false; |
+ |
return true; |
} |
@@ -106,6 +117,7 @@ bool IsEntryReadyForCommit(const syncable::ModelTypeSet& encrypted_types, |
void GetCommitIdsCommand::FilterUnreadyEntries( |
syncable::BaseTransaction* trans, |
+ const syncable::ModelTypeSet& throttled_types, |
syncable::Directory::UnsyncedMetaHandles* unsynced_handles) { |
syncable::Directory::UnsyncedMetaHandles::iterator iter; |
syncable::Directory::UnsyncedMetaHandles new_unsynced_handles; |
@@ -114,7 +126,10 @@ void GetCommitIdsCommand::FilterUnreadyEntries( |
iter != unsynced_handles->end(); |
++iter) { |
syncable::Entry entry(trans, syncable::GET_BY_HANDLE, *iter); |
- if (IsEntryReadyForCommit(encrypted_types_, passphrase_missing_, entry)) |
+ if (IsEntryReadyForCommit(encrypted_types_, |
+ passphrase_missing_, |
+ entry, |
+ throttled_types)) |
new_unsynced_handles.push_back(*iter); |
} |
if (new_unsynced_handles.size() != unsynced_handles->size()) |
@@ -124,7 +139,8 @@ void GetCommitIdsCommand::FilterUnreadyEntries( |
void GetCommitIdsCommand::AddUncommittedParentsAndTheirPredecessors( |
syncable::BaseTransaction* trans, |
syncable::Id parent_id, |
- const ModelSafeRoutingInfo& routes) { |
+ const ModelSafeRoutingInfo& routes, |
+ const syncable::ModelTypeSet& throttled_types) { |
OrderedCommitSet item_dependencies(routes); |
// Climb the tree adding entries leaf -> root. |
@@ -136,7 +152,8 @@ void GetCommitIdsCommand::AddUncommittedParentsAndTheirPredecessors( |
item_dependencies.HaveCommitItem(handle)) { |
break; |
} |
- if (!AddItemThenPredecessors(trans, &parent, syncable::IS_UNSYNCED, |
+ if (!AddItemThenPredecessors(trans, throttled_types, &parent, |
+ syncable::IS_UNSYNCED, |
&item_dependencies)) { |
break; // Parent was already present in the set. |
} |
@@ -148,8 +165,10 @@ void GetCommitIdsCommand::AddUncommittedParentsAndTheirPredecessors( |
} |
bool GetCommitIdsCommand::AddItem(syncable::Entry* item, |
- OrderedCommitSet* result) { |
- if (!IsEntryReadyForCommit(encrypted_types_, passphrase_missing_, *item)) |
+ const syncable::ModelTypeSet& throttled_types, |
+ OrderedCommitSet* result) { |
+ if (!IsEntryReadyForCommit(encrypted_types_, passphrase_missing_, *item, |
+ throttled_types)) |
return false; |
int64 item_handle = item->Get(syncable::META_HANDLE); |
if (result->HaveCommitItem(item_handle) || |
@@ -163,10 +182,11 @@ bool GetCommitIdsCommand::AddItem(syncable::Entry* item, |
bool GetCommitIdsCommand::AddItemThenPredecessors( |
syncable::BaseTransaction* trans, |
+ const syncable::ModelTypeSet& throttled_types, |
syncable::Entry* item, |
syncable::IndexedBitField inclusion_filter, |
OrderedCommitSet* result) { |
- if (!AddItem(item, result)) |
+ if (!AddItem(item, throttled_types, result)) |
return false; |
if (item->Get(syncable::IS_DEL)) |
return true; // Deleted items have no predecessors. |
@@ -177,7 +197,7 @@ bool GetCommitIdsCommand::AddItemThenPredecessors( |
CHECK(prev.good()) << "Bad id when walking predecessors."; |
if (!prev.Get(inclusion_filter)) |
break; |
- if (!AddItem(&prev, result)) |
+ if (!AddItem(&prev, throttled_types, result)) |
break; |
prev_id = prev.Get(syncable::PREV_ID); |
} |
@@ -186,11 +206,13 @@ bool GetCommitIdsCommand::AddItemThenPredecessors( |
void GetCommitIdsCommand::AddPredecessorsThenItem( |
syncable::BaseTransaction* trans, |
+ const syncable::ModelTypeSet& throttled_types, |
syncable::Entry* item, |
syncable::IndexedBitField inclusion_filter, |
const ModelSafeRoutingInfo& routes) { |
OrderedCommitSet item_dependencies(routes); |
- AddItemThenPredecessors(trans, item, inclusion_filter, &item_dependencies); |
+ AddItemThenPredecessors(trans, throttled_types, item, inclusion_filter, |
+ &item_dependencies); |
// Reverse what we added to get the correct order. |
ordered_commit_set_->AppendReverse(item_dependencies); |
@@ -203,7 +225,8 @@ bool GetCommitIdsCommand::IsCommitBatchFull() { |
void GetCommitIdsCommand::AddCreatesAndMoves( |
const vector<int64>& unsynced_handles, |
syncable::WriteTransaction* write_transaction, |
- const ModelSafeRoutingInfo& routes) { |
+ const ModelSafeRoutingInfo& routes, |
+ const syncable::ModelTypeSet& throttled_types) { |
// Add moves and creates, and prepend their uncommitted parents. |
for (CommitMetahandleIterator iterator(unsynced_handles, write_transaction, |
ordered_commit_set_.get()); |
@@ -216,9 +239,9 @@ void GetCommitIdsCommand::AddCreatesAndMoves( |
metahandle); |
if (!entry.Get(syncable::IS_DEL)) { |
AddUncommittedParentsAndTheirPredecessors(write_transaction, |
- entry.Get(syncable::PARENT_ID), routes); |
- AddPredecessorsThenItem(write_transaction, &entry, |
- syncable::IS_UNSYNCED, routes); |
+ entry.Get(syncable::PARENT_ID), routes, throttled_types); |
+ AddPredecessorsThenItem(write_transaction, throttled_types, &entry, |
+ syncable::IS_UNSYNCED, routes); |
} |
} |
@@ -313,7 +336,8 @@ void GetCommitIdsCommand::AddDeletes(const vector<int64>& unsynced_handles, |
void GetCommitIdsCommand::BuildCommitIds(const vector<int64>& unsynced_handles, |
syncable::WriteTransaction* write_transaction, |
- const ModelSafeRoutingInfo& routes) { |
+ const ModelSafeRoutingInfo& routes, |
+ const syncable::ModelTypeSet& throttled_types) { |
ordered_commit_set_.reset(new OrderedCommitSet(routes)); |
// Commits follow these rules: |
// 1. Moves or creates are preceded by needed folder creates, from |
@@ -325,7 +349,8 @@ void GetCommitIdsCommand::BuildCommitIds(const vector<int64>& unsynced_handles, |
// delete trees. |
// Add moves and creates, and prepend their uncommitted parents. |
- AddCreatesAndMoves(unsynced_handles, write_transaction, routes); |
+ AddCreatesAndMoves(unsynced_handles, write_transaction, routes, |
+ throttled_types); |
// Add all deletes. |
AddDeletes(unsynced_handles, write_transaction); |