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

Unified Diff: chrome/browser/download/chrome_download_manager_delegate.cc

Issue 324883006: Cleanup: Use PostTaskAndReplyWithResults instead of passing callbacks around in downloads code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | chrome/browser/download/download_path_reservation_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/chrome_download_manager_delegate.cc
===================================================================
--- chrome/browser/download/chrome_download_manager_delegate.cc (revision 275705)
+++ chrome/browser/download/chrome_download_manager_delegate.cc (working copy)
@@ -17,6 +17,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner.h"
+#include "base/task_runner_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
#include "chrome/browser/browser_process.h"
@@ -177,13 +178,10 @@
#endif // FULL_SAFE_BROWSING
// Called on the blocking pool to determine the MIME type for |path|.
-void GetMimeTypeAndReplyOnUIThread(
- const base::FilePath& path,
- const base::Callback<void(const std::string&)>& callback) {
+std::string GetMimeType(const base::FilePath& path) {
std::string mime_type;
net::GetMimeTypeFromFile(path, &mime_type);
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE, base::Bind(callback, mime_type));
+ return mime_type;
}
bool IsOpenInBrowserPreferreredForFile(const base::FilePath& path) {
@@ -636,9 +634,11 @@
void ChromeDownloadManagerDelegate::GetFileMimeType(
const base::FilePath& path,
const GetFileMimeTypeCallback& callback) {
- BrowserThread::PostBlockingPoolTask(
- FROM_HERE,
- base::Bind(&GetMimeTypeAndReplyOnUIThread, path, callback));
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ base::PostTaskAndReplyWithResult(BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&GetMimeType, path),
+ callback);
}
#if defined(FULL_SAFE_BROWSING)
« no previous file with comments | « no previous file | chrome/browser/download/download_path_reservation_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698