Commit 9db18b4f authored by Hiroki Nakagawa's avatar Hiroki Nakagawa Committed by Commit Bot

Allow base::ThreadChecker in //src/third_party/WebKit/Source

This CL allows base::ThreadChecker in //src/third_party/WebKit/Source and uses
it in WorkerThreadLifecycleContext as an example.

WorkerThreadLifecycleContext is now bound with the main thread and
DCHECK(IsMainThread) checks it, but the restriction will be removed by ongoing
CLs soon (see the associated issue). base::ThreadChecker should be useful in
such a case.

Bug: 829119
Change-Id: I01a2d8663829e6e2ad2d572664ff0a5ced14a4ae
Reviewed-on: https://chromium-review.googlesource.com/997232Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548383}
parent 2e196caf
...@@ -14,6 +14,7 @@ include_rules = [ ...@@ -14,6 +14,7 @@ include_rules = [
"+base/single_thread_task_runner.h", "+base/single_thread_task_runner.h",
"+base/task_scheduler/post_task.h", "+base/task_scheduler/post_task.h",
"+base/thread_annotations.h", "+base/thread_annotations.h",
"+base/threading/thread_checker.h",
"+base/time/time.h", "+base/time/time.h",
"+build", "+build",
"+platform", "+platform",
......
...@@ -9,15 +9,15 @@ ...@@ -9,15 +9,15 @@
namespace blink { namespace blink {
WorkerThreadLifecycleContext::WorkerThreadLifecycleContext() { WorkerThreadLifecycleContext::WorkerThreadLifecycleContext() {
DCHECK(IsMainThread()); DETACH_FROM_THREAD(thread_checker_);
} }
WorkerThreadLifecycleContext::~WorkerThreadLifecycleContext() { WorkerThreadLifecycleContext::~WorkerThreadLifecycleContext() {
DCHECK(IsMainThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
} }
void WorkerThreadLifecycleContext::NotifyContextDestroyed() { void WorkerThreadLifecycleContext::NotifyContextDestroyed() {
DCHECK(IsMainThread()); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(!was_context_destroyed_); DCHECK(!was_context_destroyed_);
was_context_destroyed_ = true; was_context_destroyed_ = true;
LifecycleNotifier::NotifyContextDestroyed(); LifecycleNotifier::NotifyContextDestroyed();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define WorkerThreadLifecycleContext_h #define WorkerThreadLifecycleContext_h
#include "base/macros.h" #include "base/macros.h"
#include "base/threading/thread_checker.h"
#include "core/CoreExport.h" #include "core/CoreExport.h"
#include "platform/LifecycleNotifier.h" #include "platform/LifecycleNotifier.h"
#include "platform/heap/GarbageCollected.h" #include "platform/heap/GarbageCollected.h"
...@@ -31,6 +32,9 @@ class CORE_EXPORT WorkerThreadLifecycleContext final ...@@ -31,6 +32,9 @@ class CORE_EXPORT WorkerThreadLifecycleContext final
private: private:
friend class WorkerThreadLifecycleObserver; friend class WorkerThreadLifecycleObserver;
bool was_context_destroyed_ = false; bool was_context_destroyed_ = false;
THREAD_CHECKER(thread_checker_);
DISALLOW_COPY_AND_ASSIGN(WorkerThreadLifecycleContext); DISALLOW_COPY_AND_ASSIGN(WorkerThreadLifecycleContext);
}; };
......
...@@ -38,6 +38,7 @@ _CONFIG = [ ...@@ -38,6 +38,7 @@ _CONFIG = [
'base::CreateSequencedTaskRunnerWithTraits', 'base::CreateSequencedTaskRunnerWithTraits',
'base::SequencedTaskRunner', 'base::SequencedTaskRunner',
'base::SingleThreadTaskRunner', 'base::SingleThreadTaskRunner',
'base::ThreadChecker',
'base::Time', 'base::Time',
'base::TimeDelta', 'base::TimeDelta',
'base::TimeTicks', 'base::TimeTicks',
......
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