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..cd2900a05bddd39f962b2de02ea7eb753aabf2f2 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,11 @@ void PrepareForProcessRemoteChangeCallbackAdapter( |
callback.Run(status, sync_file_info.metadata, sync_file_info.changes); |
} |
+void InvokeCallbackOnNthInvocation(int* count, const base::Closure& callback) { |
+ if (!--*count) |
peria
2014/07/22 07:19:29
nit:
Could you split this "if" statement?
Current
tzik
2014/07/22 07:28:22
Done.
|
+ callback.Run(); |
+} |
+ |
} // namespace |
LocalFileSyncService::OriginChangeMap::OriginChangeMap() |
@@ -186,10 +191,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( |