Commit 9fd60dce authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Task Migration][Extensions] Migrate the SystemInfo API

Migrate the system info API to use the new task scheduler API
instead of using the worker pool. Note: also change the shutdown
behavior to be SKIP_ON_SHUTDOWN, since there's no reason for it to be
CONTINUE_ON_SHUTDOWN.

Bug: 689520
Change-Id: I4c4fb9990123f6124948b12fc6cf580ec45c8da7
Reviewed-on: https://chromium-review.googlesource.com/591987Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491194}
parent 94cae822
......@@ -5,16 +5,19 @@
#include "extensions/browser/api/system_info/system_info_provider.h"
#include "base/bind.h"
#include "base/task_runner_util.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace extensions {
SystemInfoProvider::SystemInfoProvider() : is_waiting_for_completion_(false) {
base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool();
worker_pool_ = pool->GetSequencedTaskRunnerWithShutdownBehavior(
pool->GetSequenceToken(),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
}
SystemInfoProvider::SystemInfoProvider()
: is_waiting_for_completion_(false),
task_runner_(base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(),
/* default priority, */
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})) {}
SystemInfoProvider::~SystemInfoProvider() {
}
......@@ -60,8 +63,7 @@ void SystemInfoProvider::StartQueryInfoPostInitialization() {
// Post the custom query info task to blocking pool for information querying
// and reply with OnQueryCompleted.
base::PostTaskAndReplyWithResult(
worker_pool_.get(),
FROM_HERE,
task_runner_.get(), FROM_HERE,
base::Bind(&SystemInfoProvider::QueryInfo, this),
base::Bind(&SystemInfoProvider::OnQueryCompleted, this));
}
......
......@@ -11,7 +11,10 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/threading/sequenced_worker_pool.h"
namespace base {
class SequencedTaskRunner;
}
namespace extensions {
......@@ -87,9 +90,8 @@ class SystemInfoProvider
// Indicates if it is waiting for the querying completion.
bool is_waiting_for_completion_;
// Sequenced worker pool to make the operation of querying information get
// executed in order.
scoped_refptr<base::SequencedTaskRunner> worker_pool_;
// Sequenced task runner to safely query system information.
scoped_refptr<base::SequencedTaskRunner> task_runner_;
DISALLOW_COPY_AND_ASSIGN(SystemInfoProvider);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment