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

Unified Diff: content/public/test/test_file_error_injector.cc

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Add scoped COM initialization to quench a couple of assertion failures. Created 3 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
Index: content/public/test/test_file_error_injector.cc
diff --git a/content/public/test/test_file_error_injector.cc b/content/public/test/test_file_error_injector.cc
index 5a24423ea1afe59e91ca54f86d7dbc9229a15481..876fa4e286d09890656626154d8820eb88dcf30d 100644
--- a/content/public/test/test_file_error_injector.cc
+++ b/content/public/test/test_file_error_injector.cc
@@ -14,6 +14,7 @@
#include "content/browser/download/download_file_impl.h"
#include "content/browser/download/download_interrupt_reasons_impl.h"
#include "content/browser/download/download_manager_impl.h"
+#include "content/browser/download/download_task_runner.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/public/browser/browser_thread.h"
#include "url/gurl.h"
@@ -120,17 +121,17 @@ DownloadFileWithError::DownloadFileWithError(
observer),
error_info_(error_info),
destruction_callback_(dtor_callback) {
- // DownloadFiles are created on the UI thread and are destroyed on the FILE
- // thread. Schedule the ConstructionCallback on the FILE thread so that if a
- // DownloadItem schedules a DownloadFile to be destroyed and creates another
- // one (as happens during download resumption), then the DestructionCallback
- // for the old DownloadFile is run before the ConstructionCallback for the
- // next DownloadFile.
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, ctor_callback);
+ // DownloadFiles are created on the UI thread and are destroyed on the
+ // download task runner. Schedule the ConstructionCallback on the
+ // download task runner, so that if a DownloadItem schedules a
+ // DownloadFile to be destroyed and creates another one (as happens during
+ // download resumption), then the DestructionCallback for the old DownloadFile
+ // is run before the ConstructionCallback for the next DownloadFile.
+ GetDownloadTaskRunner()->PostTask(FROM_HERE, ctor_callback);
}
DownloadFileWithError::~DownloadFileWithError() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
destruction_callback_.Run();
}
@@ -299,14 +300,10 @@ DownloadFile* DownloadFileWithErrorFactory::CreateFile(
std::unique_ptr<ByteStreamReader> byte_stream,
const net::NetLogWithSource& net_log,
base::WeakPtr<DownloadDestinationObserver> observer) {
- return new DownloadFileWithError(std::move(save_info),
- default_download_directory,
- std::move(byte_stream),
- net_log,
- observer,
- injected_error_,
- construction_callback_,
- destruction_callback_);
+ return new DownloadFileWithError(
+ std::move(save_info), default_download_directory, std::move(byte_stream),
+ net_log, observer, injected_error_, construction_callback_,
+ destruction_callback_);
}
bool DownloadFileWithErrorFactory::SetError(
« content/common/quarantine/quarantine_win.cc ('K') | « content/public/test/download_test_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698