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

Unified Diff: content/browser/download/base_file.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/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 7c05f8deac393f8141a7006a039a758341635663..825eff0164971508933a81ff3dc595d19a6d15e7 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -28,10 +28,12 @@
namespace content {
-BaseFile::BaseFile(const net::NetLogWithSource& net_log) : net_log_(net_log) {}
+BaseFile::BaseFile(const net::NetLogWithSource& net_log) : net_log_(net_log) {
+ DETACH_FROM_SEQUENCE(sequence_checker_);
+}
BaseFile::~BaseFile() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (detached_)
Close();
else
@@ -46,7 +48,7 @@ DownloadInterruptReason BaseFile::Initialize(
const std::string& hash_so_far,
std::unique_ptr<crypto::SecureHash> hash_state,
bool is_sparse_file) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!detached_);
if (full_path.empty()) {
@@ -127,7 +129,7 @@ DownloadInterruptReason BaseFile::WriteDataToFile(int64_t offset,
}
DownloadInterruptReason BaseFile::Rename(const base::FilePath& new_path) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DownloadInterruptReason rename_result = DOWNLOAD_INTERRUPT_REASON_NONE;
// If the new path is same as the old one, there is no need to perform the
@@ -172,7 +174,7 @@ void BaseFile::Detach() {
}
void BaseFile::Cancel() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!detached_);
net_log_.AddEvent(net::NetLogEventType::CANCELLED);
@@ -188,7 +190,7 @@ void BaseFile::Cancel() {
}
std::unique_ptr<crypto::SecureHash> BaseFile::Finish() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(qinmin): verify that all the holes have been filled.
if (is_sparse_file_)
@@ -276,7 +278,7 @@ DownloadInterruptReason BaseFile::CalculatePartialHash(
}
DownloadInterruptReason BaseFile::Open(const std::string& hash_so_far) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!detached_);
DCHECK(!full_path_.empty());
@@ -339,7 +341,7 @@ DownloadInterruptReason BaseFile::Open(const std::string& hash_so_far) {
}
void BaseFile::Close() {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (file_.IsValid()) {
// Currently we don't really care about the return value, since if it fails
@@ -426,7 +428,7 @@ DownloadInterruptReason BaseFile::AnnotateWithSourceInformation(
const std::string& client_guid,
const GURL& source_url,
const GURL& referrer_url) {
- DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!detached_);
DCHECK(!full_path_.empty());

Powered by Google App Engine
This is Rietveld 408576698