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 @@ ...@@ -5,16 +5,19 @@
#include "extensions/browser/api/system_info/system_info_provider.h" #include "extensions/browser/api/system_info/system_info_provider.h"
#include "base/bind.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" #include "content/public/browser/browser_thread.h"
namespace extensions { namespace extensions {
SystemInfoProvider::SystemInfoProvider() : is_waiting_for_completion_(false) { SystemInfoProvider::SystemInfoProvider()
base::SequencedWorkerPool* pool = content::BrowserThread::GetBlockingPool(); : is_waiting_for_completion_(false),
worker_pool_ = pool->GetSequencedTaskRunnerWithShutdownBehavior( task_runner_(base::CreateSequencedTaskRunnerWithTraits(
pool->GetSequenceToken(), {base::MayBlock(),
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); /* default priority, */
} base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})) {}
SystemInfoProvider::~SystemInfoProvider() { SystemInfoProvider::~SystemInfoProvider() {
} }
...@@ -60,8 +63,7 @@ void SystemInfoProvider::StartQueryInfoPostInitialization() { ...@@ -60,8 +63,7 @@ void SystemInfoProvider::StartQueryInfoPostInitialization() {
// Post the custom query info task to blocking pool for information querying // Post the custom query info task to blocking pool for information querying
// and reply with OnQueryCompleted. // and reply with OnQueryCompleted.
base::PostTaskAndReplyWithResult( base::PostTaskAndReplyWithResult(
worker_pool_.get(), task_runner_.get(), FROM_HERE,
FROM_HERE,
base::Bind(&SystemInfoProvider::QueryInfo, this), base::Bind(&SystemInfoProvider::QueryInfo, this),
base::Bind(&SystemInfoProvider::OnQueryCompleted, this)); base::Bind(&SystemInfoProvider::OnQueryCompleted, this));
} }
......
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/threading/sequenced_worker_pool.h"
namespace base {
class SequencedTaskRunner;
}
namespace extensions { namespace extensions {
...@@ -87,9 +90,8 @@ class SystemInfoProvider ...@@ -87,9 +90,8 @@ class SystemInfoProvider
// Indicates if it is waiting for the querying completion. // Indicates if it is waiting for the querying completion.
bool is_waiting_for_completion_; bool is_waiting_for_completion_;
// Sequenced worker pool to make the operation of querying information get // Sequenced task runner to safely query system information.
// executed in order. scoped_refptr<base::SequencedTaskRunner> task_runner_;
scoped_refptr<base::SequencedTaskRunner> worker_pool_;
DISALLOW_COPY_AND_ASSIGN(SystemInfoProvider); 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