Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(988)

Unified Diff: content/browser/dom_storage/dom_storage_task_runner.cc

Issue 2576243003: Add an experiment to redirect DOMStorageTaskRunner to TaskScheduler. (Closed)
Patch Set: fix compile Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/dom_storage/dom_storage_task_runner.cc
diff --git a/content/browser/dom_storage/dom_storage_task_runner.cc b/content/browser/dom_storage/dom_storage_task_runner.cc
index c0d00d55d6e5f29342a512d6197e8b8e893e6e06..21eb54dfc9f379c401b85ca2bd558e21f1e59f16 100644
--- a/content/browser/dom_storage/dom_storage_task_runner.cc
+++ b/content/browser/dom_storage/dom_storage_task_runner.cc
@@ -4,6 +4,8 @@
#include "content/browser/dom_storage/dom_storage_task_runner.h"
+#include <utility>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/location.h"
@@ -15,20 +17,12 @@ namespace content {
// DOMStorageWorkerPoolTaskRunner
DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner(
- base::SequencedWorkerPool* sequenced_worker_pool,
- base::SequencedWorkerPool::SequenceToken primary_sequence_token,
- base::SequencedWorkerPool::SequenceToken commit_sequence_token,
- base::SingleThreadTaskRunner* delayed_task_task_runner)
- : task_runner_(delayed_task_task_runner),
- sequenced_worker_pool_(sequenced_worker_pool),
- primary_sequence_token_(primary_sequence_token),
- commit_sequence_token_(commit_sequence_token) {
- primary_sequence_checker_.DetachFromSequence();
- commit_sequence_checker_.DetachFromSequence();
-}
+ scoped_refptr<base::SequencedTaskRunner> primary_sequence,
+ scoped_refptr<base::SequencedTaskRunner> commit_sequence)
+ : primary_sequence_(std::move(primary_sequence)),
+ commit_sequence_(std::move(commit_sequence)) {}
-DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() {
-}
+DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default;
bool DOMStorageWorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
// It is valid for an implementation to always return true.
@@ -39,61 +33,39 @@ bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
- // Note base::TaskRunner implements PostTask in terms of PostDelayedTask
- // with a delay of zero, we detect that usage and avoid the unecessary
- // trip thru the message loop.
- if (delay.is_zero()) {
- return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior(
- primary_sequence_token_, from_here, task,
- base::SequencedWorkerPool::BLOCK_SHUTDOWN);
- }
- // Post a task to call this->PostTask() after the delay.
- return task_runner_->PostDelayedTask(
- FROM_HERE,
- base::Bind(base::IgnoreResult(&DOMStorageWorkerPoolTaskRunner::PostTask),
- this, from_here, task),
- delay);
+ return primary_sequence_->PostDelayedTask(from_here, task, delay);
}
bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask(
const tracked_objects::Location& from_here,
SequenceID sequence_id,
const base::Closure& task) {
- return sequenced_worker_pool_->PostSequencedWorkerTaskWithShutdownBehavior(
- IDtoToken(sequence_id), from_here, task,
- base::SequencedWorkerPool::BLOCK_SHUTDOWN);
+ return GetSequencedTaskRunner(sequence_id)->PostTask(from_here, task);
}
void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const {
- DCHECK(primary_sequence_checker_.CalledOnValidSequence());
+ DCHECK(primary_sequence_->RunsTasksOnCurrentThread());
}
void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const {
- DCHECK(commit_sequence_checker_.CalledOnValidSequence());
+ DCHECK(commit_sequence_->RunsTasksOnCurrentThread());
}
scoped_refptr<base::SequencedTaskRunner>
DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) {
- return sequenced_worker_pool_->GetSequencedTaskRunner(IDtoToken(sequence_id));
-}
-
-base::SequencedWorkerPool::SequenceToken
-DOMStorageWorkerPoolTaskRunner::IDtoToken(SequenceID id) const {
- if (id == PRIMARY_SEQUENCE)
- return primary_sequence_token_;
- DCHECK_EQ(COMMIT_SEQUENCE, id);
- return commit_sequence_token_;
+ if (sequence_id == PRIMARY_SEQUENCE)
+ return primary_sequence_;
+ DCHECK_EQ(COMMIT_SEQUENCE, sequence_id);
+ return commit_sequence_;
}
// MockDOMStorageTaskRunner
MockDOMStorageTaskRunner::MockDOMStorageTaskRunner(
- base::SingleThreadTaskRunner* task_runner)
- : task_runner_(task_runner) {
-}
+ scoped_refptr<base::SequencedTaskRunner> task_runner)
+ : task_runner_(std::move(task_runner)) {}
-MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() {
-}
+MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default;
bool MockDOMStorageTaskRunner::RunsTasksOnCurrentThread() const {
return task_runner_->RunsTasksOnCurrentThread();
« no previous file with comments | « content/browser/dom_storage/dom_storage_task_runner.h ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698