From dec9f74b8d321da907b9f8df5e3ed66d9cee58da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 3 Jun 2019 15:25:20 +0200 Subject: [PATCH] Delete obsolete RtcEventLogOutputFile constructor Followup to https://webrtc-review.googlesource.com/c/src/+/134460. Bug: webrtc:6463 Change-Id: Ib6574b02b21fddc598c1f67c7e2b515f01d33204 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/139887 Reviewed-by: Karl Wiberg Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#28206} --- api/rtc_event_log_output_file.cc | 16 ---------------- api/rtc_event_log_output_file.h | 5 ----- pc/peer_connection_interface_unittest.cc | 14 +++++++++----- sdk/android/src/jni/pc/peer_connection.cc | 7 ++++++- sdk/objc/api/peerconnection/RTCPeerConnection.mm | 7 +++---- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/api/rtc_event_log_output_file.cc b/api/rtc_event_log_output_file.cc index c300a54fce..404eb3138b 100644 --- a/api/rtc_event_log_output_file.cc +++ b/api/rtc_event_log_output_file.cc @@ -18,17 +18,6 @@ namespace webrtc { -namespace { - -FileWrapper FileWrapperFromPlatformFile(rtc::PlatformFile platform_file) { - if (platform_file == rtc::kInvalidPlatformFileValue) - return FileWrapper(); - - return FileWrapper(rtc::FdopenPlatformFileForWriting(platform_file)); -} - -} // namespace - // Together with the assumption of no single Write() would ever be called on // an input with length greater-than-or-equal-to (max(size_t) / 2), this // guarantees no overflow of the check for remaining file capacity in Write(). @@ -60,11 +49,6 @@ RtcEventLogOutputFile::RtcEventLogOutputFile(FileWrapper file, } } -RtcEventLogOutputFile::RtcEventLogOutputFile(rtc::PlatformFile platform_file, - size_t max_size_bytes) - : RtcEventLogOutputFile(FileWrapperFromPlatformFile(platform_file), - max_size_bytes) {} - bool RtcEventLogOutputFile::IsActive() const { return IsActiveInternal(); } diff --git a/api/rtc_event_log_output_file.h b/api/rtc_event_log_output_file.h index e536dfc459..e1d18e0889 100644 --- a/api/rtc_event_log_output_file.h +++ b/api/rtc_event_log_output_file.h @@ -16,7 +16,6 @@ #include #include "api/rtc_event_log_output.h" -#include "rtc_base/platform_file.h" // Can't neatly forward PlatformFile. #include "rtc_base/system/file_wrapper.h" namespace webrtc { @@ -33,10 +32,6 @@ class RtcEventLogOutputFile final : public RtcEventLogOutput { // of the FILE*, and closes it on destruction. RtcEventLogOutputFile(FILE* file, size_t max_size_bytes); - // TODO(bugs.webrtc.org/6463): Deprecated, delete together with the - // corresponding PeerConnection::StartRtcEventLog override. - RtcEventLogOutputFile(rtc::PlatformFile file, size_t max_size_bytes); - ~RtcEventLogOutputFile() override = default; bool IsActive() const override; diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc index 4549912225..2ea3e8680b 100644 --- a/pc/peer_connection_interface_unittest.cc +++ b/pc/peer_connection_interface_unittest.cc @@ -451,6 +451,12 @@ static const char kDtlsSdesFallbackSdp[] = "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 " "dummy_session_params\r\n"; +class RtcEventLogOutputNull final : public RtcEventLogOutput { + public: + bool IsActive() const override { return true; } + bool Write(const std::string& output) override { return true; } +}; + using ::cricket::StreamParams; using ::testing::Exactly; using ::testing::Values; @@ -3453,11 +3459,9 @@ TEST_P(PeerConnectionInterfaceTest, // The RtcEventLog will be reset when the PeerConnection is closed. pc_->Close(); - rtc::PlatformFile file = 0; - int64_t max_size_bytes = 1024; - EXPECT_FALSE(pc_->StartRtcEventLog( - absl::make_unique(file, max_size_bytes), - webrtc::RtcEventLog::kImmediateOutput)); + EXPECT_FALSE( + pc_->StartRtcEventLog(absl::make_unique(), + webrtc::RtcEventLog::kImmediateOutput)); pc_->StopRtcEventLog(); } diff --git a/sdk/android/src/jni/pc/peer_connection.cc b/sdk/android/src/jni/pc/peer_connection.cc index 1e3a73d7ee..311ceaf21e 100644 --- a/sdk/android/src/jni/pc/peer_connection.cc +++ b/sdk/android/src/jni/pc/peer_connection.cc @@ -750,8 +750,13 @@ static jboolean JNI_PeerConnection_StartRtcEventLog( const size_t max_size = (max_size_bytes < 0) ? RtcEventLog::kUnlimitedOutput : rtc::saturated_cast(max_size_bytes); + FILE* f = fdopen(file_descriptor, "wb"); + if (!f) { + close(file_descriptor); + return false; + } return ExtractNativePC(jni, j_pc)->StartRtcEventLog( - absl::make_unique(file_descriptor, max_size)); + absl::make_unique(f, max_size)); } static void JNI_PeerConnection_StopRtcEventLog( diff --git a/sdk/objc/api/peerconnection/RTCPeerConnection.mm b/sdk/objc/api/peerconnection/RTCPeerConnection.mm index bed85f9afe..04b07f7533 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnection.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnection.mm @@ -536,9 +536,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( RTCLogError(@"Event logging already started."); return NO; } - int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, - S_IRUSR | S_IWUSR); - if (fd < 0) { + FILE *f = fopen(filePath.UTF8String, "wb"); + if (!f) { RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno); return NO; } @@ -547,7 +546,7 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack( rtc::saturated_cast(maxSizeInBytes); _hasStartedRtcEventLog = _peerConnection->StartRtcEventLog( - absl::make_unique(fd, max_size)); + absl::make_unique(f, max_size)); return _hasStartedRtcEventLog; }