| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 RtcEventLogImpl::~RtcEventLogImpl() { | 176 RtcEventLogImpl::~RtcEventLogImpl() { |
| 177 // The RtcEventLogHelperThread destructor closes the file | 177 // The RtcEventLogHelperThread destructor closes the file |
| 178 // and waits for the thread to terminate. | 178 // and waits for the thread to terminate. |
| 179 } | 179 } |
| 180 | 180 |
| 181 bool RtcEventLogImpl::StartLogging(const std::string& file_name, | 181 bool RtcEventLogImpl::StartLogging(const std::string& file_name, |
| 182 int64_t max_size_bytes) { | 182 int64_t max_size_bytes) { |
| 183 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 183 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 184 RtcEventLogHelperThread::ControlMessage message; | 184 RtcEventLogHelperThread::ControlMessage message; |
| 185 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 185 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
| 186 message.max_size_bytes = max_size_bytes; | 186 message.max_size_bytes = max_size_bytes <= 0 |
| 187 ? std::numeric_limits<int64_t>::max() |
| 188 : max_size_bytes; |
| 187 message.start_time = clock_->TimeInMicroseconds(); | 189 message.start_time = clock_->TimeInMicroseconds(); |
| 188 message.stop_time = std::numeric_limits<int64_t>::max(); | 190 message.stop_time = std::numeric_limits<int64_t>::max(); |
| 189 message.file.reset(FileWrapper::Create()); | 191 message.file.reset(FileWrapper::Create()); |
| 190 if (message.file->OpenFile(file_name.c_str(), false) != 0) { | 192 if (message.file->OpenFile(file_name.c_str(), false) != 0) { |
| 191 return false; | 193 return false; |
| 192 } | 194 } |
| 193 if (!message_queue_.Insert(&message)) { | 195 if (!message_queue_.Insert(&message)) { |
| 194 LOG(LS_WARNING) << "Message queue full. Can't start logging."; | 196 LOG(LS_WARNING) << "Message queue full. Can't start logging."; |
| 195 return false; | 197 return false; |
| 196 } | 198 } |
| 197 return true; | 199 return true; |
| 198 } | 200 } |
| 199 | 201 |
| 200 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, | 202 bool RtcEventLogImpl::StartLogging(rtc::PlatformFile platform_file, |
| 201 int64_t max_size_bytes) { | 203 int64_t max_size_bytes) { |
| 202 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 204 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 203 RtcEventLogHelperThread::ControlMessage message; | 205 RtcEventLogHelperThread::ControlMessage message; |
| 204 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; | 206 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; |
| 205 message.max_size_bytes = max_size_bytes; | 207 message.max_size_bytes = max_size_bytes <= 0 |
| 208 ? std::numeric_limits<int64_t>::max() |
| 209 : max_size_bytes; |
| 206 message.start_time = clock_->TimeInMicroseconds(); | 210 message.start_time = clock_->TimeInMicroseconds(); |
| 207 message.stop_time = std::numeric_limits<int64_t>::max(); | 211 message.stop_time = std::numeric_limits<int64_t>::max(); |
| 208 message.file.reset(FileWrapper::Create()); | 212 message.file.reset(FileWrapper::Create()); |
| 209 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); | 213 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); |
| 210 if (!file_handle) { | 214 if (!file_handle) { |
| 211 return false; | 215 return false; |
| 212 } | 216 } |
| 213 if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) { | 217 if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) { |
| 214 return false; | 218 return false; |
| 215 } | 219 } |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // RtcEventLog member functions. | 453 // RtcEventLog member functions. |
| 450 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { | 454 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { |
| 451 #ifdef ENABLE_RTC_EVENT_LOG | 455 #ifdef ENABLE_RTC_EVENT_LOG |
| 452 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); | 456 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); |
| 453 #else | 457 #else |
| 454 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); | 458 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); |
| 455 #endif // ENABLE_RTC_EVENT_LOG | 459 #endif // ENABLE_RTC_EVENT_LOG |
| 456 } | 460 } |
| 457 | 461 |
| 458 } // namespace webrtc | 462 } // namespace webrtc |
| OLD | NEW |