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

Unified Diff: chrome/browser/sync_file_system/local/local_file_sync_service.cc

Issue 407073003: [SyncFS] Add completion callback to PromoteDemotedChanges (1/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync_file_system/local/local_file_sync_service.cc
diff --git a/chrome/browser/sync_file_system/local/local_file_sync_service.cc b/chrome/browser/sync_file_system/local/local_file_sync_service.cc
index 6f0d0823ea73d8884739003d357973188b864ebd..f49d0007d537bfdc9de6c5f434dfb4716d157178 100644
--- a/chrome/browser/sync_file_system/local/local_file_sync_service.cc
+++ b/chrome/browser/sync_file_system/local/local_file_sync_service.cc
@@ -42,6 +42,12 @@ void PrepareForProcessRemoteChangeCallbackAdapter(
callback.Run(status, sync_file_info.metadata, sync_file_info.changes);
}
+void InvokeCallbackOnNthInvocation(int* count, const base::Closure& callback) {
+ --*count;
+ if (*count <= 0)
+ callback.Run();
+}
+
} // namespace
LocalFileSyncService::OriginChangeMap::OriginChangeMap()
@@ -186,10 +192,20 @@ void LocalFileSyncService::HasPendingLocalChanges(
origin_to_contexts_[url.origin()], url, callback);
}
-void LocalFileSyncService::PromoteDemotedChanges() {
+void LocalFileSyncService::PromoteDemotedChanges(
+ const base::Closure& callback) {
+ if (origin_to_contexts_.empty()) {
+ callback.Run();
+ return;
+ }
+
+ base::Closure completion_callback =
+ base::Bind(&InvokeCallbackOnNthInvocation,
+ base::Owned(new int(origin_to_contexts_.size())), callback);
for (OriginToContext::iterator iter = origin_to_contexts_.begin();
iter != origin_to_contexts_.end(); ++iter)
- sync_context_->PromoteDemotedChanges(iter->first, iter->second);
+ sync_context_->PromoteDemotedChanges(iter->first, iter->second,
+ completion_callback);
}
void LocalFileSyncService::GetLocalFileMetadata(

Powered by Google App Engine
This is Rietveld 408576698