Revert "Remove TaskQueue constructor that uses GlobalTaskQueueFactory"

This reverts commit 7b7485b796.

Reason for revert: Breaks Chrome autoroll 

video/video_stream_decoder_impl.cc:28:7: error: no matching constructor for initialization of 'rtc::TaskQueue'
      bookkeeping_queue_("video_stream_decoder_bookkeeping_queue"),

Original change's description:
> Remove TaskQueue constructor that uses GlobalTaskQueueFactory
> 
> Bug: webrtc:10284
> Change-Id: I9547fb7110222ce3a3c2323ae2a004024eab911e
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130471
> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#27464}

TBR=danilchap@webrtc.org,kwiberg@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:10284
Change-Id: I7684f7c7d5501cc910ac9f9daa8ccf6bdb10f8e1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131338
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27491}
This commit is contained in:
Florent Castelli 2019-04-08 13:34:38 +00:00 committed by Commit Bot
parent 14d1c9d968
commit 57f2a5485a
6 changed files with 22 additions and 18 deletions

View file

@ -479,6 +479,7 @@ rtc_source_set("rtc_task_queue") {
deps = [
":macromagic",
"../api/task_queue",
"../api/task_queue:global_task_queue_factory",
"system:rtc_export",
"task_utils:to_queued_task",
"//third_party/abseil-cpp/absl/memory",

View file

@ -9,6 +9,7 @@
*/
#include "rtc_base/task_queue.h"
#include "api/task_queue/global_task_queue_factory.h"
#include "api/task_queue/task_queue_base.h"
namespace rtc {
@ -17,6 +18,10 @@ TaskQueue::TaskQueue(
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter> task_queue)
: impl_(task_queue.release()) {}
TaskQueue::TaskQueue(const char* queue_name, Priority priority)
: TaskQueue(webrtc::GlobalTaskQueueFactory().CreateTaskQueue(queue_name,
priority)) {}
TaskQueue::~TaskQueue() {
// There might running task that tries to rescheduler itself to the TaskQueue
// and not yet aware TaskQueue destructor is called.

View file

@ -80,6 +80,8 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
explicit TaskQueue(std::unique_ptr<webrtc::TaskQueueBase,
webrtc::TaskQueueDeleter> task_queue);
explicit TaskQueue(const char* queue_name,
Priority priority = Priority::NORMAL);
~TaskQueue();
// Used for DCHECKing the current queue.

View file

@ -15,7 +15,9 @@ rtc_static_library("webrtc_fuzzer_main") {
"webrtc_fuzzer_main.cc",
]
deps = [
"../../api/task_queue:global_task_queue_factory",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue_stdlib",
"//testing/libfuzzer:libfuzzer_main",
]
@ -499,7 +501,6 @@ webrtc_fuzzer_test("audio_processing_fuzzer") {
"../../modules/audio_processing/aec_dump:aec_dump_impl",
"../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../rtc_base:rtc_task_queue_stdlib",
"../../rtc_base:safe_minmax",
"../../system_wrappers:field_trial",
"//third_party/abseil-cpp/absl/memory",

View file

@ -18,7 +18,6 @@
#include "rtc_base/arraysize.h"
#include "rtc_base/numerics/safe_minmax.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/task_queue_stdlib.h"
#include "system_wrappers/include/field_trial.h"
#include "test/fuzzers/audio_processing_fuzzer_helper.h"
#include "test/fuzzers/fuzz_data_helper.h"
@ -149,19 +148,6 @@ std::unique_ptr<AudioProcessing> CreateApm(test::FuzzDataHelper* fuzz_data,
return apm;
}
TaskQueueFactory* GetTaskQueueFactory() {
// Chromium hijacked DefaultTaskQueueFactory with own implementation, but
// unable to use it without base::test::ScopedTaskEnvironment. Actual used
// task queue implementation shouldn't matter for the purpose of this fuzzer,
// so use stdlib implementation: that one is multiplatform.
// When bugs.webrtc.org/10284 is resolved and chromium stops hijacking
// DefaultTaskQueueFactory, Stdlib can be replaced with default one.
static TaskQueueFactory* const factory =
CreateTaskQueueStdlibFactory().release();
return factory;
}
} // namespace
void FuzzOneInput(const uint8_t* data, size_t size) {
@ -173,9 +159,9 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
// for field_trial.h. Hence it's created here and not in CreateApm.
std::string field_trial_string = "";
rtc::TaskQueue worker_queue(GetTaskQueueFactory()->CreateTaskQueue(
"rtc-low-prio", rtc::TaskQueue::Priority::LOW));
auto apm = CreateApm(&fuzz_data, &field_trial_string, &worker_queue);
std::unique_ptr<rtc::TaskQueue> worker_queue(
new rtc::TaskQueue("rtc-low-prio", rtc::TaskQueue::Priority::LOW));
auto apm = CreateApm(&fuzz_data, &field_trial_string, worker_queue.get());
if (apm) {
FuzzAudioProcessing(&fuzz_data, std::move(apm));

View file

@ -12,7 +12,9 @@
// It's intended to set sane defaults, such as removing logging for further
// fuzzing efficiency.
#include "api/task_queue/global_task_queue_factory.h"
#include "rtc_base/logging.h"
#include "rtc_base/task_queue_stdlib.h"
namespace {
bool g_initialized = false;
@ -26,6 +28,13 @@ void InitializeWebRtcFuzzDefaults() {
rtc::LogMessage::LogToDebug(rtc::LS_NONE);
#endif // !defined(WEBRTC_CHROMIUM_BUILD)
// Chromium hijacked DefaultTaskQueueFactory with own implementation, but
// unable to use it without base::test::ScopedTaskEnvironment. Actual used
// task queue implementation shouldn't matter for the purpose of the fuzzers,
// so use stdlib implementation: that one is multiplatform. This is a
// temporary solution until bugs.webrtc.org/10284 is resolved.
webrtc::SetGlobalTaskQueueFactory(webrtc::CreateTaskQueueStdlibFactory());
g_initialized = true;
}
} // namespace