summaryrefslogtreecommitdiff
path: root/chromium/components/update_client
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 10:33:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:45:12 +0000
commitbe59a35641616a4cf23c4a13fa0632624b021c1b (patch)
tree9da183258bdf9cc413f7562079d25ace6955467f /chromium/components/update_client
parentd702e4b6a64574e97fc7df8fe3238cde70242080 (diff)
downloadqtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/components/update_client')
-rw-r--r--chromium/components/update_client/BUILD.gn1
-rw-r--r--chromium/components/update_client/action_runner.cc34
-rw-r--r--chromium/components/update_client/action_runner.h6
-rw-r--r--chromium/components/update_client/action_runner_win.cc13
-rw-r--r--chromium/components/update_client/background_downloader_win.cc40
-rw-r--r--chromium/components/update_client/background_downloader_win.h8
-rw-r--r--chromium/components/update_client/component.cc87
-rw-r--r--chromium/components/update_client/component_patcher.cc21
-rw-r--r--chromium/components/update_client/component_patcher.h5
-rw-r--r--chromium/components/update_client/component_patcher_operation.cc26
-rw-r--r--chromium/components/update_client/component_patcher_operation.h7
-rw-r--r--chromium/components/update_client/component_patcher_unittest.cc29
-rw-r--r--chromium/components/update_client/component_patcher_unittest.h8
-rw-r--r--chromium/components/update_client/component_unpacker.cc30
-rw-r--r--chromium/components/update_client/component_unpacker.h12
-rw-r--r--chromium/components/update_client/component_unpacker_unittest.cc41
-rw-r--r--chromium/components/update_client/configurator.h5
-rw-r--r--chromium/components/update_client/crx_downloader.cc38
-rw-r--r--chromium/components/update_client/crx_downloader.h6
-rw-r--r--chromium/components/update_client/out_of_process_patcher.h2
-rw-r--r--chromium/components/update_client/ping_manager.cc1
-rw-r--r--chromium/components/update_client/ping_manager_unittest.cc5
-rw-r--r--chromium/components/update_client/protocol_builder.cc4
-rw-r--r--chromium/components/update_client/request_sender.cc46
-rw-r--r--chromium/components/update_client/request_sender.h6
-rw-r--r--chromium/components/update_client/request_sender_unittest.cc23
-rw-r--r--chromium/components/update_client/task_send_uninstall_ping.cc3
-rw-r--r--chromium/components/update_client/task_traits.h28
-rw-r--r--chromium/components/update_client/task_update.cc3
-rw-r--r--chromium/components/update_client/test_configurator.cc19
-rw-r--r--chromium/components/update_client/test_configurator.h14
-rw-r--r--chromium/components/update_client/update_checker.cc25
-rw-r--r--chromium/components/update_client/update_checker.h2
-rw-r--r--chromium/components/update_client/update_checker_unittest.cc22
-rw-r--r--chromium/components/update_client/update_client.cc8
-rw-r--r--chromium/components/update_client/update_client_unittest.cc187
-rw-r--r--chromium/components/update_client/update_engine.cc24
-rw-r--r--chromium/components/update_client/update_engine.h4
-rw-r--r--chromium/components/update_client/update_query_params.cc2
-rw-r--r--chromium/components/update_client/updater_state_unittest.cc6
-rw-r--r--chromium/components/update_client/url_fetcher_downloader.cc2
-rw-r--r--chromium/components/update_client/url_fetcher_downloader.h3
-rw-r--r--chromium/components/update_client/utils.cc2
43 files changed, 369 insertions, 489 deletions
diff --git a/chromium/components/update_client/BUILD.gn b/chromium/components/update_client/BUILD.gn
index 545210a9a5a..23ac41f0ab8 100644
--- a/chromium/components/update_client/BUILD.gn
+++ b/chromium/components/update_client/BUILD.gn
@@ -37,6 +37,7 @@ static_library("update_client") {
"task.h",
"task_send_uninstall_ping.cc",
"task_send_uninstall_ping.h",
+ "task_traits.h",
"task_update.cc",
"task_update.h",
"update_checker.cc",
diff --git a/chromium/components/update_client/action_runner.cc b/chromium/components/update_client/action_runner.cc
index 0cc68d02861..125b6db7523 100644
--- a/chromium/components/update_client/action_runner.cc
+++ b/chromium/components/update_client/action_runner.cc
@@ -13,19 +13,18 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/sequenced_task_runner.h"
+#include "base/single_thread_task_runner.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/update_client/component.h"
+#include "components/update_client/task_traits.h"
#include "components/update_client/update_client.h"
namespace update_client {
-ActionRunner::ActionRunner(
- const Component& component,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
- const std::vector<uint8_t>& key_hash)
+ActionRunner::ActionRunner(const Component& component,
+ const std::vector<uint8_t>& key_hash)
: component_(component),
- task_runner_(task_runner),
key_hash_(key_hash),
main_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
@@ -38,39 +37,34 @@ void ActionRunner::Run(const Callback& run_complete) {
run_complete_ = run_complete;
- task_runner_->PostTask(
- FROM_HERE, base::Bind(&ActionRunner::Unpack, base::Unretained(this)));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&ActionRunner::Unpack, base::Unretained(this)));
}
void ActionRunner::Unpack() {
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
-
const auto& installer = component_.crx_component().installer;
base::FilePath file_path;
installer->GetInstalledFile(component_.action_run(), &file_path);
- auto unpacker = base::MakeRefCounted<ComponentUnpacker>(
- key_hash_, file_path, installer, nullptr, task_runner_);
-
+ auto unpacker = base::MakeRefCounted<ComponentUnpacker>(key_hash_, file_path,
+ installer, nullptr);
unpacker->Unpack(
base::Bind(&ActionRunner::UnpackComplete, base::Unretained(this)));
}
void ActionRunner::UnpackComplete(const ComponentUnpacker::Result& result) {
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
-
if (result.error != UnpackerError::kNone) {
DCHECK(!base::DirectoryExists(result.unpack_path));
main_task_runner_->PostTask(
FROM_HERE,
- base::Bind(run_complete_, false, static_cast<int>(result.error),
- result.extended_error));
+ base::BindOnce(run_complete_, false, static_cast<int>(result.error),
+ result.extended_error));
return;
}
- task_runner_->PostTask(
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::BindOnce(&ActionRunner::RunCommand, base::Unretained(this),
MakeCommandLine(result.unpack_path)));
@@ -79,10 +73,8 @@ void ActionRunner::UnpackComplete(const ComponentUnpacker::Result& result) {
#if !defined(OS_WIN)
void ActionRunner::RunCommand(const base::CommandLine& cmdline) {
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
-
main_task_runner_->PostTask(FROM_HERE,
- base::Bind(run_complete_, false, -1, 0));
+ base::BindOnce(run_complete_, false, -1, 0));
}
base::CommandLine ActionRunner::MakeCommandLine(
diff --git a/chromium/components/update_client/action_runner.h b/chromium/components/update_client/action_runner.h
index b253ae0ccff..84c14ed56f8 100644
--- a/chromium/components/update_client/action_runner.h
+++ b/chromium/components/update_client/action_runner.h
@@ -20,7 +20,7 @@
namespace base {
class CommandLine;
class Process;
-class SequencedTaskRunner;
+class SingleThreadTaskRunner;
}
namespace update_client {
@@ -33,7 +33,6 @@ class ActionRunner {
base::Callback<void(bool succeeded, int error_code, int extra_code1)>;
ActionRunner(const Component& component,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const std::vector<uint8_t>& key_hash);
~ActionRunner();
@@ -50,14 +49,13 @@ class ActionRunner {
void WaitForCommand(base::Process process);
const Component& component_;
- const scoped_refptr<base::SequencedTaskRunner>& task_runner_;
// Contains the key hash of the CRX this object is allowed to run. This value
// is using during the unpacking of the CRX to verify its integrity.
const std::vector<uint8_t> key_hash_;
// Used to post callbacks to the main thread.
- scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
Callback run_complete_;
diff --git a/chromium/components/update_client/action_runner_win.cc b/chromium/components/update_client/action_runner_win.cc
index f6ce555a90e..3e082b96a70 100644
--- a/chromium/components/update_client/action_runner_win.cc
+++ b/chromium/components/update_client/action_runner_win.cc
@@ -11,8 +11,9 @@
#include "base/location.h"
#include "base/process/launch.h"
#include "base/process/process.h"
-#include "base/sequenced_task_runner.h"
+#include "base/single_thread_task_runner.h"
#include "base/task_scheduler/post_task.h"
+#include "components/update_client/task_traits.h"
namespace {
@@ -24,17 +25,12 @@ const base::FilePath::CharType kRecoveryFileName[] =
namespace update_client {
void ActionRunner::RunCommand(const base::CommandLine& cmdline) {
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
-
base::LaunchOptions options;
options.start_hidden = true;
base::Process process = base::LaunchProcess(cmdline, options);
- // This task joins a process, hence .WithBaseSyncPrimitives().
base::PostTaskWithTraits(
- FROM_HERE,
- {base::WithBaseSyncPrimitives(), base::TaskPriority::BACKGROUND,
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
+ FROM_HERE, kTaskTraitsRunCommand,
base::BindOnce(&ActionRunner::WaitForCommand, base::Unretained(this),
std::move(process)));
}
@@ -44,9 +40,8 @@ void ActionRunner::WaitForCommand(base::Process process) {
const base::TimeDelta kMaxWaitTime = base::TimeDelta::FromSeconds(600);
const bool succeeded =
process.WaitForExitWithTimeout(kMaxWaitTime, &exit_code);
-
main_task_runner_->PostTask(
- FROM_HERE, base::Bind(run_complete_, succeeded, exit_code, 0));
+ FROM_HERE, base::BindOnce(run_complete_, succeeded, exit_code, 0));
}
base::CommandLine ActionRunner::MakeCommandLine(
diff --git a/chromium/components/update_client/background_downloader_win.cc b/chromium/components/update_client/background_downloader_win.cc
index feaef33a682..f4f82d19b13 100644
--- a/chromium/components/update_client/background_downloader_win.cc
+++ b/chromium/components/update_client/background_downloader_win.cc
@@ -30,6 +30,7 @@
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "base/win/scoped_co_mem.h"
+#include "components/update_client/task_traits.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/utils.h"
#include "url/gurl.h"
@@ -398,13 +399,10 @@ void CleanupJob(const ComPtr<IBackgroundCopyJob>& job) {
} // namespace
BackgroundDownloader::BackgroundDownloader(
- std::unique_ptr<CrxDownloader> successor,
- net::URLRequestContextGetter* context_getter)
+ std::unique_ptr<CrxDownloader> successor)
: CrxDownloader(std::move(successor)),
com_task_runner_(base::CreateCOMSTATaskRunnerWithTraits(
- {base::MayBlock(), base::TaskPriority::BACKGROUND,
- base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN})),
- context_getter_(context_getter),
+ kTaskTraitsBackgroundDownloader)),
git_cookie_bits_manager_(0),
git_cookie_job_(0) {}
@@ -422,15 +420,15 @@ void BackgroundDownloader::StartTimer() {
void BackgroundDownloader::OnTimer() {
DCHECK(thread_checker_.CalledOnValidThread());
com_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&BackgroundDownloader::OnDownloading, base::Unretained(this)));
+ FROM_HERE, base::BindOnce(&BackgroundDownloader::OnDownloading,
+ base::Unretained(this)));
}
void BackgroundDownloader::DoStartDownload(const GURL& url) {
DCHECK(thread_checker_.CalledOnValidThread());
- com_task_runner_->PostTask(FROM_HERE,
- base::Bind(&BackgroundDownloader::BeginDownload,
- base::Unretained(this), url));
+ com_task_runner_->PostTask(
+ FROM_HERE, base::BindOnce(&BackgroundDownloader::BeginDownload,
+ base::Unretained(this), url));
}
// Called one time when this class is asked to do a download.
@@ -447,9 +445,9 @@ void BackgroundDownloader::BeginDownload(const GURL& url) {
}
ResetInterfacePointers();
- main_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&BackgroundDownloader::StartTimer, base::Unretained(this)));
+ main_task_runner()->PostTask(FROM_HERE,
+ base::BindOnce(&BackgroundDownloader::StartTimer,
+ base::Unretained(this)));
}
// Creates or opens an existing BITS job to download the |url|, and handles
@@ -538,9 +536,9 @@ void BackgroundDownloader::OnDownloading() {
return;
ResetInterfacePointers();
- main_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&BackgroundDownloader::StartTimer, base::Unretained(this)));
+ main_task_runner()->PostTask(FROM_HERE,
+ base::BindOnce(&BackgroundDownloader::StartTimer,
+ base::Unretained(this)));
}
// Completes the BITS download, picks up the file path of the response, and
@@ -584,9 +582,9 @@ void BackgroundDownloader::EndDownload(HRESULT error) {
result.downloaded_bytes = downloaded_bytes;
result.total_bytes = total_bytes;
main_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&BackgroundDownloader::OnDownloadComplete,
- base::Unretained(this), is_handled, result, download_metrics));
+ FROM_HERE, base::BindOnce(&BackgroundDownloader::OnDownloadComplete,
+ base::Unretained(this), is_handled, result,
+ download_metrics));
// Once the task is posted to the the main thread, this object may be deleted
// by its owner. It is not safe to access members of this object on this task
@@ -674,8 +672,8 @@ bool BackgroundDownloader::OnStateTransferring() {
result.total_bytes = total_bytes;
main_task_runner()->PostTask(
- FROM_HERE, base::Bind(&BackgroundDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&BackgroundDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
return false;
}
diff --git a/chromium/components/update_client/background_downloader_win.h b/chromium/components/update_client/background_downloader_win.h
index 7549b709455..28b96938642 100644
--- a/chromium/components/update_client/background_downloader_win.h
+++ b/chromium/components/update_client/background_downloader_win.h
@@ -38,10 +38,8 @@ namespace update_client {
// a sequenced task runner, which handles all client COM interaction with
// the BITS service.
class BackgroundDownloader : public CrxDownloader {
- protected:
- friend class CrxDownloader;
- BackgroundDownloader(std::unique_ptr<CrxDownloader> successor,
- net::URLRequestContextGetter* context_getter);
+ public:
+ explicit BackgroundDownloader(std::unique_ptr<CrxDownloader> successor);
~BackgroundDownloader() override;
private:
@@ -129,8 +127,6 @@ class BackgroundDownloader : public CrxDownloader {
// Executes blocking COM calls to BITS.
scoped_refptr<base::SequencedTaskRunner> com_task_runner_;
- net::URLRequestContextGetter* context_getter_;
-
// The timer has thread affinity. This member is initialized and destroyed
// on the main task runner.
std::unique_ptr<base::OneShotTimer> timer_;
diff --git a/chromium/components/update_client/component.cc b/chromium/components/update_client/component.cc
index 750ee8ae18d..cd2b0d88d3b 100644
--- a/chromium/components/update_client/component.cc
+++ b/chromium/components/update_client/component.cc
@@ -14,11 +14,13 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/single_thread_task_runner.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/update_client/action_runner.h"
#include "components/update_client/component_unpacker.h"
#include "components/update_client/configurator.h"
#include "components/update_client/protocol_builder.h"
+#include "components/update_client/task_traits.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/update_engine.h"
@@ -64,14 +66,10 @@ using InstallOnBlockingTaskRunnerCompleteCallback =
base::Callback<void(int error_category, int error_code, int extra_code1)>;
CrxInstaller::Result DoInstallOnBlockingTaskRunner(
- const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
- const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const base::FilePath& unpack_path,
const std::string& fingerprint,
const scoped_refptr<CrxInstaller>& installer,
InstallOnBlockingTaskRunnerCompleteCallback callback) {
- DCHECK(blocking_task_runner->RunsTasksInCurrentSequence());
-
if (static_cast<int>(fingerprint.size()) !=
base::WriteFile(
unpack_path.Append(FILE_PATH_LITERAL("manifest.fingerprint")),
@@ -88,70 +86,60 @@ CrxInstaller::Result DoInstallOnBlockingTaskRunner(
void InstallOnBlockingTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
- const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const base::FilePath& unpack_path,
const std::string& fingerprint,
const scoped_refptr<CrxInstaller>& installer,
InstallOnBlockingTaskRunnerCompleteCallback callback) {
- DCHECK(blocking_task_runner->RunsTasksInCurrentSequence());
-
DCHECK(base::DirectoryExists(unpack_path));
- const auto result = DoInstallOnBlockingTaskRunner(
- main_task_runner, blocking_task_runner, unpack_path, fingerprint,
- installer, callback);
+ const auto result = DoInstallOnBlockingTaskRunner(unpack_path, fingerprint,
+ installer, callback);
base::DeleteFile(unpack_path, true);
const ErrorCategory error_category =
result.error ? ErrorCategory::kInstallError : ErrorCategory::kErrorNone;
main_task_runner->PostTask(
FROM_HERE,
- base::Bind(callback, static_cast<int>(error_category),
- static_cast<int>(result.error), result.extended_error));
+ base::BindOnce(callback, static_cast<int>(error_category),
+ static_cast<int>(result.error), result.extended_error));
}
void UnpackCompleteOnBlockingTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
- const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const base::FilePath& crx_path,
const std::string& fingerprint,
const scoped_refptr<CrxInstaller>& installer,
InstallOnBlockingTaskRunnerCompleteCallback callback,
const ComponentUnpacker::Result& result) {
- DCHECK(blocking_task_runner->RunsTasksInCurrentSequence());
-
update_client::DeleteFileAndEmptyParentDirectory(crx_path);
if (result.error != UnpackerError::kNone) {
main_task_runner->PostTask(
FROM_HERE,
- base::Bind(callback, static_cast<int>(ErrorCategory::kUnpackError),
- static_cast<int>(result.error), result.extended_error));
+ base::BindOnce(callback, static_cast<int>(ErrorCategory::kUnpackError),
+ static_cast<int>(result.error), result.extended_error));
return;
}
- blocking_task_runner->PostTask(
- FROM_HERE, base::Bind(&InstallOnBlockingTaskRunner, main_task_runner,
- blocking_task_runner, result.unpack_path,
- fingerprint, installer, callback));
+ base::PostTaskWithTraits(
+ FROM_HERE, kTaskTraits,
+ base::BindOnce(&InstallOnBlockingTaskRunner, main_task_runner,
+ result.unpack_path, fingerprint, installer, callback));
}
void StartInstallOnBlockingTaskRunner(
const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
- const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
const std::vector<uint8_t>& pk_hash,
const base::FilePath& crx_path,
const std::string& fingerprint,
const scoped_refptr<CrxInstaller>& installer,
const scoped_refptr<OutOfProcessPatcher>& oop_patcher,
InstallOnBlockingTaskRunnerCompleteCallback callback) {
- DCHECK(blocking_task_runner->RunsTasksInCurrentSequence());
-
auto unpacker = base::MakeRefCounted<ComponentUnpacker>(
- pk_hash, crx_path, installer, oop_patcher, blocking_task_runner);
+ pk_hash, crx_path, installer, oop_patcher);
unpacker->Unpack(base::Bind(&UnpackCompleteOnBlockingTaskRunner,
- main_task_runner, blocking_task_runner, crx_path,
- fingerprint, installer, callback));
+ main_task_runner, crx_path, fingerprint,
+ installer, callback));
}
} // namespace
@@ -296,7 +284,7 @@ void Component::State::TransitionState(std::unique_ptr<State> next_state) {
is_final_ = true;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(callback(), base::Passed(&next_state)));
+ FROM_HERE, base::BindOnce(callback(), base::Passed(&next_state)));
}
Component::StateNew::StateNew(Component* component)
@@ -583,16 +571,16 @@ void Component::StateUpdatingDiff::DoHandle() {
component.NotifyObservers(Events::COMPONENT_UPDATE_READY);
- update_context.blocking_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&update_client::StartInstallOnBlockingTaskRunner,
- base::ThreadTaskRunnerHandle::Get(),
- update_context.blocking_task_runner,
- component.crx_component_.pk_hash, component.crx_path_,
- component.next_fp_, component.crx_component_.installer,
- update_context.config->CreateOutOfProcessPatcher(),
- base::Bind(&Component::StateUpdatingDiff::InstallComplete,
- base::Unretained(this))));
+ base::CreateSequencedTaskRunnerWithTraits(kTaskTraits)
+ ->PostTask(FROM_HERE,
+ base::BindOnce(
+ &update_client::StartInstallOnBlockingTaskRunner,
+ base::ThreadTaskRunnerHandle::Get(),
+ component.crx_component_.pk_hash, component.crx_path_,
+ component.next_fp_, component.crx_component_.installer,
+ update_context.config->CreateOutOfProcessPatcher(),
+ base::Bind(&Component::StateUpdatingDiff::InstallComplete,
+ base::Unretained(this))));
}
void Component::StateUpdatingDiff::InstallComplete(int error_category,
@@ -642,16 +630,16 @@ void Component::StateUpdating::DoHandle() {
component.NotifyObservers(Events::COMPONENT_UPDATE_READY);
- update_context.blocking_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&update_client::StartInstallOnBlockingTaskRunner,
- base::ThreadTaskRunnerHandle::Get(),
- update_context.blocking_task_runner,
- component.crx_component_.pk_hash, component.crx_path_,
- component.next_fp_, component.crx_component_.installer,
- update_context.config->CreateOutOfProcessPatcher(),
- base::Bind(&Component::StateUpdating::InstallComplete,
- base::Unretained(this))));
+ base::CreateSequencedTaskRunnerWithTraits(kTaskTraits)
+ ->PostTask(
+ FROM_HERE,
+ base::BindOnce(&update_client::StartInstallOnBlockingTaskRunner,
+ base::ThreadTaskRunnerHandle::Get(),
+ component.crx_component_.pk_hash, component.crx_path_,
+ component.next_fp_, component.crx_component_.installer,
+ update_context.config->CreateOutOfProcessPatcher(),
+ base::Bind(&Component::StateUpdating::InstallComplete,
+ base::Unretained(this))));
}
void Component::StateUpdating::InstallComplete(int error_category,
@@ -733,8 +721,7 @@ void Component::StateRun::DoHandle() {
const auto& component = State::component();
action_runner_ = base::MakeUnique<ActionRunner>(
- component, component.update_context_.blocking_task_runner,
- component.update_context_.config->GetRunActionKeyHash());
+ component, component.update_context_.config->GetRunActionKeyHash());
action_runner_->Run(
base::Bind(&StateRun::ActionRunComplete, base::Unretained(this)));
diff --git a/chromium/components/update_client/component_patcher.cc b/chromium/components/update_client/component_patcher.cc
index 0bd27dd2776..a69860c5b85 100644
--- a/chromium/components/update_client/component_patcher.cc
+++ b/chromium/components/update_client/component_patcher.cc
@@ -14,6 +14,7 @@
#include "base/json/json_file_value_serializer.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "components/update_client/component_patcher_operation.h"
#include "components/update_client/update_client.h"
@@ -45,23 +46,20 @@ ComponentPatcher::ComponentPatcher(
const base::FilePath& input_dir,
const base::FilePath& unpack_dir,
scoped_refptr<CrxInstaller> installer,
- scoped_refptr<OutOfProcessPatcher> out_of_process_patcher,
- scoped_refptr<base::SequencedTaskRunner> task_runner)
+ scoped_refptr<OutOfProcessPatcher> out_of_process_patcher)
: input_dir_(input_dir),
unpack_dir_(unpack_dir),
installer_(installer),
- out_of_process_patcher_(out_of_process_patcher),
- task_runner_(task_runner) {
-}
+ out_of_process_patcher_(out_of_process_patcher) {}
ComponentPatcher::~ComponentPatcher() {
}
void ComponentPatcher::Start(const Callback& callback) {
callback_ = callback;
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&ComponentPatcher::StartPatching,
- scoped_refptr<ComponentPatcher>(this)));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&ComponentPatcher::StartPatching,
+ scoped_refptr<ComponentPatcher>(this)));
}
void ComponentPatcher::StartPatching() {
@@ -97,8 +95,7 @@ void ComponentPatcher::PatchNextFile() {
}
current_operation_->Run(command_args, input_dir_, unpack_dir_, installer_,
base::Bind(&ComponentPatcher::DonePatchingFile,
- scoped_refptr<ComponentPatcher>(this)),
- task_runner_);
+ scoped_refptr<ComponentPatcher>(this)));
}
void ComponentPatcher::DonePatchingFile(UnpackerError error,
@@ -113,8 +110,8 @@ void ComponentPatcher::DonePatchingFile(UnpackerError error,
void ComponentPatcher::DonePatching(UnpackerError error, int extended_error) {
current_operation_ = NULL;
- task_runner_->PostTask(FROM_HERE,
- base::Bind(callback_, error, extended_error));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(callback_, error, extended_error));
callback_.Reset();
}
diff --git a/chromium/components/update_client/component_patcher.h b/chromium/components/update_client/component_patcher.h
index 3302d177305..2179778ad94 100644
--- a/chromium/components/update_client/component_patcher.h
+++ b/chromium/components/update_client/component_patcher.h
@@ -32,7 +32,6 @@
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner.h"
#include "base/values.h"
#include "components/update_client/component_unpacker.h"
@@ -67,8 +66,7 @@ class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> {
ComponentPatcher(const base::FilePath& input_dir,
const base::FilePath& unpack_dir,
scoped_refptr<CrxInstaller> installer,
- scoped_refptr<OutOfProcessPatcher> out_of_process_patcher,
- scoped_refptr<base::SequencedTaskRunner> task_runner);
+ scoped_refptr<OutOfProcessPatcher> out_of_process_patcher);
// Starts patching files. This member function returns immediately, after
// posting a task to do the patching. When patching has been completed,
@@ -97,7 +95,6 @@ class ComponentPatcher : public base::RefCountedThreadSafe<ComponentPatcher> {
std::unique_ptr<base::ListValue> commands_;
base::ListValue::const_iterator next_command_;
scoped_refptr<DeltaUpdateOp> current_operation_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(ComponentPatcher);
};
diff --git a/chromium/components/update_client/component_patcher_operation.cc b/chromium/components/update_client/component_patcher_operation.cc
index be7be1f3208..6fbde6b7aef 100644
--- a/chromium/components/update_client/component_patcher_operation.cc
+++ b/chromium/components/update_client/component_patcher_operation.cc
@@ -12,6 +12,8 @@
#include "base/files/memory_mapped_file.h"
#include "base/location.h"
#include "base/strings/string_number_conversions.h"
+#include "base/task_scheduler/post_task.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "components/update_client/out_of_process_patcher.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
@@ -57,15 +59,12 @@ DeltaUpdateOp::DeltaUpdateOp() {
DeltaUpdateOp::~DeltaUpdateOp() {
}
-void DeltaUpdateOp::Run(
- const base::DictionaryValue* command_args,
- const base::FilePath& input_dir,
- const base::FilePath& unpack_dir,
- const scoped_refptr<CrxInstaller>& installer,
- const ComponentPatcher::Callback& callback,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner) {
+void DeltaUpdateOp::Run(const base::DictionaryValue* command_args,
+ const base::FilePath& input_dir,
+ const base::FilePath& unpack_dir,
+ const scoped_refptr<CrxInstaller>& installer,
+ const ComponentPatcher::Callback& callback) {
callback_ = callback;
- task_runner_ = task_runner;
std::string output_rel_path;
if (!command_args->GetString(kOutput, &output_rel_path) ||
!command_args->GetString(kSha256, &output_sha256_)) {
@@ -97,8 +96,8 @@ void DeltaUpdateOp::Run(
void DeltaUpdateOp::DoneRunning(UnpackerError error, int extended_error) {
if (error == UnpackerError::kNone)
error = CheckHash();
- task_runner_->PostTask(FROM_HERE,
- base::Bind(callback_, error, extended_error));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(callback_, error, extended_error));
callback_.Reset();
}
@@ -110,10 +109,6 @@ UnpackerError DeltaUpdateOp::CheckHash() {
: UnpackerError::kDeltaVerificationFailure;
}
-scoped_refptr<base::SequencedTaskRunner> DeltaUpdateOp::GetTaskRunner() {
- return task_runner_;
-}
-
DeltaUpdateOpCopy::DeltaUpdateOpCopy() {
}
@@ -200,8 +195,7 @@ UnpackerError DeltaUpdateOpPatch::DoParseArguments(
void DeltaUpdateOpPatch::DoRun(const ComponentPatcher::Callback& callback) {
if (out_of_process_patcher_.get()) {
out_of_process_patcher_->Patch(
- operation_, GetTaskRunner(), input_abs_path_, patch_abs_path_,
- output_abs_path_,
+ operation_, input_abs_path_, patch_abs_path_, output_abs_path_,
base::Bind(&DeltaUpdateOpPatch::DonePatching, this, callback));
return;
}
diff --git a/chromium/components/update_client/component_patcher_operation.h b/chromium/components/update_client/component_patcher_operation.h
index 4520b986ffb..553f76f8d49 100644
--- a/chromium/components/update_client/component_patcher_operation.h
+++ b/chromium/components/update_client/component_patcher_operation.h
@@ -11,7 +11,6 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner.h"
#include "components/update_client/component_patcher.h"
#include "components/update_client/component_unpacker.h"
@@ -41,14 +40,11 @@ class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> {
const base::FilePath& input_dir,
const base::FilePath& unpack_dir,
const scoped_refptr<CrxInstaller>& installer,
- const ComponentPatcher::Callback& callback,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner);
+ const ComponentPatcher::Callback& callback);
protected:
virtual ~DeltaUpdateOp();
- scoped_refptr<base::SequencedTaskRunner> GetTaskRunner();
-
std::string output_sha256_;
base::FilePath output_abs_path_;
@@ -76,7 +72,6 @@ class DeltaUpdateOp : public base::RefCountedThreadSafe<DeltaUpdateOp> {
void DoneRunning(UnpackerError error, int extended_error);
ComponentPatcher::Callback callback_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(DeltaUpdateOp);
};
diff --git a/chromium/components/update_client/component_patcher_unittest.cc b/chromium/components/update_client/component_patcher_unittest.cc
index 19876268423..b6dfe2cbfed 100644
--- a/chromium/components/update_client/component_patcher_unittest.cc
+++ b/chromium/components/update_client/component_patcher_unittest.cc
@@ -11,7 +11,6 @@
#include "base/macros.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/update_client/component_patcher.h"
#include "components/update_client/component_patcher_operation.h"
@@ -63,12 +62,14 @@ base::FilePath test_file(const char* file) {
namespace update_client {
-ComponentPatcherOperationTest::ComponentPatcherOperationTest() {
+ComponentPatcherOperationTest::ComponentPatcherOperationTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::IO) {
EXPECT_TRUE(unpack_dir_.CreateUniqueTempDir());
EXPECT_TRUE(input_dir_.CreateUniqueTempDir());
EXPECT_TRUE(installed_dir_.CreateUniqueTempDir());
- installer_ = new ReadOnlyTestInstaller(installed_dir_.GetPath());
- task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ installer_ =
+ base::MakeRefCounted<ReadOnlyTestInstaller>(installed_dir_.GetPath());
}
ComponentPatcherOperationTest::~ComponentPatcherOperationTest() {
@@ -90,9 +91,8 @@ TEST_F(ComponentPatcherOperationTest, CheckCreateOperation) {
TestCallback callback;
scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCreate();
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(), NULL,
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
+ base::Bind(&TestCallback::Set, base::Unretained(&callback)));
+ scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(true, callback.called_);
EXPECT_EQ(UnpackerError::kNone, callback.error_);
@@ -119,9 +119,8 @@ TEST_F(ComponentPatcherOperationTest, CheckCopyOperation) {
scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCopy();
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
+ base::Bind(&TestCallback::Set, base::Unretained(&callback)));
+ scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(true, callback.called_);
EXPECT_EQ(UnpackerError::kNone, callback.error_);
@@ -153,9 +152,8 @@ TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) {
CreateDeltaUpdateOp("courgette", NULL /* out_of_process_patcher */);
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
+ base::Bind(&TestCallback::Set, base::Unretained(&callback)));
+ scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(true, callback.called_);
EXPECT_EQ(UnpackerError::kNone, callback.error_);
@@ -187,9 +185,8 @@ TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) {
CreateDeltaUpdateOp("bsdiff", NULL /* out_of_process_patcher */);
op->Run(command_args.get(), input_dir_.GetPath(), unpack_dir_.GetPath(),
installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
+ base::Bind(&TestCallback::Set, base::Unretained(&callback)));
+ scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(true, callback.called_);
EXPECT_EQ(UnpackerError::kNone, callback.error_);
diff --git a/chromium/components/update_client/component_patcher_unittest.h b/chromium/components/update_client/component_patcher_unittest.h
index b642a7c71e6..bf5168c308a 100644
--- a/chromium/components/update_client/component_patcher_unittest.h
+++ b/chromium/components/update_client/component_patcher_unittest.h
@@ -9,8 +9,9 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/message_loop/message_loop.h"
+#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h"
+#include "base/test/scoped_task_environment.h"
#include "courgette/courgette.h"
#include "courgette/third_party/bsdiff/bsdiff.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,14 +29,11 @@ class ComponentPatcherOperationTest : public testing::Test {
~ComponentPatcherOperationTest() override;
protected:
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
base::ScopedTempDir input_dir_;
base::ScopedTempDir installed_dir_;
base::ScopedTempDir unpack_dir_;
scoped_refptr<ReadOnlyTestInstaller> installer_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
-
- private:
- base::MessageLoopForIO loop_;
};
} // namespace update_client
diff --git a/chromium/components/update_client/component_unpacker.cc b/chromium/components/update_client/component_unpacker.cc
index 50444e80d9e..f9ef280666d 100644
--- a/chromium/components/update_client/component_unpacker.cc
+++ b/chromium/components/update_client/component_unpacker.cc
@@ -19,6 +19,7 @@
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "components/crx_file/crx_verifier.h"
#include "components/update_client/component_patcher.h"
@@ -54,16 +55,14 @@ ComponentUnpacker::ComponentUnpacker(
const std::vector<uint8_t>& pk_hash,
const base::FilePath& path,
const scoped_refptr<CrxInstaller>& installer,
- const scoped_refptr<OutOfProcessPatcher>& oop_patcher,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner)
+ const scoped_refptr<OutOfProcessPatcher>& oop_patcher)
: pk_hash_(pk_hash),
path_(path),
is_delta_(false),
installer_(installer),
oop_patcher_(oop_patcher),
error_(UnpackerError::kNone),
- extended_error_(0),
- task_runner_(task_runner) {}
+ extended_error_(0) {}
ComponentUnpacker::~ComponentUnpacker() {}
@@ -125,18 +124,18 @@ bool ComponentUnpacker::BeginPatching() {
error_ = UnpackerError::kUnzipPathError;
return false;
}
- patcher_ = new ComponentPatcher(unpack_diff_path_, unpack_path_, installer_,
- oop_patcher_, task_runner_);
- task_runner_->PostTask(
+ patcher_ = base::MakeRefCounted<ComponentPatcher>(
+ unpack_diff_path_, unpack_path_, installer_, oop_patcher_);
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&ComponentPatcher::Start, patcher_,
- base::Bind(&ComponentUnpacker::EndPatching,
- scoped_refptr<ComponentUnpacker>(this))));
+ base::BindOnce(&ComponentPatcher::Start, patcher_,
+ base::Bind(&ComponentUnpacker::EndPatching,
+ scoped_refptr<ComponentUnpacker>(this))));
} else {
- task_runner_->PostTask(FROM_HERE,
- base::Bind(&ComponentUnpacker::EndPatching,
- scoped_refptr<ComponentUnpacker>(this),
- UnpackerError::kNone, 0));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(&ComponentUnpacker::EndPatching,
+ scoped_refptr<ComponentUnpacker>(this),
+ UnpackerError::kNone, 0));
}
return true;
}
@@ -161,7 +160,8 @@ void ComponentUnpacker::EndUnpacking() {
if (error_ == UnpackerError::kNone)
result.unpack_path = unpack_path_;
- task_runner_->PostTask(FROM_HERE, base::Bind(callback_, result));
+ base::SequencedTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(callback_, result));
}
} // namespace update_client
diff --git a/chromium/components/update_client/component_unpacker.h b/chromium/components/update_client/component_unpacker.h
index 54fc6a9094c..d0b5259fb5c 100644
--- a/chromium/components/update_client/component_unpacker.h
+++ b/chromium/components/update_client/component_unpacker.h
@@ -16,7 +16,6 @@
#include "base/json/json_file_value_serializer.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner.h"
#include "components/update_client/out_of_process_patcher.h"
#include "components/update_client/update_client_errors.h"
@@ -84,12 +83,10 @@ class ComponentUnpacker : public base::RefCountedThreadSafe<ComponentUnpacker> {
// Constructs an unpacker for a specific component unpacking operation.
// |pk_hash| is the expected/ public key SHA256 hash. |path| is the current
// location of the CRX.
- ComponentUnpacker(
- const std::vector<uint8_t>& pk_hash,
- const base::FilePath& path,
- const scoped_refptr<CrxInstaller>& installer,
- const scoped_refptr<OutOfProcessPatcher>& oop_patcher,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner);
+ ComponentUnpacker(const std::vector<uint8_t>& pk_hash,
+ const base::FilePath& path,
+ const scoped_refptr<CrxInstaller>& installer,
+ const scoped_refptr<OutOfProcessPatcher>& oop_patcher);
// Begins the actual unpacking of the files. May invoke a patcher and the
// component installer if the package is a differential update.
@@ -135,7 +132,6 @@ class ComponentUnpacker : public base::RefCountedThreadSafe<ComponentUnpacker> {
scoped_refptr<OutOfProcessPatcher> oop_patcher_;
UnpackerError error_;
int extended_error_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(ComponentUnpacker);
};
diff --git a/chromium/components/update_client/component_unpacker_unittest.cc b/chromium/components/update_client/component_unpacker_unittest.cc
index 1488c3273a8..65eca6d7049 100644
--- a/chromium/components/update_client/component_unpacker_unittest.cc
+++ b/chromium/components/update_client/component_unpacker_unittest.cc
@@ -12,6 +12,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
+#include "base/memory/ref_counted.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/task_scheduler/post_task.h"
@@ -78,24 +79,14 @@ class ComponentUnpackerTest : public testing::Test {
const scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_ =
base::ThreadTaskRunnerHandle::Get();
base::RunLoop runloop_;
- base::Closure quit_closure_;
-
- scoped_refptr<update_client::TestConfigurator> config_;
+ const base::Closure quit_closure_ = runloop_.QuitClosure();
ComponentUnpacker::Result result_;
};
-ComponentUnpackerTest::ComponentUnpackerTest()
- : scoped_task_environment_(
- base::test::ScopedTaskEnvironment::MainThreadType::UI) {
- quit_closure_ = runloop_.QuitClosure();
-
- config_ = new TestConfigurator(
- base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}),
- base::ThreadTaskRunnerHandle::Get());
-}
+ComponentUnpackerTest::ComponentUnpackerTest() = default;
-ComponentUnpackerTest::~ComponentUnpackerTest() {}
+ComponentUnpackerTest::~ComponentUnpackerTest() = default;
void ComponentUnpackerTest::RunThreads() {
runloop_.Run();
@@ -108,10 +99,10 @@ void ComponentUnpackerTest::UnpackComplete(
}
TEST_F(ComponentUnpackerTest, UnpackFullCrx) {
- scoped_refptr<ComponentUnpacker> component_unpacker = new ComponentUnpacker(
- std::vector<uint8_t>(std::begin(jebg_hash), std::end(jebg_hash)),
- test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"), nullptr, nullptr,
- config_->GetSequencedTaskRunner());
+ scoped_refptr<ComponentUnpacker> component_unpacker =
+ base::MakeRefCounted<ComponentUnpacker>(
+ std::vector<uint8_t>(std::begin(jebg_hash), std::end(jebg_hash)),
+ test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"), nullptr, nullptr);
component_unpacker->Unpack(base::Bind(&ComponentUnpackerTest::UnpackComplete,
base::Unretained(this)));
RunThreads();
@@ -138,10 +129,10 @@ TEST_F(ComponentUnpackerTest, UnpackFullCrx) {
}
TEST_F(ComponentUnpackerTest, UnpackFileNotFound) {
- scoped_refptr<ComponentUnpacker> component_unpacker = new ComponentUnpacker(
- std::vector<uint8_t>(std::begin(jebg_hash), std::end(jebg_hash)),
- test_file("file-not-found.crx"), nullptr, nullptr,
- config_->GetSequencedTaskRunner());
+ scoped_refptr<ComponentUnpacker> component_unpacker =
+ base::MakeRefCounted<ComponentUnpacker>(
+ std::vector<uint8_t>(std::begin(jebg_hash), std::end(jebg_hash)),
+ test_file("file-not-found.crx"), nullptr, nullptr);
component_unpacker->Unpack(base::Bind(&ComponentUnpackerTest::UnpackComplete,
base::Unretained(this)));
RunThreads();
@@ -155,10 +146,10 @@ TEST_F(ComponentUnpackerTest, UnpackFileNotFound) {
// Tests a mismatch between the public key hash and the id of the component.
TEST_F(ComponentUnpackerTest, UnpackFileHashMismatch) {
- scoped_refptr<ComponentUnpacker> component_unpacker = new ComponentUnpacker(
- std::vector<uint8_t>(std::begin(abag_hash), std::end(abag_hash)),
- test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"), nullptr, nullptr,
- config_->GetSequencedTaskRunner());
+ scoped_refptr<ComponentUnpacker> component_unpacker =
+ base::MakeRefCounted<ComponentUnpacker>(
+ std::vector<uint8_t>(std::begin(abag_hash), std::end(abag_hash)),
+ test_file("jebgalgnebhfojomionfpkfelancnnkf.crx"), nullptr, nullptr);
component_unpacker->Unpack(base::Bind(&ComponentUnpackerTest::UnpackComplete,
base::Unretained(this)));
RunThreads();
diff --git a/chromium/components/update_client/configurator.h b/chromium/components/update_client/configurator.h
index ddb5b5d29f6..44a2d04e018 100644
--- a/chromium/components/update_client/configurator.h
+++ b/chromium/components/update_client/configurator.h
@@ -15,7 +15,6 @@ class GURL;
class PrefService;
namespace base {
-class SequencedTaskRunner;
class Version;
}
@@ -116,10 +115,6 @@ class Configurator : public base::RefCountedThreadSafe<Configurator> {
// True if signing of update checks is enabled.
virtual bool EnabledCupSigning() const = 0;
- // Gets a task runner to a blocking pool of threads suitable for worker jobs.
- virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
- const = 0;
-
// Returns a PrefService that the update_client can use to store persistent
// update information. The PrefService must outlive the entire update_client,
// and be safe to access from the thread the update_client is constructed
diff --git a/chromium/components/update_client/crx_downloader.cc b/chromium/components/update_client/crx_downloader.cc
index afdfdbf6d8f..b75be30172c 100644
--- a/chromium/components/update_client/crx_downloader.cc
+++ b/chromium/components/update_client/crx_downloader.cc
@@ -11,6 +11,7 @@
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -18,6 +19,7 @@
#if defined(OS_WIN)
#include "components/update_client/background_downloader_win.h"
#endif
+#include "components/update_client/task_traits.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/url_fetcher_downloader.h"
#include "components/update_client/utils.h"
@@ -41,13 +43,13 @@ CrxDownloader::DownloadMetrics::DownloadMetrics()
std::unique_ptr<CrxDownloader> CrxDownloader::Create(
bool is_background_download,
net::URLRequestContextGetter* context_getter) {
- std::unique_ptr<CrxDownloader> url_fetcher_downloader(
- std::unique_ptr<CrxDownloader>(new UrlFetcherDownloader(
- std::unique_ptr<CrxDownloader>(), context_getter)));
+ std::unique_ptr<CrxDownloader> url_fetcher_downloader =
+ base::MakeUnique<UrlFetcherDownloader>(nullptr, context_getter);
+
#if defined(OS_WIN)
if (is_background_download) {
- return std::unique_ptr<CrxDownloader>(new BackgroundDownloader(
- std::move(url_fetcher_downloader), context_getter));
+ return base::MakeUnique<BackgroundDownloader>(
+ std::move(url_fetcher_downloader));
}
#endif
@@ -105,7 +107,7 @@ void CrxDownloader::StartDownload(const std::vector<GURL>& urls,
Result result;
result.error = static_cast<int>(error);
main_task_runner()->PostTask(FROM_HERE,
- base::Bind(download_callback, result));
+ base::BindOnce(download_callback, result));
return;
}
@@ -125,16 +127,14 @@ void CrxDownloader::OnDownloadComplete(
if (!result.error)
base::PostTaskWithTraits(
- FROM_HERE,
- {base::MayBlock(), base::TaskPriority::BACKGROUND,
- base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN},
- base::Bind(&CrxDownloader::VerifyResponse, base::Unretained(this),
- is_handled, result, download_metrics));
+ FROM_HERE, kTaskTraits,
+ base::BindOnce(&CrxDownloader::VerifyResponse, base::Unretained(this),
+ is_handled, result, download_metrics));
else
main_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&CrxDownloader::HandleDownloadError, base::Unretained(this),
- is_handled, result, download_metrics));
+ FROM_HERE, base::BindOnce(&CrxDownloader::HandleDownloadError,
+ base::Unretained(this), is_handled, result,
+ download_metrics));
}
void CrxDownloader::OnDownloadProgress(const Result& result) {
@@ -158,7 +158,7 @@ void CrxDownloader::VerifyResponse(bool is_handled,
if (VerifyFileHash256(result.response, expected_hash_)) {
download_metrics_.push_back(download_metrics);
main_task_runner()->PostTask(FROM_HERE,
- base::Bind(download_callback_, result));
+ base::BindOnce(download_callback_, result));
return;
}
@@ -171,9 +171,9 @@ void CrxDownloader::VerifyResponse(bool is_handled,
result.response.clear();
main_task_runner()->PostTask(
- FROM_HERE,
- base::Bind(&CrxDownloader::HandleDownloadError, base::Unretained(this),
- is_handled, result, download_metrics));
+ FROM_HERE, base::BindOnce(&CrxDownloader::HandleDownloadError,
+ base::Unretained(this), is_handled, result,
+ download_metrics));
}
void CrxDownloader::HandleDownloadError(
@@ -212,7 +212,7 @@ void CrxDownloader::HandleDownloadError(
// The download ends here since there is no url nor downloader to handle this
// download request further.
main_task_runner()->PostTask(FROM_HERE,
- base::Bind(download_callback_, result));
+ base::BindOnce(download_callback_, result));
}
} // namespace update_client
diff --git a/chromium/components/update_client/crx_downloader.h b/chromium/components/update_client/crx_downloader.h
index 0b6cae8981a..6c27ca77ac7 100644
--- a/chromium/components/update_client/crx_downloader.h
+++ b/chromium/components/update_client/crx_downloader.h
@@ -15,7 +15,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner.h"
+#include "base/single_thread_task_runner.h"
#include "base/threading/thread_checker.h"
#include "url/gurl.h"
@@ -136,7 +136,7 @@ class CrxDownloader {
// Returns the url which is currently being downloaded from.
GURL url() const;
- scoped_refptr<base::SequencedTaskRunner> main_task_runner() const {
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner() const {
return main_task_runner_;
}
@@ -154,7 +154,7 @@ class CrxDownloader {
base::ThreadChecker thread_checker_;
// Used to post callbacks to the main thread.
- scoped_refptr<base::SequencedTaskRunner> main_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
std::vector<GURL> urls_;
diff --git a/chromium/components/update_client/out_of_process_patcher.h b/chromium/components/update_client/out_of_process_patcher.h
index a41f01b223c..df0ee37ff79 100644
--- a/chromium/components/update_client/out_of_process_patcher.h
+++ b/chromium/components/update_client/out_of_process_patcher.h
@@ -12,7 +12,6 @@
namespace base {
class FilePath;
-class SequencedTaskRunner;
}
namespace update_client {
@@ -23,7 +22,6 @@ class OutOfProcessPatcher
public:
virtual void Patch(
const std::string& operation,
- const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const base::FilePath& input_abs_path,
const base::FilePath& patch_abs_path,
const base::FilePath& output_abs_path,
diff --git a/chromium/components/update_client/ping_manager.cc b/chromium/components/update_client/ping_manager.cc
index 66d9e2b970c..50d7b2cbe8a 100644
--- a/chromium/components/update_client/ping_manager.cc
+++ b/chromium/components/update_client/ping_manager.cc
@@ -16,7 +16,6 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
-#include "base/sequenced_task_runner.h"
#include "components/update_client/configurator.h"
#include "components/update_client/protocol_builder.h"
#include "components/update_client/request_sender.h"
diff --git a/chromium/components/update_client/ping_manager_unittest.cc b/chromium/components/update_client/ping_manager_unittest.cc
index 503a4d59528..b883d3766ab 100644
--- a/chromium/components/update_client/ping_manager_unittest.cc
+++ b/chromium/components/update_client/ping_manager_unittest.cc
@@ -50,9 +50,8 @@ class PingManagerTest : public testing::Test {
PingManagerTest::PingManagerTest() {}
void PingManagerTest::SetUp() {
- config_ = new TestConfigurator(base::ThreadTaskRunnerHandle::Get(),
- base::ThreadTaskRunnerHandle::Get());
- ping_manager_.reset(new PingManager(config_));
+ config_ = base::MakeRefCounted<TestConfigurator>();
+ ping_manager_ = base::MakeUnique<PingManager>(config_);
}
void PingManagerTest::TearDown() {
diff --git a/chromium/components/update_client/protocol_builder.cc b/chromium/components/update_client/protocol_builder.cc
index f8430b117a8..d662fcec75a 100644
--- a/chromium/components/update_client/protocol_builder.cc
+++ b/chromium/components/update_client/protocol_builder.cc
@@ -158,9 +158,7 @@ std::string BuildUninstalledEventElement(const Component& component) {
using base::StringAppendF;
std::string event;
- StringAppendF(&event, "<event eventtype=\"4\" extracode1=\"%d\"",
- component.extra_code1());
-
+ StringAppendF(&event, "<event eventtype=\"4\" eventresult=\"1\"");
if (component.extra_code1())
StringAppendF(&event, " extracode1=\"%d\"", component.extra_code1());
StringAppendF(&event, "/>");
diff --git a/chromium/components/update_client/request_sender.cc b/chromium/components/update_client/request_sender.cc
index 782ada6a270..af2b87b5fe7 100644
--- a/chromium/components/update_client/request_sender.cc
+++ b/chromium/components/update_client/request_sender.cc
@@ -11,7 +11,6 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/single_thread_task_runner.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/client_update_protocol/ecdsa.h"
@@ -26,14 +25,14 @@ namespace update_client {
namespace {
// This is an ECDSA prime256v1 named-curve key.
-const int kKeyVersion = 7;
+constexpr int kKeyVersion = 7;
const char kKeyPubBytesBase64[] =
"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEj0QKufXIOBN30DtKeOYA5NV64FfY"
"HDou4sGqtcNUIlxpTzIbO45rB45QILhW6aDTwwjWLR1YCqpEAGICvFs8dQ==";
// The ETag header carries the ECSDA signature of the protocol response, if
// signing has been used.
-const char kHeaderEtag[] = "ETag";
+constexpr const char* kHeaderEtag = "ETag";
// The server uses the optional X-Retry-After header to indicate that the
// current request should not be attempted again. Any response received along
@@ -47,17 +46,11 @@ const char kHeaderEtag[] = "ETag";
// The value of the header is the number of seconds to wait before trying to do
// a subsequent update check. The upper bound for the number of seconds to wait
// before trying to do a subsequent update check is capped at 24 hours.
-const char kHeaderXRetryAfter[] = "X-Retry-After";
-const int64_t kMaxRetryAfterSec = 24 * 60 * 60;
+constexpr const char* kHeaderXRetryAfter = "X-Retry-After";
+constexpr int64_t kMaxRetryAfterSec = 24 * 60 * 60;
} // namespace
-// This value is chosen not to conflict with network errors defined by
-// net/base/net_error_list.h. The callers don't have to handle this error in
-// any meaningful way, but this value may be reported in UMA stats, therefore
-// avoiding collisions with known network errors is desirable.
-int RequestSender::kErrorResponseNotTrusted = -10000;
-
RequestSender::RequestSender(const scoped_refptr<Configurator>& config)
: config_(config), use_signing_(false) {}
@@ -111,9 +104,9 @@ void RequestSender::SendInternal() {
SendProtocolRequest(url, request_body_, this, config_->RequestContext());
if (!url_fetcher_.get())
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&RequestSender::SendInternalComplete, base::Unretained(this),
- -1, std::string(), std::string(), 0));
+ FROM_HERE, base::BindOnce(&RequestSender::SendInternalComplete,
+ base::Unretained(this), -1, std::string(),
+ std::string(), 0));
}
void RequestSender::SendInternalComplete(int error,
@@ -123,8 +116,8 @@ void RequestSender::SendInternalComplete(int error,
if (!error) {
if (!use_signing_) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(request_sender_callback_, 0, response_body,
- retry_after_sec));
+ FROM_HERE, base::BindOnce(request_sender_callback_, 0, response_body,
+ retry_after_sec));
return;
}
@@ -132,8 +125,8 @@ void RequestSender::SendInternalComplete(int error,
DCHECK(signer_.get());
if (signer_->ValidateResponse(response_body, response_etag)) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(request_sender_callback_, 0, response_body,
- retry_after_sec));
+ FROM_HERE, base::BindOnce(request_sender_callback_, 0, response_body,
+ retry_after_sec));
return;
}
@@ -146,8 +139,8 @@ void RequestSender::SendInternalComplete(int error,
// should not send further request until the cooldown has expired.
if (retry_after_sec <= 0 && ++cur_url_ != urls_.end() &&
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&RequestSender::SendInternal, base::Unretained(this)))) {
+ FROM_HERE, base::BindOnce(&RequestSender::SendInternal,
+ base::Unretained(this)))) {
return;
}
@@ -174,16 +167,17 @@ void RequestSender::OnURLFetchComplete(const net::URLFetcher* source) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&RequestSender::SendInternalComplete,
- base::Unretained(this), fetch_error, response_body,
- GetStringHeaderValue(source, kHeaderEtag),
- static_cast<int>(retry_after_sec)));
+ FROM_HERE,
+ base::BindOnce(&RequestSender::SendInternalComplete,
+ base::Unretained(this), fetch_error, response_body,
+ GetStringHeaderValue(source, kHeaderEtag),
+ static_cast<int>(retry_after_sec)));
}
void RequestSender::HandleSendError(int error, int retry_after_sec) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(request_sender_callback_, error, std::string(),
- retry_after_sec));
+ FROM_HERE, base::BindOnce(request_sender_callback_, error, std::string(),
+ retry_after_sec));
}
std::string RequestSender::GetKey(const char* key_bytes_base64) {
diff --git a/chromium/components/update_client/request_sender.h b/chromium/components/update_client/request_sender.h
index f1ec16e95d4..e6ecbda9035 100644
--- a/chromium/components/update_client/request_sender.h
+++ b/chromium/components/update_client/request_sender.h
@@ -45,7 +45,11 @@ class RequestSender : public net::URLFetcherDelegate {
using RequestSenderCallback = base::Callback<
void(int error, const std::string& response, int retry_after_sec)>;
- static int kErrorResponseNotTrusted;
+ // This value is chosen not to conflict with network errors defined by
+ // net/base/net_error_list.h. The callers don't have to handle this error in
+ // any meaningful way, but this value may be reported in UMA stats, therefore
+ // avoiding collisions with known network errors is desirable.
+ enum : int { kErrorResponseNotTrusted = -10000 };
explicit RequestSender(const scoped_refptr<Configurator>& config);
~RequestSender() override;
diff --git a/chromium/components/update_client/request_sender_unittest.cc b/chromium/components/update_client/request_sender_unittest.cc
index 82a07c20dd6..d96e4da7e7f 100644
--- a/chromium/components/update_client/request_sender_unittest.cc
+++ b/chromium/components/update_client/request_sender_unittest.cc
@@ -9,11 +9,10 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
-#include "base/test/scoped_task_scheduler.h"
+#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/update_client/test_configurator.h"
#include "components/update_client/url_request_post_interceptor.h"
@@ -58,7 +57,8 @@ class RequestSenderTest : public testing::Test {
protected:
void Quit();
void RunThreads();
- void RunThreadsUntilIdle();
+
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
scoped_refptr<TestConfigurator> config_;
std::unique_ptr<RequestSender> request_sender_;
@@ -72,20 +72,19 @@ class RequestSenderTest : public testing::Test {
std::string response_;
private:
- base::MessageLoopForIO loop_;
- base::test::ScopedTaskScheduler scoped_task_scheduler_;
base::Closure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(RequestSenderTest);
};
-RequestSenderTest::RequestSenderTest() : scoped_task_scheduler_(&loop_) {}
+RequestSenderTest::RequestSenderTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::IO) {}
RequestSenderTest::~RequestSenderTest() {}
void RequestSenderTest::SetUp() {
- config_ = base::MakeRefCounted<TestConfigurator>(
- base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get());
+ config_ = base::MakeRefCounted<TestConfigurator>();
interceptor_factory_ =
base::MakeUnique<InterceptorFactory>(base::ThreadTaskRunnerHandle::Get());
post_interceptor_1_ =
@@ -107,8 +106,6 @@ void RequestSenderTest::TearDown() {
interceptor_factory_ = nullptr;
config_ = nullptr;
-
- RunThreadsUntilIdle();
}
void RequestSenderTest::RunThreads() {
@@ -120,11 +117,7 @@ void RequestSenderTest::RunThreads() {
// intercepts on the IO thread, run the threads until they are
// idle. The component updater service won't loop again until the loop count
// is set and the service is started.
- RunThreadsUntilIdle();
-}
-
-void RequestSenderTest::RunThreadsUntilIdle() {
- base::RunLoop().RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
void RequestSenderTest::Quit() {
diff --git a/chromium/components/update_client/task_send_uninstall_ping.cc b/chromium/components/update_client/task_send_uninstall_ping.cc
index bb5d96a5a76..70130ed3795 100644
--- a/chromium/components/update_client/task_send_uninstall_ping.cc
+++ b/chromium/components/update_client/task_send_uninstall_ping.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/version.h"
#include "components/update_client/update_client.h"
@@ -56,7 +55,7 @@ void TaskSendUninstallPing::TaskComplete(Error error) {
DCHECK(thread_checker_.CalledOnValidThread());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(callback_, this, error));
+ FROM_HERE, base::BindOnce(callback_, this, error));
}
} // namespace update_client
diff --git a/chromium/components/update_client/task_traits.h b/chromium/components/update_client/task_traits.h
new file mode 100644
index 00000000000..1a3d393b264
--- /dev/null
+++ b/chromium/components/update_client/task_traits.h
@@ -0,0 +1,28 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_UPDATE_CLIENT_TASK_TRAITS_H_
+#define COMPONENTS_UPDATE_CLIENT_TASK_TRAITS_H_
+
+#include "base/task_scheduler/task_traits.h"
+
+namespace update_client {
+
+constexpr base::TaskTraits kTaskTraits = {
+ base::MayBlock(), base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN};
+
+constexpr base::TaskTraits kTaskTraitsBackgroundDownloader = {
+ base::MayBlock(), base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN};
+
+// This task joins a process, hence .WithBaseSyncPrimitives().
+constexpr base::TaskTraits kTaskTraitsRunCommand = {
+ base::MayBlock(), base::WithBaseSyncPrimitives(),
+ base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN};
+
+} // namespace update_client
+
+#endif // COMPONENTS_UPDATE_CLIENT_TASK_TRAITS_H_
diff --git a/chromium/components/update_client/task_update.cc b/chromium/components/update_client/task_update.cc
index 3c85950b90f..b9fb47b1f1b 100644
--- a/chromium/components/update_client/task_update.cc
+++ b/chromium/components/update_client/task_update.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_engine.h"
@@ -56,7 +55,7 @@ void TaskUpdate::TaskComplete(Error error) {
DCHECK(thread_checker_.CalledOnValidThread());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(callback_, this, error));
+ FROM_HERE, base::BindOnce(callback_, this, error));
}
} // namespace update_client
diff --git a/chromium/components/update_client/test_configurator.cc b/chromium/components/update_client/test_configurator.cc
index ade005de167..a61c093701f 100644
--- a/chromium/components/update_client/test_configurator.cc
+++ b/chromium/components/update_client/test_configurator.cc
@@ -6,8 +6,7 @@
#include <utility>
-#include "base/sequenced_task_runner.h"
-#include "base/single_thread_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/version.h"
#include "components/prefs/pref_service.h"
#include "components/update_client/out_of_process_patcher.h"
@@ -27,16 +26,14 @@ std::vector<GURL> MakeDefaultUrls() {
} // namespace
-TestConfigurator::TestConfigurator(
- const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
- const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner)
- : worker_task_runner_(worker_task_runner),
- brand_("TEST"),
+TestConfigurator::TestConfigurator()
+ : brand_("TEST"),
initial_time_(0),
ondemand_time_(0),
enabled_cup_signing_(false),
enabled_component_updates_(true),
- context_(new net::TestURLRequestContextGetter(network_task_runner)) {}
+ context_(base::MakeRefCounted<net::TestURLRequestContextGetter>(
+ base::ThreadTaskRunnerHandle::Get())) {}
TestConfigurator::~TestConfigurator() {
}
@@ -163,12 +160,6 @@ void TestConfigurator::SetPingUrl(const GURL& url) {
ping_url_ = url;
}
-scoped_refptr<base::SequencedTaskRunner>
-TestConfigurator::GetSequencedTaskRunner() const {
- DCHECK(worker_task_runner_.get());
- return worker_task_runner_;
-}
-
PrefService* TestConfigurator::GetPrefService() const {
return nullptr;
}
diff --git a/chromium/components/update_client/test_configurator.h b/chromium/components/update_client/test_configurator.h
index fd0bc2f31df..01a9674ed73 100644
--- a/chromium/components/update_client/test_configurator.h
+++ b/chromium/components/update_client/test_configurator.h
@@ -18,11 +18,6 @@
class PrefService;
-namespace base {
-class SequencedTaskRunner;
-class SingleThreadTaskRunner;
-} // namespace base
-
namespace net {
class TestURLRequestContextGetter;
class URLRequestContextGetter;
@@ -61,9 +56,7 @@ const uint8_t gjpm_hash[] = {0x69, 0xfc, 0x41, 0xf6, 0x17, 0x20, 0xc6, 0x36,
class TestConfigurator : public Configurator {
public:
- TestConfigurator(
- const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
- const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
+ TestConfigurator();
// Overrrides for Configurator.
int InitialDelay() const override;
@@ -86,8 +79,6 @@ class TestConfigurator : public Configurator {
bool EnabledComponentUpdates() const override;
bool EnabledBackgroundDownloader() const override;
bool EnabledCupSigning() const override;
- scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
- const override;
PrefService* GetPrefService() const override;
bool IsPerUserInstall() const override;
std::vector<uint8_t> GetRunActionKeyHash() const override;
@@ -103,11 +94,8 @@ class TestConfigurator : public Configurator {
private:
friend class base::RefCountedThreadSafe<TestConfigurator>;
-
~TestConfigurator() override;
- scoped_refptr<base::SequencedTaskRunner> worker_task_runner_;
-
std::string brand_;
int initial_time_;
int ondemand_time_;
diff --git a/chromium/components/update_client/update_checker.cc b/chromium/components/update_client/update_checker.cc
index 4995f7500bc..dd4348d131d 100644
--- a/chromium/components/update_client/update_checker.cc
+++ b/chromium/components/update_client/update_checker.cc
@@ -17,6 +17,7 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/update_client/component.h"
@@ -25,6 +26,7 @@
#include "components/update_client/protocol_builder.h"
#include "components/update_client/protocol_parser.h"
#include "components/update_client/request_sender.h"
+#include "components/update_client/task_traits.h"
#include "components/update_client/update_client.h"
#include "components/update_client/updater_state.h"
#include "components/update_client/utils.h"
@@ -52,7 +54,7 @@ class UpdateCheckerImpl : public UpdateChecker {
~UpdateCheckerImpl() override;
// Overrides for UpdateChecker.
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_checked,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -95,7 +97,7 @@ UpdateCheckerImpl::~UpdateCheckerImpl() {
DCHECK(thread_checker_.CalledOnValidThread());
}
-bool UpdateCheckerImpl::CheckForUpdates(
+void UpdateCheckerImpl::CheckForUpdates(
const std::vector<std::string>& ids_checked,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -106,13 +108,13 @@ bool UpdateCheckerImpl::CheckForUpdates(
ids_checked_ = ids_checked;
update_check_callback_ = update_check_callback;
- return config_->GetSequencedTaskRunner()->PostTaskAndReply(
- FROM_HERE,
- base::Bind(&UpdateCheckerImpl::ReadUpdaterStateAttributes,
- base::Unretained(this)),
- base::Bind(&UpdateCheckerImpl::CheckForUpdatesHelper,
- base::Unretained(this), base::ConstRef(components),
- additional_attributes, enabled_component_updates));
+ base::PostTaskWithTraitsAndReply(
+ FROM_HERE, kTaskTraits,
+ base::BindOnce(&UpdateCheckerImpl::ReadUpdaterStateAttributes,
+ base::Unretained(this)),
+ base::BindOnce(&UpdateCheckerImpl::CheckForUpdatesHelper,
+ base::Unretained(this), base::ConstRef(components),
+ additional_attributes, enabled_component_updates));
}
// This function runs on the blocking pool task runner.
@@ -195,7 +197,7 @@ void UpdateCheckerImpl::UpdateCheckSucceeded(
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback_, 0, retry_after_sec));
+ FROM_HERE, base::BindOnce(update_check_callback_, 0, retry_after_sec));
}
void UpdateCheckerImpl::UpdateCheckFailed(const IdToComponentPtrMap& components,
@@ -210,7 +212,8 @@ void UpdateCheckerImpl::UpdateCheckFailed(const IdToComponentPtrMap& components,
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback_, error, retry_after_sec));
+ FROM_HERE,
+ base::BindOnce(update_check_callback_, error, retry_after_sec));
}
} // namespace
diff --git a/chromium/components/update_client/update_checker.h b/chromium/components/update_client/update_checker.h
index f9729fb81fb..c38bf61e790 100644
--- a/chromium/components/update_client/update_checker.h
+++ b/chromium/components/update_client/update_checker.h
@@ -37,7 +37,7 @@ class UpdateChecker {
// XML attribute string.
// On completion, the state of |components| is mutated as required by the
// server response received.
- virtual bool CheckForUpdates(
+ virtual void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
diff --git a/chromium/components/update_client/update_checker_unittest.cc b/chromium/components/update_client/update_checker_unittest.cc
index 033118be25f..70c667fc901 100644
--- a/chromium/components/update_client/update_checker_unittest.cc
+++ b/chromium/components/update_client/update_checker_unittest.cc
@@ -13,10 +13,9 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/run_loop.h"
-#include "base/test/scoped_task_scheduler.h"
+#include "base/test/scoped_task_environment.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/version.h"
#include "build/build_config.h"
@@ -64,7 +63,6 @@ class UpdateCheckerTest : public testing::Test {
protected:
void Quit();
void RunThreads();
- void RunThreadsUntilIdle();
std::unique_ptr<Component> MakeComponent() const;
@@ -86,21 +84,21 @@ class UpdateCheckerTest : public testing::Test {
private:
std::unique_ptr<UpdateContext> MakeFakeUpdateContext() const;
- base::MessageLoopForIO loop_;
- base::test::ScopedTaskScheduler scoped_task_scheduler_;
+ base::test::ScopedTaskEnvironment scoped_task_environment_;
base::Closure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(UpdateCheckerTest);
};
-UpdateCheckerTest::UpdateCheckerTest() : scoped_task_scheduler_(&loop_) {}
+UpdateCheckerTest::UpdateCheckerTest()
+ : scoped_task_environment_(
+ base::test::ScopedTaskEnvironment::MainThreadType::IO) {}
UpdateCheckerTest::~UpdateCheckerTest() {
}
void UpdateCheckerTest::SetUp() {
- config_ = base::MakeRefCounted<TestConfigurator>(
- base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get());
+ config_ = base::MakeRefCounted<TestConfigurator>();
pref_ = base::MakeUnique<TestingPrefServiceSimple>();
PersistedData::RegisterPrefs(pref_->registry());
metadata_ = base::MakeUnique<PersistedData>(pref_.get());
@@ -126,7 +124,7 @@ void UpdateCheckerTest::TearDown() {
// The PostInterceptor requires the message loop to run to destruct correctly.
// TODO(sorin): This is fragile and should be fixed.
- RunThreadsUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
void UpdateCheckerTest::RunThreads() {
@@ -138,11 +136,7 @@ void UpdateCheckerTest::RunThreads() {
// intercepts on the IO thread, run the threads until they are
// idle. The component updater service won't loop again until the loop count
// is set and the service is started.
- RunThreadsUntilIdle();
-}
-
-void UpdateCheckerTest::RunThreadsUntilIdle() {
- base::RunLoop().RunUntilIdle();
+ scoped_task_environment_.RunUntilIdle();
}
void UpdateCheckerTest::Quit() {
diff --git a/chromium/components/update_client/update_client.cc b/chromium/components/update_client/update_client.cc
index 4d248b27f5e..429a7a98864 100644
--- a/chromium/components/update_client/update_client.cc
+++ b/chromium/components/update_client/update_client.cc
@@ -18,8 +18,6 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
-#include "base/sequenced_task_runner.h"
-#include "base/single_thread_task_runner.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -131,7 +129,7 @@ void UpdateClientImpl::Update(const std::vector<std::string>& ids,
void UpdateClientImpl::RunTask(std::unique_ptr<Task> task) {
DCHECK(thread_checker_.CalledOnValidThread());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&Task::Run, base::Unretained(task.get())));
+ FROM_HERE, base::BindOnce(&Task::Run, base::Unretained(task.get())));
tasks_.insert(task.release());
}
@@ -141,8 +139,8 @@ void UpdateClientImpl::OnTaskComplete(const Callback& callback,
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(task);
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
- base::Bind(callback, error));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::BindOnce(callback, error));
// Remove the task from the set of the running tasks. Only tasks handled by
// the update engine can be in this data structure.
diff --git a/chromium/components/update_client/update_client_unittest.cc b/chromium/components/update_client/update_client_unittest.cc
index 98d02bcdc32..05b872fe288 100644
--- a/chromium/components/update_client/update_client_unittest.cc
+++ b/chromium/components/update_client/update_client_unittest.cc
@@ -172,10 +172,12 @@ class UpdateClientTest : public testing::Test {
base::test::ScopedTaskEnvironment scoped_task_environment_;
base::RunLoop runloop_;
- base::Closure quit_closure_;
+ const base::Closure quit_closure_ = runloop_.QuitClosure();
- scoped_refptr<update_client::TestConfigurator> config_;
- std::unique_ptr<TestingPrefServiceSimple> pref_;
+ scoped_refptr<update_client::TestConfigurator> config_ =
+ base::MakeRefCounted<TestConfigurator>();
+ std::unique_ptr<TestingPrefServiceSimple> pref_ =
+ base::MakeUnique<TestingPrefServiceSimple>();
std::unique_ptr<update_client::PersistedData> metadata_;
DISALLOW_COPY_AND_ASSIGN(UpdateClientTest);
@@ -183,15 +185,7 @@ class UpdateClientTest : public testing::Test {
constexpr int UpdateClientTest::kNumWorkerThreads_;
-UpdateClientTest::UpdateClientTest()
- : scoped_task_environment_(
- base::test::ScopedTaskEnvironment::MainThreadType::UI),
- pref_(base::MakeUnique<TestingPrefServiceSimple>()) {
- quit_closure_ = runloop_.QuitClosure();
-
- config_ = base::MakeRefCounted<TestConfigurator>(
- base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()}),
- base::ThreadTaskRunnerHandle::Get());
+UpdateClientTest::UpdateClientTest() {
PersistedData::RegisterPrefs(pref_->registry());
metadata_ = base::MakeUnique<PersistedData>(pref_.get());
}
@@ -245,7 +239,7 @@ TEST_F(UpdateClientTest, OneCrxNoUpdate) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -267,9 +261,7 @@ TEST_F(UpdateClientTest, OneCrxNoUpdate) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
-
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -358,7 +350,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -429,8 +421,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -465,13 +456,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateNoUpdate) {
result.total_bytes = 1843;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -570,7 +561,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdate) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -663,8 +654,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdate) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -719,8 +709,8 @@ TEST_F(UpdateClientTest, TwoCrxUpdate) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
@@ -840,7 +830,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -930,8 +920,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -986,13 +975,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateDownloadTimeout) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -1111,7 +1100,7 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdate) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -1217,8 +1206,7 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdate) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -1273,13 +1261,13 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdate) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -1440,7 +1428,7 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -1488,8 +1476,7 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -1528,9 +1515,9 @@ TEST_F(UpdateClientTest, OneCrxInstallError) {
base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -1628,7 +1615,7 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdateFailsFullUpdateSucceeds) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -1736,8 +1723,7 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdateFailsFullUpdateSucceeds) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -1807,13 +1793,13 @@ TEST_F(UpdateClientTest, OneCrxDiffUpdateFailsFullUpdateSucceeds) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -1934,7 +1920,7 @@ TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -1956,8 +1942,7 @@ TEST_F(UpdateClientTest, OneCrxNoUpdateQueuedCall) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -2047,7 +2032,7 @@ TEST_F(UpdateClientTest, OneCrxInstall) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -2101,8 +2086,7 @@ TEST_F(UpdateClientTest, OneCrxInstall) {
EXPECT_TRUE(component->on_demand());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -2141,13 +2125,13 @@ TEST_F(UpdateClientTest, OneCrxInstall) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -2240,7 +2224,7 @@ TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -2263,8 +2247,7 @@ TEST_F(UpdateClientTest, ConcurrentInstallSameCRX) {
EXPECT_TRUE(component->on_demand());
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -2346,14 +2329,12 @@ TEST_F(UpdateClientTest, EmptyIdList) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
bool enabled_component_updates,
- const UpdateCheckCallback& update_check_callback) override {
- return false;
- }
+ const UpdateCheckCallback& update_check_callback) override {}
};
class FakeCrxDownloader : public CrxDownloader {
@@ -2398,14 +2379,12 @@ TEST_F(UpdateClientTest, SendUninstallPing) {
return nullptr;
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
bool enabled_component_updates,
- const UpdateCheckCallback& update_check_callback) override {
- return false;
- }
+ const UpdateCheckCallback& update_check_callback) override {}
};
class FakeCrxDownloader : public CrxDownloader {
@@ -2499,7 +2478,7 @@ TEST_F(UpdateClientTest, RetryAfter) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -2529,8 +2508,7 @@ TEST_F(UpdateClientTest, RetryAfter) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, retry_after_sec));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, retry_after_sec));
}
};
@@ -2673,7 +2651,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -2768,8 +2746,7 @@ TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -2808,13 +2785,13 @@ TEST_F(UpdateClientTest, TwoCrxUpdateOneUpdateDisabled) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&FakeCrxDownloader::OnDownloadProgress,
- base::Unretained(this), result));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadProgress,
+ base::Unretained(this), result));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -2921,7 +2898,7 @@ TEST_F(UpdateClientTest, OneCrxUpdateCheckFails) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -2934,9 +2911,7 @@ TEST_F(UpdateClientTest, OneCrxUpdateCheckFails) {
EXPECT_EQ(1u, components.count(id));
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, -1, 0));
-
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, -1, 0));
}
};
@@ -3004,7 +2979,7 @@ TEST_F(UpdateClientTest, ActionRun_Install) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -3058,8 +3033,7 @@ TEST_F(UpdateClientTest, ActionRun_Install) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -3098,9 +3072,9 @@ TEST_F(UpdateClientTest, ActionRun_Install) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&FakeCrxDownloader::OnDownloadComplete,
- base::Unretained(this), true, result, download_metrics));
+ FROM_HERE, base::BindOnce(&FakeCrxDownloader::OnDownloadComplete,
+ base::Unretained(this), true, result,
+ download_metrics));
}
};
@@ -3164,7 +3138,7 @@ TEST_F(UpdateClientTest, ActionRun_NoUpdate) {
return base::MakeUnique<FakeUpdateChecker>();
}
- bool CheckForUpdates(
+ void CheckForUpdates(
const std::vector<std::string>& ids_to_check,
const IdToComponentPtrMap& components,
const std::string& additional_attributes,
@@ -3199,9 +3173,7 @@ TEST_F(UpdateClientTest, ActionRun_NoUpdate) {
component->SetParseResult(result);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(update_check_callback, 0, 0));
-
- return true;
+ FROM_HERE, base::BindOnce(update_check_callback, 0, 0));
}
};
@@ -3242,8 +3214,7 @@ TEST_F(UpdateClientTest, ActionRun_NoUpdate) {
scoped_refptr<ComponentUnpacker> component_unpacker = new ComponentUnpacker(
std::vector<uint8_t>(std::begin(gjpm_hash), std::end(gjpm_hash)),
- TestFilePath("runaction_test_win.crx3"), nullptr, nullptr,
- config()->GetSequencedTaskRunner());
+ TestFilePath("runaction_test_win.crx3"), nullptr, nullptr);
component_unpacker->Unpack(base::Bind(
[](base::FilePath* unpack_path, const base::Closure& quit_closure,
diff --git a/chromium/components/update_client/update_engine.cc b/chromium/components/update_client/update_engine.cc
index ef4db8eaf93..cf22810a980 100644
--- a/chromium/components/update_client/update_engine.cc
+++ b/chromium/components/update_client/update_engine.cc
@@ -39,7 +39,6 @@ UpdateContext::UpdateContext(
crx_data_callback(crx_data_callback),
notify_observers_callback(notify_observers_callback),
callback(callback),
- blocking_task_runner(config->GetSequencedTaskRunner()),
crx_downloader_factory(crx_downloader_factory) {
for (const auto& id : ids)
components.insert(
@@ -74,7 +73,7 @@ void UpdateEngine::Update(
if (IsThrottled(is_foreground)) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(callback, Error::RETRY_LATER));
+ FROM_HERE, base::BindOnce(callback, Error::RETRY_LATER));
return;
}
@@ -143,7 +142,7 @@ void UpdateEngine::ComponentCheckingForUpdatesStart(
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::Bind(&UpdateEngine::DoUpdateCheck, base::Unretained(this), it));
+ base::BindOnce(&UpdateEngine::DoUpdateCheck, base::Unretained(this), it));
}
void UpdateEngine::DoUpdateCheck(const UpdateContextIterator& it) {
@@ -209,8 +208,8 @@ void UpdateEngine::ComponentCheckingForUpdatesComplete(
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&UpdateEngine::UpdateCheckComplete,
- base::Unretained(this), it));
+ FROM_HERE, base::BindOnce(&UpdateEngine::UpdateCheckComplete,
+ base::Unretained(this), it));
}
void UpdateEngine::UpdateCheckComplete(const UpdateContextIterator& it) {
@@ -223,8 +222,8 @@ void UpdateEngine::UpdateCheckComplete(const UpdateContextIterator& it) {
update_context->component_queue.push(id);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it));
+ FROM_HERE, base::BindOnce(&UpdateEngine::HandleComponent,
+ base::Unretained(this), it));
}
void UpdateEngine::HandleComponent(const UpdateContextIterator& it) {
@@ -254,7 +253,8 @@ void UpdateEngine::HandleComponent(const UpdateContextIterator& it) {
if (!next_update_delay.is_zero() && component->IsUpdateAvailable()) {
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
- base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it),
+ base::BindOnce(&UpdateEngine::HandleComponent, base::Unretained(this),
+ it),
next_update_delay);
next_update_delay = base::TimeDelta();
@@ -293,8 +293,8 @@ void UpdateEngine::HandleComponentComplete(const UpdateContextIterator& it) {
}
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it));
+ FROM_HERE, base::BindOnce(&UpdateEngine::HandleComponent,
+ base::Unretained(this), it));
}
void UpdateEngine::UpdateComplete(const UpdateContextIterator& it,
@@ -362,8 +362,8 @@ void UpdateEngine::SendUninstallPing(const std::string& id,
update_context->component_queue.push(id);
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&UpdateEngine::HandleComponent, base::Unretained(this), it));
+ FROM_HERE, base::BindOnce(&UpdateEngine::HandleComponent,
+ base::Unretained(this), it));
}
} // namespace update_client
diff --git a/chromium/components/update_client/update_engine.h b/chromium/components/update_client/update_engine.h
index df643b1ea42..9f3b57f7502 100644
--- a/chromium/components/update_client/update_engine.h
+++ b/chromium/components/update_client/update_engine.h
@@ -28,7 +28,6 @@
namespace base {
class TimeTicks;
-class SequencedTaskRunner;
} // namespace base
namespace update_client {
@@ -152,9 +151,6 @@ struct UpdateContext {
// Called when the all updates associated with this context have completed.
const UpdateEngine::Callback callback;
- // Runs tasks in a blocking thread pool.
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner;
-
// Creates instances of CrxDownloader;
CrxDownloader::Factory crx_downloader_factory;
diff --git a/chromium/components/update_client/update_query_params.cc b/chromium/components/update_client/update_query_params.cc
index 7b576e585b2..65d53ba79ee 100644
--- a/chromium/components/update_client/update_query_params.cc
+++ b/chromium/components/update_client/update_query_params.cc
@@ -33,6 +33,8 @@ const char kOs[] =
"cros";
#elif defined(OS_LINUX)
"linux";
+#elif defined(OS_FUCHSIA)
+ "fuchsia";
#elif defined(OS_OPENBSD)
"openbsd";
#else
diff --git a/chromium/components/update_client/updater_state_unittest.cc b/chromium/components/update_client/updater_state_unittest.cc
index ca889ade7e1..86ad660a3d7 100644
--- a/chromium/components/update_client/updater_state_unittest.cc
+++ b/chromium/components/update_client/updater_state_unittest.cc
@@ -46,9 +46,9 @@ TEST_F(UpdaterStateTest, Serialize) {
#if defined(OS_WIN)
// The name of the Windows updater for Chrome.
EXPECT_STREQ("Omaha", UpdaterState::GetState(false)->at("name").c_str());
- #elif defined(OS_MACOSX)
- EXPECT_STREQ("Keystone", UpdaterState::GetState(false)->at("name").c_str());
- #endif
+#elif defined(OS_MACOSX) && !defined(OS_IOS)
+ EXPECT_STREQ("Keystone", UpdaterState::GetState(false)->at("name").c_str());
+#endif
#endif // GOOGLE_CHROME_BUILD
// Tests some of the remaining values.
diff --git a/chromium/components/update_client/url_fetcher_downloader.cc b/chromium/components/update_client/url_fetcher_downloader.cc
index 03e6190bd4d..2213f483fff 100644
--- a/chromium/components/update_client/url_fetcher_downloader.cc
+++ b/chromium/components/update_client/url_fetcher_downloader.cc
@@ -79,7 +79,7 @@ void UrlFetcherDownloader::StartURLFetch(const GURL& url) {
destination: GOOGLE_OWNED_SERVICE
}
policy {
- cookies_allowed: false
+ cookies_allowed: NO
setting: "This feature cannot be disabled."
chrome_policy {
ComponentUpdatesEnabled {
diff --git a/chromium/components/update_client/url_fetcher_downloader.h b/chromium/components/update_client/url_fetcher_downloader.h
index cb81fbc8850..2007aa76c8a 100644
--- a/chromium/components/update_client/url_fetcher_downloader.h
+++ b/chromium/components/update_client/url_fetcher_downloader.h
@@ -27,8 +27,7 @@ namespace update_client {
// Implements a CRX downloader in top of the URLFetcher.
class UrlFetcherDownloader : public CrxDownloader,
public net::URLFetcherDelegate {
- protected:
- friend class CrxDownloader;
+ public:
UrlFetcherDownloader(std::unique_ptr<CrxDownloader> successor,
net::URLRequestContextGetter* context_getter);
~UrlFetcherDownloader() override;
diff --git a/chromium/components/update_client/utils.cc b/chromium/components/update_client/utils.cc
index 74ef1e7e769..8d4afcfbff7 100644
--- a/chromium/components/update_client/utils.cc
+++ b/chromium/components/update_client/utils.cc
@@ -84,7 +84,7 @@ std::unique_ptr<net::URLFetcher> SendProtocolRequest(
destination: GOOGLE_OWNED_SERVICE
}
policy {
- cookies_allowed: false
+ cookies_allowed: NO
setting: "This feature cannot be disabled."
chrome_policy {
ComponentUpdatesEnabled {