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

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

Issue 2890853002: Downloads: replace BrowserThread::FILE with task scheduler. (Closed)
Patch Set: Add a missing mock expectation. Created 3 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
Index: content/browser/download/mhtml_generation_manager.cc
diff --git a/content/browser/download/mhtml_generation_manager.cc b/content/browser/download/mhtml_generation_manager.cc
index 001d30d59f469fbfc9696f80015393a5d031b473..f161b9cf06dca2e65f5aa17c737926170a1a6524 100644
--- a/content/browser/download/mhtml_generation_manager.cc
+++ b/content/browser/download/mhtml_generation_manager.cc
@@ -18,9 +18,11 @@
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/task_runner_util.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "content/browser/bad_message.h"
+#include "content/browser/download/download_task_runner.h"
#include "content/browser/download/mhtml_extra_parts_impl.h"
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
@@ -379,8 +381,8 @@ void MHTMLGenerationManager::Job::CloseFile(
}
// If no previous error occurred the boundary should be sent.
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::FILE, FROM_HERE,
+ PostTaskAndReplyWithResult(
+ GetDownloadTaskRunner().get(), FROM_HERE,
base::Bind(
&MHTMLGenerationManager::Job::FinalizeAndCloseFileOnFileThread,
save_status,
@@ -437,7 +439,7 @@ MHTMLGenerationManager::Job::FinalizeAndCloseFileOnFileThread(
const std::string& boundary,
base::File file,
const MHTMLExtraPartsImpl* extra_parts) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
// If no previous error occurred the boundary should have been provided.
if (save_status == MhtmlSaveStatus::SUCCESS) {
@@ -473,7 +475,7 @@ bool MHTMLGenerationManager::Job::WriteExtraDataParts(
const std::string& boundary,
base::File& file,
const MHTMLExtraPartsImpl* extra_parts) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
// Don't write an extra data part if there is none.
if (extra_parts == nullptr)
return true;
@@ -508,7 +510,7 @@ bool MHTMLGenerationManager::Job::WriteExtraDataParts(
// static
bool MHTMLGenerationManager::Job::WriteFooter(const std::string& boundary,
base::File& file) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
std::string footer = base::StringPrintf("--%s--\r\n", boundary.c_str());
DCHECK(base::IsStringASCII(footer));
return (file.WriteAtCurrentPos(footer.data(), footer.size()) >= 0);
@@ -517,7 +519,7 @@ bool MHTMLGenerationManager::Job::WriteFooter(const std::string& boundary,
// static
bool MHTMLGenerationManager::Job::CloseFileIfValid(base::File& file,
int64_t* file_size) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
DCHECK(file_size);
if (file.IsValid()) {
*file_size = file.GetLength();
@@ -548,8 +550,8 @@ void MHTMLGenerationManager::SaveMHTML(WebContents* web_contents,
web_contents->GetLastCommittedURL().possibly_invalid_spec(),
"file", params.file_path.AsUTF8Unsafe());
- BrowserThread::PostTaskAndReplyWithResult(
- BrowserThread::FILE, FROM_HERE,
+ PostTaskAndReplyWithResult(
+ GetDownloadTaskRunner().get(), FROM_HERE,
base::Bind(&MHTMLGenerationManager::CreateFile, params.file_path),
base::Bind(&MHTMLGenerationManager::OnFileAvailable,
base::Unretained(this), // Safe b/c |this| is a singleton.
@@ -596,7 +598,7 @@ void MHTMLGenerationManager::OnSerializeAsMHTMLResponse(
// static
base::File MHTMLGenerationManager::CreateFile(const base::FilePath& file_path) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK(GetDownloadTaskRunner()->RunsTasksInCurrentSequence());
// SECURITY NOTE: A file descriptor to the file created below will be passed
// to multiple renderer processes which (in out-of-process iframes mode) can

Powered by Google App Engine
This is Rietveld 408576698