Provide the option of injecting rtc::TaskQueue when creating RtcEventLogImpl via factory methods.
Bug: webrtc:9004 Change-Id: Ia7cc96074dbf84f576e5fb0762866b213ec8e69f Reviewed-on: https://webrtc-review.googlesource.com/63022 Commit-Queue: Dino Radaković <dinor@webrtc.org> Reviewed-by: Elad Alon <eladalon@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22520}
This commit is contained in:
parent
fe48ee9e2c
commit
e9d2e4d3fb
@ -44,6 +44,7 @@ rtc_source_set("rtc_event_log_api") {
|
||||
deps = [
|
||||
"../api:libjingle_logging_api",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base:rtc_task_queue",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include "api/rtceventlogoutput.h"
|
||||
#include "logging/rtc_event_log/events/rtc_event.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -37,6 +38,12 @@ class RtcEventLog {
|
||||
// Factory method to create an RtcEventLog object.
|
||||
static std::unique_ptr<RtcEventLog> Create(EncodingType encoding_type);
|
||||
|
||||
// Factory method to create an RtcEventLog object which uses the given
|
||||
// rtc::TaskQueue for emitting output.
|
||||
static std::unique_ptr<RtcEventLog> Create(
|
||||
EncodingType encoding_type,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue);
|
||||
|
||||
// Create an RtcEventLog object that does nothing.
|
||||
static std::unique_ptr<RtcEventLog> CreateNull();
|
||||
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
#include "logging/rtc_event_log/rtc_event_log_factory.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -19,6 +21,12 @@ std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
|
||||
return RtcEventLog::Create(encoding_type);
|
||||
}
|
||||
|
||||
std::unique_ptr<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
|
||||
RtcEventLog::EncodingType encoding_type,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue) {
|
||||
return RtcEventLog::Create(encoding_type, std::move(task_queue));
|
||||
}
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory() {
|
||||
return std::unique_ptr<RtcEventLogFactoryInterface>(new RtcEventLogFactory());
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -23,6 +24,10 @@ class RtcEventLogFactory : public RtcEventLogFactoryInterface {
|
||||
|
||||
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||
RtcEventLog::EncodingType encoding_type) override;
|
||||
|
||||
std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||
RtcEventLog::EncodingType encoding_type,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue) override;
|
||||
};
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -26,6 +27,10 @@ class RtcEventLogFactoryInterface {
|
||||
|
||||
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||
RtcEventLog::EncodingType encoding_type) = 0;
|
||||
|
||||
virtual std::unique_ptr<RtcEventLog> CreateRtcEventLog(
|
||||
RtcEventLog::EncodingType encoding_type,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
|
||||
|
||||
@ -81,10 +81,9 @@ std::unique_ptr<RtcEventLogEncoder> CreateEncoder(
|
||||
|
||||
class RtcEventLogImpl final : public RtcEventLog {
|
||||
public:
|
||||
explicit RtcEventLogImpl(
|
||||
std::unique_ptr<RtcEventLogEncoder> event_encoder,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue =
|
||||
rtc::MakeUnique<rtc::TaskQueue>("rtc_event_log"));
|
||||
RtcEventLogImpl(std::unique_ptr<RtcEventLogEncoder> event_encoder,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue);
|
||||
|
||||
~RtcEventLogImpl() override;
|
||||
|
||||
// TODO(eladalon): We should change these name to reflect that what we're
|
||||
@ -363,6 +362,13 @@ void RtcEventLogImpl::WriteToOutput(const std::string& output_string) {
|
||||
|
||||
// RtcEventLog member functions.
|
||||
std::unique_ptr<RtcEventLog> RtcEventLog::Create(EncodingType encoding_type) {
|
||||
return Create(encoding_type,
|
||||
rtc::MakeUnique<rtc::TaskQueue>("rtc_event_log"));
|
||||
}
|
||||
|
||||
std::unique_ptr<RtcEventLog> RtcEventLog::Create(
|
||||
EncodingType encoding_type,
|
||||
std::unique_ptr<rtc::TaskQueue> task_queue) {
|
||||
#ifdef ENABLE_RTC_EVENT_LOG
|
||||
// TODO(eladalon): Known issue - there's a race over |rtc_event_log_count|.
|
||||
constexpr int kMaxLogCount = 5;
|
||||
@ -374,7 +380,8 @@ std::unique_ptr<RtcEventLog> RtcEventLog::Create(EncodingType encoding_type) {
|
||||
return CreateNull();
|
||||
}
|
||||
auto encoder = CreateEncoder(encoding_type);
|
||||
return rtc::MakeUnique<RtcEventLogImpl>(std::move(encoder));
|
||||
return rtc::MakeUnique<RtcEventLogImpl>(std::move(encoder),
|
||||
std::move(task_queue));
|
||||
#else
|
||||
return CreateNull();
|
||||
#endif // ENABLE_RTC_EVENT_LOG
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user