Commit c1a72712 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Refactoring of the iOS component updater to use the new task scheduler api.

This is a mechanical change.

At high level:
* Not posting to the FILE thread.
* Posting to a task runner obtained by calling GetTaskRunnerForThread.

Bug: 735695
Change-Id: I273289deeb1af44868970d561717fa03615a932c
Reviewed-on: https://chromium-review.googlesource.com/544444Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481925}
parent 30e02557
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/rand_util.h" #include "base/rand_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/component_updater/component_updater_service.h" #include "components/component_updater/component_updater_service.h"
...@@ -43,11 +45,9 @@ void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus, ...@@ -43,11 +45,9 @@ void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus,
SetCRLSetFilePath(path); SetCRLSetFilePath(path);
cus_ = cus; cus_ = cus;
if (!web::WebThread::PostTask( base::PostTaskWithTraits(
web::WebThread::FILE, FROM_HERE, FROM_HERE, {base::TaskPriority::BACKGROUND, base::MayBlock()},
base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) { base::BindOnce(&CRLSetFetcher::DoInitialLoadFromDisk, this));
NOTREACHED();
}
} }
void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) { void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
...@@ -56,15 +56,13 @@ void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) { ...@@ -56,15 +56,13 @@ void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
if (path.empty()) if (path.empty())
return; return;
SetCRLSetFilePath(path); SetCRLSetFilePath(path);
if (!web::WebThread::PostTask( base::PostTaskWithTraits(
web::WebThread::FILE, FROM_HERE, FROM_HERE, {base::TaskPriority::BACKGROUND, base::MayBlock()},
base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) { base::BindOnce(&CRLSetFetcher::DoDeleteFromDisk, this));
NOTREACHED();
}
} }
void CRLSetFetcher::DoInitialLoadFromDisk() { void CRLSetFetcher::DoInitialLoadFromDisk() {
DCHECK_CURRENTLY_ON(web::WebThread::FILE); base::ThreadRestrictions::AssertIOAllowed();
LoadFromDisk(GetCRLSetFilePath(), &crl_set_); LoadFromDisk(GetCRLSetFilePath(), &crl_set_);
...@@ -74,9 +72,10 @@ void CRLSetFetcher::DoInitialLoadFromDisk() { ...@@ -74,9 +72,10 @@ void CRLSetFetcher::DoInitialLoadFromDisk() {
// Get updates, advertising the sequence number of the CRL set that we just // Get updates, advertising the sequence number of the CRL set that we just
// loaded, if any. // loaded, if any.
if (!web::WebThread::PostTask(web::WebThread::UI, FROM_HERE, if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)
base::Bind(&CRLSetFetcher::RegisterComponent, ->PostTask(FROM_HERE,
this, sequence_of_loaded_crl))) { base::BindOnce(&CRLSetFetcher::RegisterComponent, this,
sequence_of_loaded_crl))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -85,7 +84,7 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path, ...@@ -85,7 +84,7 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path,
scoped_refptr<net::CRLSet>* out_crl_set) { scoped_refptr<net::CRLSet>* out_crl_set) {
TRACE_EVENT0("CRLSetFetcher", "LoadFromDisk"); TRACE_EVENT0("CRLSetFetcher", "LoadFromDisk");
DCHECK_CURRENTLY_ON(web::WebThread::FILE); base::ThreadRestrictions::AssertIOAllowed();
std::string crl_set_bytes; std::string crl_set_bytes;
{ {
...@@ -101,9 +100,10 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path, ...@@ -101,9 +100,10 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path,
VLOG(1) << "Loaded " << crl_set_bytes.size() << " bytes of CRL set from disk"; VLOG(1) << "Loaded " << crl_set_bytes.size() << " bytes of CRL set from disk";
if (!web::WebThread::PostTask( if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::IO)
web::WebThread::IO, FROM_HERE, ->PostTask(FROM_HERE,
base::Bind(&CRLSetFetcher::SetCRLSetIfNewer, this, *out_crl_set))) { base::BindOnce(&CRLSetFetcher::SetCRLSetIfNewer, this,
*out_crl_set))) {
NOTREACHED(); NOTREACHED();
} }
} }
...@@ -150,7 +150,7 @@ void CRLSetFetcher::RegisterComponent(uint32_t sequence_of_loaded_crl) { ...@@ -150,7 +150,7 @@ void CRLSetFetcher::RegisterComponent(uint32_t sequence_of_loaded_crl) {
} }
void CRLSetFetcher::DoDeleteFromDisk() { void CRLSetFetcher::DoDeleteFromDisk() {
DCHECK_CURRENTLY_ON(web::WebThread::FILE); base::ThreadRestrictions::AssertIOAllowed();
DeleteFile(GetCRLSetFilePath(), false /* not recursive */); DeleteFile(GetCRLSetFilePath(), false /* not recursive */);
} }
...@@ -228,9 +228,10 @@ bool CRLSetFetcher::DoInstall(const base::DictionaryValue& manifest, ...@@ -228,9 +228,10 @@ bool CRLSetFetcher::DoInstall(const base::DictionaryValue& manifest,
crl_set_ = new_crl_set; crl_set_ = new_crl_set;
} }
if (!web::WebThread::PostTask( if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::IO)
web::WebThread::IO, FROM_HERE, ->PostTask(FROM_HERE,
base::Bind(&CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) { base::BindOnce(&CRLSetFetcher::SetCRLSetIfNewer, this,
crl_set_))) {
NOTREACHED(); NOTREACHED();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment