OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 written_bytes_ += output_string.size(); | 799 written_bytes_ += output_string.size(); |
800 } | 800 } |
801 | 801 |
802 max_size_bytes_ = std::numeric_limits<decltype(max_size_bytes_)>::max(); | 802 max_size_bytes_ = std::numeric_limits<decltype(max_size_bytes_)>::max(); |
803 written_bytes_ = 0; | 803 written_bytes_ = 0; |
804 | 804 |
805 file_->CloseFile(); | 805 file_->CloseFile(); |
806 RTC_DCHECK(!file_->is_open()); | 806 RTC_DCHECK(!file_->is_open()); |
807 } | 807 } |
808 | 808 |
809 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, | |
810 rtclog::EventStream* result) { | |
811 char tmp_buffer[1024]; | |
812 int bytes_read = 0; | |
813 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); | |
814 if (!dump_file->OpenFile(file_name.c_str(), true)) { | |
815 return false; | |
816 } | |
817 ProtoString dump_buffer; | |
818 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) { | |
819 dump_buffer.append(tmp_buffer, bytes_read); | |
820 } | |
821 dump_file->CloseFile(); | |
822 return result->ParseFromString(dump_buffer); | |
823 } | |
824 | |
825 #endif // ENABLE_RTC_EVENT_LOG | 809 #endif // ENABLE_RTC_EVENT_LOG |
826 | 810 |
827 // RtcEventLog member functions. | 811 // RtcEventLog member functions. |
828 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { | 812 std::unique_ptr<RtcEventLog> RtcEventLog::Create() { |
829 #ifdef ENABLE_RTC_EVENT_LOG | 813 #ifdef ENABLE_RTC_EVENT_LOG |
830 // TODO(eladalon): Known issue - there's a race over |log_count_| here. | 814 // TODO(eladalon): Known issue - there's a race over |log_count_| here. |
831 constexpr int kMaxLogCount = 5; | 815 constexpr int kMaxLogCount = 5; |
832 int count = 1 + std::atomic_fetch_add(&RtcEventLogImpl::log_count_, 1); | 816 int count = 1 + std::atomic_fetch_add(&RtcEventLogImpl::log_count_, 1); |
833 if (count > kMaxLogCount) { | 817 if (count > kMaxLogCount) { |
834 LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. " | 818 LOG(LS_WARNING) << "Denied creation of additional WebRTC event logs. " |
835 << count - 1 << " logs open already."; | 819 << count - 1 << " logs open already."; |
836 std::atomic_fetch_sub(&RtcEventLogImpl::log_count_, 1); | 820 std::atomic_fetch_sub(&RtcEventLogImpl::log_count_, 1); |
837 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 821 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
838 } | 822 } |
839 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); | 823 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl()); |
840 #else | 824 #else |
841 return CreateNull(); | 825 return CreateNull(); |
842 #endif // ENABLE_RTC_EVENT_LOG | 826 #endif // ENABLE_RTC_EVENT_LOG |
843 } | 827 } |
844 | 828 |
845 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { | 829 std::unique_ptr<RtcEventLog> RtcEventLog::CreateNull() { |
846 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 830 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
847 } | 831 } |
848 | 832 |
849 } // namespace webrtc | 833 } // namespace webrtc |
OLD | NEW |