Commit 80a30288 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[TaskScheduler]: Migrate off of ScopedAllowWait in /content/shell

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

It should have been replaced by :
 * base::ScopedAllowBaseSyncPrimitivesForTesting in test files.
 * base::ScopedAllowBaseSyncPrimitives in non-test files
 * base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope 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.

This CL required special attention:
 * ScopedAllowWaitForAndroidLayoutTests was deleted in favor of
   ScopedAllowBaseSyncPrimitivesForTesting.
 * |reduced_restrictions_| was removed because the related WaitableEvent is
   now declared as idle, which does not require any allowance.

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=peter@chromium.org

Bug: 766678
Change-Id: I8065043e9b1b5005fb9ff2894cb2dc30098efd8e
Reviewed-on: https://chromium-review.googlesource.com/c/1325205
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607673}
parent bc739335
......@@ -132,7 +132,6 @@ class BrowserTestBase;
class CategorizedWorkerPool;
class GpuProcessTransportFactory;
class NestedMessagePumpAndroid;
class ScopedAllowWaitForAndroidLayoutTests;
class ScopedAllowWaitForDebugURL;
class SessionStorageDatabase;
class SoftwareOutputDeviceMus;
......@@ -526,7 +525,6 @@ class BASE_EXPORT ThreadRestrictions {
friend class content::BrowserShutdownProfileDumper;
friend class content::BrowserTestBase;
friend class content::NestedMessagePumpAndroid;
friend class content::ScopedAllowWaitForAndroidLayoutTests;
friend class content::ScopedAllowWaitForDebugURL;
friend class ::HistogramSynchronizer;
friend class internal::TaskTracker;
......
......@@ -34,10 +34,6 @@
#include "content/shell/common/layout_test.mojom.h"
#include "ui/gfx/geometry/size.h"
#if defined(OS_ANDROID)
#include "base/threading/thread_restrictions.h"
#endif
class SkBitmap;
namespace content {
......@@ -50,17 +46,6 @@ class RenderProcessHost;
class Shell;
struct TestInfo;
#if defined(OS_ANDROID)
// Android uses a nested run loop for running layout tests because the
// default message loop, provided by the system, does not offer a blocking
// Run() method. The loop itself, implemented as NestedMessagePumpAndroid,
// uses a base::WaitableEvent allowing it to sleep until more events arrive.
class ScopedAllowWaitForAndroidLayoutTests {
private:
base::ThreadRestrictions::ScopedAllowWait wait;
};
#endif
class BlinkTestResultPrinter {
public:
BlinkTestResultPrinter(std::ostream* output, std::ostream* error);
......@@ -346,11 +331,6 @@ class BlinkTestController : public WebContentsObserver,
// Map from one frame to one mojo pipe.
std::map<GlobalFrameRoutingId, mojom::LayoutTestControlAssociatedPtr>
layout_test_control_map_;
#if defined(OS_ANDROID)
// Because of the nested message pump implementation, Android needs to allow
// waiting on the UI thread while layout tests are being ran.
ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_;
#endif
SEQUENCE_CHECKER(sequence_checker_);
......
......@@ -18,6 +18,7 @@
#include "base/task/post_task.h"
#include "base/test/android/url_utils.h"
#include "base/test/test_support_android.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/shell/browser/layout_test/blink_test_controller.h"
......@@ -117,7 +118,7 @@ void RedirectStream(
FROM_HERE, {BrowserThread::IO},
base::Bind(&CreateAndConnectSocket, port,
base::Bind(finish_redirection, &redirected)));
ScopedAllowWaitForAndroidLayoutTests allow_wait;
base::ScopedAllowBaseSyncPrimitivesForTesting allow_wait;
while (!redirected.IsSignaled())
redirected.Wait();
}
......
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