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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10825160: gdata: Cleanup GDataFileSystem::AddUploadedFileOnUIThread(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment to explain the ScopedClosureRunner. Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 9d7aa28116ea8814c0c227b536c3c91e6ab5710f..949ca502c72fbfceca97db5ae5b43830ffc99bac 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -3527,34 +3527,30 @@ void GDataFileSystem::AddUploadedFileOnUIThread(
GDataCache::FileOperationType cache_operation,
const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!callback.is_null());
+
+ // ScopedClosureRunner ensures that the specified callback is always invoked
+ // upon return or passed on.
+ base::ScopedClosureRunner callback_runner(callback);
if (!entry.get()) {
NOTREACHED();
- callback.Run();
return;
}
GDataEntry* dir_entry = directory_service_->FindEntryByPathSync(
virtual_dir_path);
- if (!dir_entry) {
- callback.Run();
+ if (!dir_entry)
return;
- }
GDataDirectory* parent_dir = dir_entry->AsGDataDirectory();
- if (!parent_dir) {
- callback.Run();
+ if (!parent_dir)
return;
- }
scoped_ptr<GDataEntry> new_entry(
GDataEntry::FromDocumentEntry(
parent_dir, entry.get(), directory_service_.get()));
- if (!new_entry.get()) {
- callback.Run();
+ if (!new_entry.get())
return;
- }
if (upload_mode == UPLOAD_EXISTING_FILE) {
// Remove an existing entry, which should be present.
@@ -3579,13 +3575,13 @@ void GDataFileSystem::AddUploadedFileOnUIThread(
file_content_path,
cache_operation,
base::Bind(&OnCacheUpdatedForAddUploadedFile,
- callback));
+ callback_runner.Release()));
} else if (upload_mode == UPLOAD_EXISTING_FILE) {
// Clear the dirty bit if we have updated an existing file.
cache_->ClearDirtyOnUIThread(resource_id,
md5,
base::Bind(&OnCacheUpdatedForAddUploadedFile,
- callback));
+ callback_runner.Release()));
} else {
NOTREACHED() << "Unexpected upload mode: " << upload_mode;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698