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 @@
#include "base/numerics/safe_conversions.h"
#include "base/rand_util.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/trace_event/trace_event.h"
#include "components/component_updater/component_updater_service.h"
......@@ -43,11 +45,9 @@ void CRLSetFetcher::StartInitialLoad(ComponentUpdateService* cus,
SetCRLSetFilePath(path);
cus_ = cus;
if (!web::WebThread::PostTask(
web::WebThread::FILE, FROM_HERE,
base::Bind(&CRLSetFetcher::DoInitialLoadFromDisk, this))) {
NOTREACHED();
}
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::BACKGROUND, base::MayBlock()},
base::BindOnce(&CRLSetFetcher::DoInitialLoadFromDisk, this));
}
void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
......@@ -56,15 +56,13 @@ void CRLSetFetcher::DeleteFromDisk(const base::FilePath& path) {
if (path.empty())
return;
SetCRLSetFilePath(path);
if (!web::WebThread::PostTask(
web::WebThread::FILE, FROM_HERE,
base::Bind(&CRLSetFetcher::DoDeleteFromDisk, this))) {
NOTREACHED();
}
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::BACKGROUND, base::MayBlock()},
base::BindOnce(&CRLSetFetcher::DoDeleteFromDisk, this));
}
void CRLSetFetcher::DoInitialLoadFromDisk() {
DCHECK_CURRENTLY_ON(web::WebThread::FILE);
base::ThreadRestrictions::AssertIOAllowed();
LoadFromDisk(GetCRLSetFilePath(), &crl_set_);
......@@ -74,9 +72,10 @@ void CRLSetFetcher::DoInitialLoadFromDisk() {
// Get updates, advertising the sequence number of the CRL set that we just
// loaded, if any.
if (!web::WebThread::PostTask(web::WebThread::UI, FROM_HERE,
base::Bind(&CRLSetFetcher::RegisterComponent,
this, sequence_of_loaded_crl))) {
if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::UI)
->PostTask(FROM_HERE,
base::BindOnce(&CRLSetFetcher::RegisterComponent, this,
sequence_of_loaded_crl))) {
NOTREACHED();
}
}
......@@ -85,7 +84,7 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path,
scoped_refptr<net::CRLSet>* out_crl_set) {
TRACE_EVENT0("CRLSetFetcher", "LoadFromDisk");
DCHECK_CURRENTLY_ON(web::WebThread::FILE);
base::ThreadRestrictions::AssertIOAllowed();
std::string crl_set_bytes;
{
......@@ -101,9 +100,10 @@ void CRLSetFetcher::LoadFromDisk(base::FilePath path,
VLOG(1) << "Loaded " << crl_set_bytes.size() << " bytes of CRL set from disk";
if (!web::WebThread::PostTask(
web::WebThread::IO, FROM_HERE,
base::Bind(&CRLSetFetcher::SetCRLSetIfNewer, this, *out_crl_set))) {
if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::IO)
->PostTask(FROM_HERE,
base::BindOnce(&CRLSetFetcher::SetCRLSetIfNewer, this,
*out_crl_set))) {
NOTREACHED();
}
}
......@@ -150,7 +150,7 @@ void CRLSetFetcher::RegisterComponent(uint32_t sequence_of_loaded_crl) {
}
void CRLSetFetcher::DoDeleteFromDisk() {
DCHECK_CURRENTLY_ON(web::WebThread::FILE);
base::ThreadRestrictions::AssertIOAllowed();
DeleteFile(GetCRLSetFilePath(), false /* not recursive */);
}
......@@ -228,9 +228,10 @@ bool CRLSetFetcher::DoInstall(const base::DictionaryValue& manifest,
crl_set_ = new_crl_set;
}
if (!web::WebThread::PostTask(
web::WebThread::IO, FROM_HERE,
base::Bind(&CRLSetFetcher::SetCRLSetIfNewer, this, crl_set_))) {
if (!web::WebThread::GetTaskRunnerForThread(web::WebThread::IO)
->PostTask(FROM_HERE,
base::BindOnce(&CRLSetFetcher::SetCRLSetIfNewer, this,
crl_set_))) {
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