RtcEventLog::Create() no longer a friend of RtcEventLogImpl

By making RtcEventLogImpl's ctor public, we remove the necessity to make the function a friend. Visibility of RtcEventLogImpl is still limited to the .cc file.

BUG=webrtc:8111

Change-Id: I774d2e93620a8d9f24299ef2a94f7593b490839d
Reviewed-on: https://webrtc-review.googlesource.com/1237
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19876}
This commit is contained in:
Elad Alon 2017-09-15 14:49:55 +02:00 committed by Commit Bot
parent d45aea8f42
commit 2782904c56

View File

@ -96,12 +96,10 @@ class ResourceOwningTask final : public rtc::QueuedTask {
std::unique_ptr<T> resource_; std::unique_ptr<T> resource_;
std::function<void(std::unique_ptr<T>)> handler_; std::function<void(std::unique_ptr<T>)> handler_;
}; };
} // namespace
class RtcEventLogImpl final : public RtcEventLog { class RtcEventLogImpl final : public RtcEventLog {
friend std::unique_ptr<RtcEventLog> RtcEventLog::Create();
public: public:
RtcEventLogImpl();
~RtcEventLogImpl() override; ~RtcEventLogImpl() override;
bool StartLogging(const std::string& file_name, bool StartLogging(const std::string& file_name,
@ -143,8 +141,6 @@ class RtcEventLogImpl final : public RtcEventLog {
void StartLoggingInternal(std::unique_ptr<FileWrapper> file, void StartLoggingInternal(std::unique_ptr<FileWrapper> file,
int64_t max_size_bytes); int64_t max_size_bytes);
RtcEventLogImpl(); // Creation is done by RtcEventLog::Create.
void StoreEvent(std::unique_ptr<rtclog::Event> event); void StoreEvent(std::unique_ptr<rtclog::Event> event);
void LogProbeResult(int id, void LogProbeResult(int id,
rtclog::BweProbeResult::ResultType result, rtclog::BweProbeResult::ResultType result,
@ -186,11 +182,6 @@ class RtcEventLogImpl final : public RtcEventLog {
RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogImpl); RTC_DISALLOW_COPY_AND_ASSIGN(RtcEventLogImpl);
}; };
namespace {
// The functions in this namespace convert enums from the runtime format
// that the rest of the WebRtc project can use, to the corresponding
// serialized enum which is defined by the protobuf.
rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) { rtclog::VideoReceiveConfig_RtcpMode ConvertRtcpMode(RtcpMode rtcp_mode) {
switch (rtcp_mode) { switch (rtcp_mode) {
case RtcpMode::kCompound: case RtcpMode::kCompound:
@ -233,8 +224,6 @@ rtclog::BweProbeResult::ResultType ConvertProbeResultType(
return rtclog::BweProbeResult::SUCCESS; return rtclog::BweProbeResult::SUCCESS;
} }
} // namespace
RtcEventLogImpl::RtcEventLogImpl() RtcEventLogImpl::RtcEventLogImpl()
: file_(FileWrapper::Create()), : file_(FileWrapper::Create()),
max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()), max_size_bytes_(std::numeric_limits<decltype(max_size_bytes_)>::max()),
@ -804,6 +793,8 @@ void RtcEventLogImpl::StopLogFile(int64_t stop_time) {
RTC_DCHECK(!file_->is_open()); RTC_DCHECK(!file_->is_open());
} }
} // namespace
#endif // ENABLE_RTC_EVENT_LOG #endif // ENABLE_RTC_EVENT_LOG
// RtcEventLog member functions. // RtcEventLog member functions.
@ -816,9 +807,9 @@ std::unique_ptr<RtcEventLog> RtcEventLog::Create() {
LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. " LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. "
<< count - 1 << " logs open already."; << count - 1 << " logs open already.";
std::atomic_fetch_sub(&rtc_event_log_count, 1); std::atomic_fetch_sub(&rtc_event_log_count, 1);
return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); return CreateNull();
} }
return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); return rtc::MakeUnique<RtcEventLogImpl>();
#else #else
return CreateNull(); return CreateNull();
#endif // ENABLE_RTC_EVENT_LOG #endif // ENABLE_RTC_EVENT_LOG