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

Unified Diff: content/browser/download/drag_download_file.cc

Issue 2105173004: Remove calls to MessageLoop::current() in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « content/browser/download/drag_download_file.h ('k') | content/browser/gamepad/gamepad_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/drag_download_file.cc
diff --git a/content/browser/download/drag_download_file.cc b/content/browser/download/drag_download_file.cc
index cd68969fb0dd06ff9cf1ef67f0f4050d72cf3ba7..94725a67830ba727c21f7f3d81665ac1b486af7b 100644
--- a/content/browser/download/drag_download_file.cc
+++ b/content/browser/download/drag_download_file.cc
@@ -11,6 +11,7 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "content/browser/download/download_stats.h"
#include "content/browser/web_contents/web_contents_impl.h"
@@ -37,13 +38,14 @@ typedef base::Callback<void(bool)> OnCompleted;
// anyway.
class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
public:
- DragDownloadFileUI(const GURL& url,
- const Referrer& referrer,
- const std::string& referrer_encoding,
- WebContents* web_contents,
- base::MessageLoop* on_completed_loop,
- const OnCompleted& on_completed)
- : on_completed_loop_(on_completed_loop),
+ DragDownloadFileUI(
+ const GURL& url,
+ const Referrer& referrer,
+ const std::string& referrer_encoding,
+ WebContents* web_contents,
+ scoped_refptr<base::SingleThreadTaskRunner> on_completed_task_runner,
+ const OnCompleted& on_completed)
+ : on_completed_task_runner_(on_completed_task_runner),
on_completed_(on_completed),
url_(url),
referrer_(referrer),
@@ -51,7 +53,7 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
web_contents_(web_contents),
download_item_(NULL),
weak_ptr_factory_(this) {
- DCHECK(on_completed_loop_);
+ DCHECK(on_completed_task_runner_);
DCHECK(!on_completed_.is_null());
DCHECK(web_contents_);
// May be called on any thread.
@@ -102,8 +104,8 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!item || item->GetState() != DownloadItem::IN_PROGRESS) {
DCHECK(!item || item->GetLastReason() != DOWNLOAD_INTERRUPT_REASON_NONE);
- on_completed_loop_->task_runner()->PostTask(
- FROM_HERE, base::Bind(on_completed_, false));
+ on_completed_task_runner_->PostTask(FROM_HERE,
+ base::Bind(on_completed_, false));
return;
}
DCHECK_EQ(DOWNLOAD_INTERRUPT_REASON_NONE, interrupt_reason);
@@ -120,7 +122,7 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
state == DownloadItem::CANCELLED ||
state == DownloadItem::INTERRUPTED) {
if (!on_completed_.is_null()) {
- on_completed_loop_->task_runner()->PostTask(
+ on_completed_task_runner_->PostTask(
FROM_HERE,
base::Bind(on_completed_, state == DownloadItem::COMPLETE));
on_completed_.Reset();
@@ -137,7 +139,7 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
if (!on_completed_.is_null()) {
const bool is_complete =
download_item_->GetState() == DownloadItem::COMPLETE;
- on_completed_loop_->task_runner()->PostTask(
+ on_completed_task_runner_->PostTask(
FROM_HERE, base::Bind(on_completed_, is_complete));
on_completed_.Reset();
}
@@ -145,7 +147,7 @@ class DragDownloadFile::DragDownloadFileUI : public DownloadItem::Observer {
download_item_ = NULL;
}
- base::MessageLoop* on_completed_loop_;
+ scoped_refptr<base::SingleThreadTaskRunner> const on_completed_task_runner_;
OnCompleted on_completed_;
GURL url_;
Referrer referrer_;
@@ -167,16 +169,12 @@ DragDownloadFile::DragDownloadFile(const base::FilePath& file_path,
WebContents* web_contents)
: file_path_(file_path),
file_(std::move(file)),
- drag_message_loop_(base::MessageLoop::current()),
+ drag_task_runner_(base::ThreadTaskRunnerHandle::Get()),
state_(INITIALIZED),
drag_ui_(NULL),
weak_ptr_factory_(this) {
drag_ui_ = new DragDownloadFileUI(
- url,
- referrer,
- referrer_encoding,
- web_contents,
- drag_message_loop_,
+ url, referrer, referrer_encoding, web_contents, drag_task_runner_,
base::Bind(&DragDownloadFile::DownloadCompleted,
weak_ptr_factory_.GetWeakPtr()));
DCHECK(!file_path_.empty());
@@ -244,7 +242,7 @@ void DragDownloadFile::DownloadCompleted(bool is_successful) {
void DragDownloadFile::CheckThread() {
#if defined(OS_WIN)
- DCHECK(drag_message_loop_ == base::MessageLoop::current());
+ DCHECK(drag_task_runner_->BelongsToCurrentThread());
#else
DCHECK_CURRENTLY_ON(BrowserThread::UI);
#endif
« no previous file with comments | « content/browser/download/drag_download_file.h ('k') | content/browser/gamepad/gamepad_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698