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

Unified Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 22336003: Manage fan-in for writable file entry checking on the UI thread. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 4 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/extensions/api/file_system/file_system_api.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_api.cc b/chrome/browser/extensions/api/file_system/file_system_api.cc
index e347fcf7675118211deb07f259fc51e4d284c104..fe663808eaaf1ba7b05496f6ad3c2fa8fa356db2 100644
--- a/chrome/browser/extensions/api/file_system/file_system_api.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_api.cc
@@ -315,30 +315,20 @@ class WritableFileChecker
virtual ~WritableFileChecker() {}
// Called when a work item is completed. If all work items are done, this
- // posts a task to run AllTasksDone on the UI thread.
+ // calls the success or failure callback.
void TaskDone() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (--outstanding_tasks_ == 0) {
- content::BrowserThread::PostTask(
- content::BrowserThread::UI,
- FROM_HERE,
- base::Bind(&WritableFileChecker::AllTasksDone, this));
+ if (error_.empty())
+ on_success_.Run();
+ else
+ on_failure_.Run(error_);
}
}
- // Called on the UI thread when all tasks are done.
- void AllTasksDone() {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- if (error_.empty())
- on_success_.Run();
- else
- on_failure_.Run(error_);
- }
-
// Reports an error in completing a work item. This may be called more than
// once, but only the last message will be retained.
void Error(const std::string& message) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
DCHECK(!message.empty());
error_ = message;
TaskDone();
@@ -350,22 +340,36 @@ class WritableFileChecker
for (std::vector<base::FilePath>::const_iterator it = paths.begin();
it != paths.end(); ++it) {
if (!DoCheckWritableFile(*it, extension_path_, &error)) {
- Error(error);
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&WritableFileChecker::Error, this, error));
return;
}
}
- TaskDone();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&WritableFileChecker::TaskDone, this));
}
#if defined(OS_CHROMEOS)
void CheckRemoteWritableFile(drive::FileError error,
const base::FilePath& path) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
if (error == drive::FILE_ERROR_OK) {
- TaskDone();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&WritableFileChecker::TaskDone, this));
} else {
- Error(base::StringPrintf(kWritableFileErrorFormat,
- path.BaseName().AsUTF8Unsafe().c_str()));
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(
+ &WritableFileChecker::Error,
+ this,
+ base::StringPrintf(kWritableFileErrorFormat,
+ path.BaseName().AsUTF8Unsafe().c_str())));
}
}
#endif
« 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