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 <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28206}
This commit is contained in:
Niels Möller 2019-06-03 15:25:20 +02:00 committed by Commit Bot
parent 12561e06ce
commit dec9f74b8d
5 changed files with 18 additions and 31 deletions

View file

@ -18,17 +18,6 @@
namespace webrtc { 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 // 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 // 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(). // 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 { bool RtcEventLogOutputFile::IsActive() const {
return IsActiveInternal(); return IsActiveInternal();
} }

View file

@ -16,7 +16,6 @@
#include <string> #include <string>
#include "api/rtc_event_log_output.h" #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" #include "rtc_base/system/file_wrapper.h"
namespace webrtc { namespace webrtc {
@ -33,10 +32,6 @@ class RtcEventLogOutputFile final : public RtcEventLogOutput {
// of the FILE*, and closes it on destruction. // of the FILE*, and closes it on destruction.
RtcEventLogOutputFile(FILE* file, size_t max_size_bytes); 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; ~RtcEventLogOutputFile() override = default;
bool IsActive() const override; bool IsActive() const override;

View file

@ -451,6 +451,12 @@ static const char kDtlsSdesFallbackSdp[] =
"inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 " "inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj|2^20|1:32 "
"dummy_session_params\r\n"; "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 ::cricket::StreamParams;
using ::testing::Exactly; using ::testing::Exactly;
using ::testing::Values; using ::testing::Values;
@ -3453,11 +3459,9 @@ TEST_P(PeerConnectionInterfaceTest,
// The RtcEventLog will be reset when the PeerConnection is closed. // The RtcEventLog will be reset when the PeerConnection is closed.
pc_->Close(); pc_->Close();
rtc::PlatformFile file = 0; EXPECT_FALSE(
int64_t max_size_bytes = 1024; pc_->StartRtcEventLog(absl::make_unique<webrtc::RtcEventLogOutputNull>(),
EXPECT_FALSE(pc_->StartRtcEventLog( webrtc::RtcEventLog::kImmediateOutput));
absl::make_unique<webrtc::RtcEventLogOutputFile>(file, max_size_bytes),
webrtc::RtcEventLog::kImmediateOutput));
pc_->StopRtcEventLog(); pc_->StopRtcEventLog();
} }

View file

@ -750,8 +750,13 @@ static jboolean JNI_PeerConnection_StartRtcEventLog(
const size_t max_size = (max_size_bytes < 0) const size_t max_size = (max_size_bytes < 0)
? RtcEventLog::kUnlimitedOutput ? RtcEventLog::kUnlimitedOutput
: rtc::saturated_cast<size_t>(max_size_bytes); : rtc::saturated_cast<size_t>(max_size_bytes);
FILE* f = fdopen(file_descriptor, "wb");
if (!f) {
close(file_descriptor);
return false;
}
return ExtractNativePC(jni, j_pc)->StartRtcEventLog( return ExtractNativePC(jni, j_pc)->StartRtcEventLog(
absl::make_unique<RtcEventLogOutputFile>(file_descriptor, max_size)); absl::make_unique<RtcEventLogOutputFile>(f, max_size));
} }
static void JNI_PeerConnection_StopRtcEventLog( static void JNI_PeerConnection_StopRtcEventLog(

View file

@ -536,9 +536,8 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
RTCLogError(@"Event logging already started."); RTCLogError(@"Event logging already started.");
return NO; return NO;
} }
int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, FILE *f = fopen(filePath.UTF8String, "wb");
S_IRUSR | S_IWUSR); if (!f) {
if (fd < 0) {
RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno); RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
return NO; return NO;
} }
@ -547,7 +546,7 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
rtc::saturated_cast<size_t>(maxSizeInBytes); rtc::saturated_cast<size_t>(maxSizeInBytes);
_hasStartedRtcEventLog = _peerConnection->StartRtcEventLog( _hasStartedRtcEventLog = _peerConnection->StartRtcEventLog(
absl::make_unique<webrtc::RtcEventLogOutputFile>(fd, max_size)); absl::make_unique<webrtc::RtcEventLogOutputFile>(f, max_size));
return _hasStartedRtcEventLog; return _hasStartedRtcEventLog;
} }