0

[TaskScheduler]: Migrate off of ScopedAllowWait in /cc

base::ThreadRestrictions::ScopedAllowWait is deprecated in favor of its more
explicit counterpart.

It should have been replaced by :
 * base::ScopedAllowBaseSyncPrimitivesForTesting in test files.
 * base::ScopedAllowSyncPrimitives in non-test files
 * base::ScopedAllowSyncPrimitivesOutsideBlockingScope when it's used on threads
   that don't allow blocking
The last one is strongly frowned upon but this CL aims to document existing
behavior rather than address it. Owners are encouraged to follow-up by fixing
unnecessary waits and more particularly unnecessary waits
outside-blocking-scope.

Note: The non-for-testing versions require friend'ing in thread_restrictions.h
but care was taken to add these friends ahead of git cl split (since it wasn't
possible to do a line-by-line associated CL split).
Refer to the top-level CL if necessary :
https://chromium-review.googlesource.com/c/chromium/src/+/1288533

Please CQ if LGTY!

This CL was uploaded by git cl split.

R=kylechar@chromium.org

Bug: 766678, 902653
Change-Id: I30a5956028c8d7bca56be07433b2b2f31592ae9f
Reviewed-on: https://chromium-review.googlesource.com/c/1324395
Reviewed-by: kylechar <kylechar@chromium.org>
Commit-Queue: kylechar <kylechar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606497}
This commit is contained in:
Etienne Pierre-doray
2018-11-08 16:46:33 +00:00
committed by Commit Bot
parent 2756e0a757
commit 7575b70d50
2 changed files with 6 additions and 3 deletions

@@ -39,7 +39,8 @@ class CompletionEvent {
DCHECK(!waited_);
waited_ = true;
#endif
base::ThreadRestrictions::ScopedAllowWait allow_wait;
// http://crbug.com/902653
base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait;
event_.Wait();
}
@@ -48,7 +49,8 @@ class CompletionEvent {
DCHECK(!waited_);
waited_ = true;
#endif
base::ThreadRestrictions::ScopedAllowWait allow_wait;
// http://crbug.com/902653
base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait;
if (event_.TimedWait(max_time))
return true;
#if DCHECK_IS_ON()

@@ -83,7 +83,8 @@ void SingleThreadTaskGraphRunner::WaitForTasksToFinishRunning(
{
base::AutoLock lock(lock_);
base::ThreadRestrictions::ScopedAllowWait allow_wait;
// http://crbug.com/902823
base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait;
auto* task_namespace = work_queue_.GetNamespaceForToken(token);