Commit 19ef4825 authored by Dmitry Gozman's avatar Dmitry Gozman Committed by Commit Bot

Merge platform/threading to platform/scheduler

There was a single BackgroundTaskRunner::PostOnBackgroundThread
function in platform/threading, which makes sense to be in scheduler.

Change-Id: Ibe0a53d6875c43cda0915bf8de5c15085fda12c5
Reviewed-on: https://chromium-review.googlesource.com/1128543
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573432}
parent d52effd0
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "third_party/blink/renderer/platform/graphics/image_data_buffer.h" #include "third_party/blink/renderer/platform/graphics/image_data_buffer.h"
#include "third_party/blink/renderer/platform/histogram.h" #include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/image-encoders/image_encoder_utils.h" #include "third_party/blink/renderer/platform/image-encoders/image_encoder_utils.h"
#include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h" #include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/threading/background_task_runner.h"
#include "third_party/blink/renderer/platform/web_task_runner.h" #include "third_party/blink/renderer/platform/web_task_runner.h"
#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/time.h" #include "third_party/blink/renderer/platform/wtf/time.h"
...@@ -371,7 +371,7 @@ void CanvasAsyncBlobCreator::ScheduleAsyncBlobCreation(const double& quality) { ...@@ -371,7 +371,7 @@ void CanvasAsyncBlobCreator::ScheduleAsyncBlobCreation(const double& quality) {
WrapPersistent(this))); WrapPersistent(this)));
} else { } else {
BackgroundTaskRunner::PostOnBackgroundThread( BackgroundScheduler::PostOnBackgroundThread(
FROM_HERE, FROM_HERE,
CrossThreadBind(&CanvasAsyncBlobCreator::EncodeImageOnEncoderThread, CrossThreadBind(&CanvasAsyncBlobCreator::EncodeImageOnEncoderThread,
WrapCrossThreadPersistent(this), quality)); WrapCrossThreadPersistent(this), quality));
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h" #include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h" #include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h" #include "third_party/blink/renderer/platform/image-decoders/image_decoder.h"
#include "third_party/blink/renderer/platform/threading/background_task_runner.h" #include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorSpaceXformCanvas.h" #include "third_party/skia/include/core/SkColorSpaceXformCanvas.h"
#include "third_party/skia/include/core/SkImageInfo.h" #include "third_party/skia/include/core/SkImageInfo.h"
...@@ -1008,7 +1008,7 @@ ScriptPromise ImageBitmap::CreateAsync(ImageElementBase* image, ...@@ -1008,7 +1008,7 @@ ScriptPromise ImageBitmap::CreateAsync(ImageElementBase* image,
draw_dst_rect, parsed_options.flip_y); draw_dst_rect, parsed_options.flip_y);
std::unique_ptr<ParsedOptions> passed_parsed_options = std::unique_ptr<ParsedOptions> passed_parsed_options =
std::make_unique<ParsedOptions>(parsed_options); std::make_unique<ParsedOptions>(parsed_options);
BackgroundTaskRunner::PostOnBackgroundThread( BackgroundScheduler::PostOnBackgroundThread(
FROM_HERE, FROM_HERE,
CrossThreadBind(&RasterizeImageOnBackgroundThread, CrossThreadBind(&RasterizeImageOnBackgroundThread,
WrapCrossThreadPersistent(resolver), WrapCrossThreadPersistent(resolver),
......
...@@ -54,8 +54,8 @@ ...@@ -54,8 +54,8 @@
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/histogram.h" #include "third_party/blink/renderer/platform/histogram.h"
#include "third_party/blink/renderer/platform/image-decoders/image_decoder.h" #include "third_party/blink/renderer/platform/image-decoders/image_decoder.h"
#include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include "third_party/blink/renderer/platform/shared_buffer.h" #include "third_party/blink/renderer/platform/shared_buffer.h"
#include "third_party/blink/renderer/platform/threading/background_task_runner.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace blink { namespace blink {
...@@ -297,7 +297,7 @@ void ImageBitmapFactories::ImageBitmapLoader::ScheduleAsyncImageBitmapDecoding( ...@@ -297,7 +297,7 @@ void ImageBitmapFactories::ImageBitmapLoader::ScheduleAsyncImageBitmapDecoding(
DOMArrayBuffer* array_buffer) { DOMArrayBuffer* array_buffer) {
scoped_refptr<base::SingleThreadTaskRunner> task_runner = scoped_refptr<base::SingleThreadTaskRunner> task_runner =
Platform::Current()->CurrentThread()->GetTaskRunner(); Platform::Current()->CurrentThread()->GetTaskRunner();
BackgroundTaskRunner::PostOnBackgroundThread( BackgroundScheduler::PostOnBackgroundThread(
FROM_HERE, FROM_HERE,
CrossThreadBind( CrossThreadBind(
&ImageBitmapFactories::ImageBitmapLoader::DecodeImageOnDecoderThread, &ImageBitmapFactories::ImageBitmapLoader::DecodeImageOnDecoderThread,
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "third_party/blink/renderer/platform/audio/audio_bus.h" #include "third_party/blink/renderer/platform/audio/audio_bus.h"
#include "third_party/blink/renderer/platform/audio/audio_file_reader.h" #include "third_party/blink/renderer/platform/audio/audio_file_reader.h"
#include "third_party/blink/renderer/platform/cross_thread_functional.h" #include "third_party/blink/renderer/platform/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/threading/background_task_runner.h" #include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include "third_party/blink/renderer/platform/web_task_runner.h" #include "third_party/blink/renderer/platform/web_task_runner.h"
namespace blink { namespace blink {
...@@ -51,7 +51,7 @@ void AsyncAudioDecoder::DecodeAsync( ...@@ -51,7 +51,7 @@ void AsyncAudioDecoder::DecodeAsync(
if (!audio_data) if (!audio_data)
return; return;
BackgroundTaskRunner::PostOnBackgroundThread( BackgroundScheduler::PostOnBackgroundThread(
FROM_HERE, FROM_HERE,
CrossThreadBind(&AsyncAudioDecoder::DecodeOnBackgroundThread, CrossThreadBind(&AsyncAudioDecoder::DecodeOnBackgroundThread,
WrapCrossThreadPersistent(audio_data), sample_rate, WrapCrossThreadPersistent(audio_data), sample_rate,
......
...@@ -1371,8 +1371,6 @@ jumbo_component("platform") { ...@@ -1371,8 +1371,6 @@ jumbo_component("platform") {
"theme.cc", "theme.cc",
"theme.h", "theme.h",
"theme_types.h", "theme_types.h",
"threading/background_task_runner.cc",
"threading/background_task_runner.h",
"time_clamper.cc", "time_clamper.cc",
"time_clamper.h", "time_clamper.h",
"timer.cc", "timer.cc",
...@@ -1866,7 +1864,6 @@ jumbo_source_set("blink_platform_unittests_sources") { ...@@ -1866,7 +1864,6 @@ jumbo_source_set("blink_platform_unittests_sources") {
"text/text_run_test.cc", "text/text_run_test.cc",
"text/unicode_utilities_test.cc", "text/unicode_utilities_test.cc",
"text/writing_mode_utils_test.cc", "text/writing_mode_utils_test.cc",
"threading/background_task_runner_test.cc",
"time_clamper_test.cc", "time_clamper_test.cc",
"timer_test.cc", "timer_test.cc",
"transforms/affine_transform_test.cc", "transforms/affine_transform_test.cc",
......
...@@ -20,6 +20,7 @@ blink_platform_sources("scheduler") { ...@@ -20,6 +20,7 @@ blink_platform_sources("scheduler") {
"child/webthread_base.cc", "child/webthread_base.cc",
"child/webthread_impl_for_worker_scheduler.cc", "child/webthread_impl_for_worker_scheduler.cc",
"child/webthread_impl_for_worker_scheduler.h", "child/webthread_impl_for_worker_scheduler.h",
"common/background_scheduler.cc",
"common/cancelable_closure_holder.cc", "common/cancelable_closure_holder.cc",
"common/cancelable_closure_holder.h", "common/cancelable_closure_holder.h",
"common/frame_or_worker_scheduler.cc", "common/frame_or_worker_scheduler.cc",
...@@ -78,6 +79,7 @@ blink_platform_sources("scheduler") { ...@@ -78,6 +79,7 @@ blink_platform_sources("scheduler") {
"main_thread/user_model.cc", "main_thread/user_model.cc",
"main_thread/user_model.h", "main_thread/user_model.h",
"main_thread/web_render_widget_scheduling_state.cc", "main_thread/web_render_widget_scheduling_state.cc",
"public/background_scheduler.h",
"public/frame_or_worker_scheduler.h", "public/frame_or_worker_scheduler.h",
"public/frame_scheduler.h", "public/frame_scheduler.h",
"public/page_lifecycle_state.h", "public/page_lifecycle_state.h",
...@@ -174,6 +176,7 @@ jumbo_source_set("unit_tests") { ...@@ -174,6 +176,7 @@ jumbo_source_set("unit_tests") {
"base/work_queue_sets_unittest.cc", "base/work_queue_sets_unittest.cc",
"base/work_queue_unittest.cc", "base/work_queue_unittest.cc",
"child/webthread_impl_for_worker_scheduler_unittest.cc", "child/webthread_impl_for_worker_scheduler_unittest.cc",
"common/background_scheduler_unittest.cc",
"common/idle_canceled_delayed_task_sweeper_unittest.cc", "common/idle_canceled_delayed_task_sweeper_unittest.cc",
"common/idle_helper_unittest.cc", "common/idle_helper_unittest.cc",
"common/metrics_helper_unittest.cc", "common/metrics_helper_unittest.cc",
......
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/platform/threading/background_task_runner.h" #include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include "base/location.h" #include "base/location.h"
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
namespace blink { namespace blink {
void BackgroundTaskRunner::PostOnBackgroundThread( void BackgroundScheduler::PostOnBackgroundThread(const base::Location& location,
const base::Location& location, CrossThreadClosure closure) {
CrossThreadClosure closure) {
base::PostTaskWithTraits(location, base::PostTaskWithTraits(location,
{base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, {base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
ConvertToBaseCallback(std::move(closure))); ConvertToBaseCallback(std::move(closure)));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/platform/threading/background_task_runner.h" #include "third_party/blink/renderer/platform/scheduler/public/background_scheduler.h"
#include <memory> #include <memory>
#include "base/location.h" #include "base/location.h"
...@@ -21,10 +21,10 @@ void PingPongTask(WaitableEvent* done_event) { ...@@ -21,10 +21,10 @@ void PingPongTask(WaitableEvent* done_event) {
} // namespace } // namespace
TEST(BackgroundTaskRunnerTest, RunOnBackgroundThread) { TEST(BackgroundSchedulerTest, RunOnBackgroundThread) {
base::test::ScopedTaskEnvironment scoped_task_environment; base::test::ScopedTaskEnvironment scoped_task_environment;
std::unique_ptr<WaitableEvent> done_event = std::make_unique<WaitableEvent>(); std::unique_ptr<WaitableEvent> done_event = std::make_unique<WaitableEvent>();
BackgroundTaskRunner::PostOnBackgroundThread( BackgroundScheduler::PostOnBackgroundThread(
FROM_HERE, FROM_HERE,
CrossThreadBind(&PingPongTask, CrossThreadUnretained(done_event.get()))); CrossThreadBind(&PingPongTask, CrossThreadUnretained(done_event.get())));
// Test passes by not hanging on the following wait(). // Test passes by not hanging on the following wait().
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_THREADING_BACKGROUND_TASK_RUNNER_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_BACKGROUND_SCHEDULER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_THREADING_BACKGROUND_TASK_RUNNER_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_BACKGROUND_SCHEDULER_H_
#include "base/location.h" #include "base/location.h"
#include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/platform_export.h"
...@@ -11,13 +11,18 @@ ...@@ -11,13 +11,18 @@
namespace blink { namespace blink {
namespace BackgroundTaskRunner { namespace BackgroundScheduler {
// This is a thin wrapper around base::TaskScheduler to accomodate
// Blink's CrossThreadClosure, which only allows background tasks.
//
// Non-background tasks should be posted using another scheduler, e.g.
// FrameShceduler.
PLATFORM_EXPORT void PostOnBackgroundThread(const base::Location&, PLATFORM_EXPORT void PostOnBackgroundThread(const base::Location&,
CrossThreadClosure); CrossThreadClosure);
} // BackgroundTaskRunner } // namespace BackgroundScheduler
} // namespace blink } // namespace blink
#endif #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_SCHEDULER_PUBLIC_BACKGROUND_SCHEDULER_H_
include_rules = [
# Don't depend on platform/.
"-third_party/blink/renderer/platform",
# Module.
"+third_party/blink/renderer/platform/threading",
# Dependencies.
"+base/task_scheduler",
"+base/test",
"+third_party/blink/renderer/platform/cross_thread_functional.h",
"+third_party/blink/renderer/platform/platform_export.h",
"+third_party/blink/renderer/platform/threading/background_task_runner.h",
"+third_party/blink/renderer/platform/waitable_event.h",
"+third_party/blink/renderer/platform/wtf",
]
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