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

Unified Diff: base/thread_task_runner_handle.cc

Issue 1911023002: TaskScheduler: Add TaskRunnerHandle support to TaskScheduler tasks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@c1_1876363004_STTR
Patch Set: review:danakj#28 Created 4 years, 8 months 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
« no previous file with comments | « base/thread_task_runner_handle.h ('k') | base/threading/sequenced_task_runner_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/thread_task_runner_handle.cc
diff --git a/base/thread_task_runner_handle.cc b/base/thread_task_runner_handle.cc
index 911e90c798c47f8b69af49a7631a5487a8a01b94..3a3f14b300582d8b5e0504ec6fdb8c7ad37c1599 100644
--- a/base/thread_task_runner_handle.cc
+++ b/base/thread_task_runner_handle.cc
@@ -4,15 +4,19 @@
#include "base/thread_task_runner_handle.h"
+#include <utility>
+
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/single_thread_task_runner.h"
+#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_local.h"
namespace base {
namespace {
-base::LazyInstance<base::ThreadLocalPointer<ThreadTaskRunnerHandle> >::Leaky
+base::LazyInstance<base::ThreadLocalPointer<ThreadTaskRunnerHandle>>::Leaky
lazy_tls_ptr = LAZY_INSTANCE_INITIALIZER;
} // namespace
@@ -26,21 +30,23 @@ scoped_refptr<SingleThreadTaskRunner> ThreadTaskRunnerHandle::Get() {
// static
bool ThreadTaskRunnerHandle::IsSet() {
- return lazy_tls_ptr.Pointer()->Get() != NULL;
+ return !!lazy_tls_ptr.Pointer()->Get();
}
ThreadTaskRunnerHandle::ThreadTaskRunnerHandle(
scoped_refptr<SingleThreadTaskRunner> task_runner)
: task_runner_(std::move(task_runner)) {
DCHECK(task_runner_->BelongsToCurrentThread());
- DCHECK(!lazy_tls_ptr.Pointer()->Get());
+ // No SequencedTaskRunnerHandle (which includes ThreadTaskRunnerHandles)
+ // should already be set for this thread.
+ DCHECK(!SequencedTaskRunnerHandle::IsSet());
lazy_tls_ptr.Pointer()->Set(this);
}
ThreadTaskRunnerHandle::~ThreadTaskRunnerHandle() {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_EQ(lazy_tls_ptr.Pointer()->Get(), this);
- lazy_tls_ptr.Pointer()->Set(NULL);
+ lazy_tls_ptr.Pointer()->Set(nullptr);
}
} // namespace base
« no previous file with comments | « base/thread_task_runner_handle.h ('k') | base/threading/sequenced_task_runner_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698