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

Unified Diff: content/browser/download/mhtml_generation_manager.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/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 df825ba7caccb2af0650473acef425ad85a713b6..f96f354106a4516b3604ea3c4e96d62cadfc3f4a 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"
@@ -380,8 +382,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,
@@ -438,7 +440,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) {
@@ -474,7 +476,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;
@@ -509,7 +511,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);
@@ -518,7 +520,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();
@@ -549,8 +551,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.
@@ -597,7 +599,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