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}
This commit is contained in:
Danil Chapovalov 2019-04-05 14:49:45 +02:00 committed by Commit Bot
parent 59e875ce18
commit 7b7485b796
6 changed files with 18 additions and 22 deletions

View File

@ -479,7 +479,6 @@ 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,7 +9,6 @@
*/
#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 {
@ -18,10 +17,6 @@ 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,8 +80,6 @@ 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,9 +15,7 @@ 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",
]
@ -501,6 +499,7 @@ 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,6 +18,7 @@
#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"
@ -148,6 +149,19 @@ 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) {
@ -159,9 +173,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 = "";
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());
rtc::TaskQueue worker_queue(GetTaskQueueFactory()->CreateTaskQueue(
"rtc-low-prio", rtc::TaskQueue::Priority::LOW));
auto apm = CreateApm(&fuzz_data, &field_trial_string, &worker_queue);
if (apm) {
FuzzAudioProcessing(&fuzz_data, std::move(apm));

View File

@ -12,9 +12,7 @@
// 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;
@ -28,13 +26,6 @@ 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