Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Side by Side Diff: webrtc/call/rtc_event_log.cc

Issue 2054373002: FileWrapper[Impl] modifications and actually remove the "Impl" class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix use of ASSERT instead of ASSERT_TRUE in test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/call/rtc_event_log_helper_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int64_t max_size_bytes) { 181 int64_t max_size_bytes) {
182 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 182 RTC_DCHECK(thread_checker_.CalledOnValidThread());
183 RtcEventLogHelperThread::ControlMessage message; 183 RtcEventLogHelperThread::ControlMessage message;
184 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE; 184 message.message_type = RtcEventLogHelperThread::ControlMessage::START_FILE;
185 message.max_size_bytes = max_size_bytes <= 0 185 message.max_size_bytes = max_size_bytes <= 0
186 ? std::numeric_limits<int64_t>::max() 186 ? std::numeric_limits<int64_t>::max()
187 : max_size_bytes; 187 : max_size_bytes;
188 message.start_time = clock_->TimeInMicroseconds(); 188 message.start_time = clock_->TimeInMicroseconds();
189 message.stop_time = std::numeric_limits<int64_t>::max(); 189 message.stop_time = std::numeric_limits<int64_t>::max();
190 message.file.reset(FileWrapper::Create()); 190 message.file.reset(FileWrapper::Create());
191 if (message.file->OpenFile(file_name.c_str(), false) != 0) { 191 if (!message.file->OpenFile(file_name.c_str(), false)) {
192 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; 192 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
193 return false; 193 return false;
194 } 194 }
195 if (!message_queue_.Insert(&message)) { 195 if (!message_queue_.Insert(&message)) {
196 LOG(LS_ERROR) << "Message queue full. Can't start logging."; 196 LOG(LS_ERROR) << "Message queue full. Can't start logging.";
197 return false; 197 return false;
198 } 198 }
199 helper_thread_.SignalNewEvent(); 199 helper_thread_.SignalNewEvent();
200 LOG(LS_INFO) << "Starting WebRTC event log."; 200 LOG(LS_INFO) << "Starting WebRTC event log.";
201 return true; 201 return true;
(...skipping 13 matching lines...) Expand all
215 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file); 215 FILE* file_handle = rtc::FdopenPlatformFileForWriting(platform_file);
216 if (!file_handle) { 216 if (!file_handle) {
217 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; 217 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
218 // Even though we failed to open a FILE*, the platform_file is still open 218 // Even though we failed to open a FILE*, the platform_file is still open
219 // and needs to be closed. 219 // and needs to be closed.
220 if (!rtc::ClosePlatformFile(platform_file)) { 220 if (!rtc::ClosePlatformFile(platform_file)) {
221 LOG(LS_ERROR) << "Can't close file."; 221 LOG(LS_ERROR) << "Can't close file.";
222 } 222 }
223 return false; 223 return false;
224 } 224 }
225 if (message.file->OpenFromFileHandle(file_handle, true, false) != 0) { 225 if (!message.file->OpenFromFileHandle(file_handle)) {
226 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started."; 226 LOG(LS_ERROR) << "Can't open file. WebRTC event log not started.";
227 return false; 227 return false;
228 } 228 }
229 if (!message_queue_.Insert(&message)) { 229 if (!message_queue_.Insert(&message)) {
230 LOG(LS_ERROR) << "Message queue full. Can't start logging."; 230 LOG(LS_ERROR) << "Message queue full. Can't start logging.";
231 return false; 231 return false;
232 } 232 }
233 helper_thread_.SignalNewEvent(); 233 helper_thread_.SignalNewEvent();
234 LOG(LS_INFO) << "Starting WebRTC event log."; 234 LOG(LS_INFO) << "Starting WebRTC event log.";
235 return true; 235 return true;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event."; 436 LOG(LS_ERROR) << "WebRTC event log queue full. Dropping event.";
437 } 437 }
438 helper_thread_.SignalNewEvent(); 438 helper_thread_.SignalNewEvent();
439 } 439 }
440 440
441 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name, 441 bool RtcEventLog::ParseRtcEventLog(const std::string& file_name,
442 rtclog::EventStream* result) { 442 rtclog::EventStream* result) {
443 char tmp_buffer[1024]; 443 char tmp_buffer[1024];
444 int bytes_read = 0; 444 int bytes_read = 0;
445 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create()); 445 std::unique_ptr<FileWrapper> dump_file(FileWrapper::Create());
446 if (dump_file->OpenFile(file_name.c_str(), true) != 0) { 446 if (!dump_file->OpenFile(file_name.c_str(), true)) {
447 return false; 447 return false;
448 } 448 }
449 std::string dump_buffer; 449 std::string dump_buffer;
450 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) { 450 while ((bytes_read = dump_file->Read(tmp_buffer, sizeof(tmp_buffer))) > 0) {
451 dump_buffer.append(tmp_buffer, bytes_read); 451 dump_buffer.append(tmp_buffer, bytes_read);
452 } 452 }
453 dump_file->CloseFile(); 453 dump_file->CloseFile();
454 return result->ParseFromString(dump_buffer); 454 return result->ParseFromString(dump_buffer);
455 } 455 }
456 456
457 #endif // ENABLE_RTC_EVENT_LOG 457 #endif // ENABLE_RTC_EVENT_LOG
458 458
459 // RtcEventLog member functions. 459 // RtcEventLog member functions.
460 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) { 460 std::unique_ptr<RtcEventLog> RtcEventLog::Create(const Clock* clock) {
461 #ifdef ENABLE_RTC_EVENT_LOG 461 #ifdef ENABLE_RTC_EVENT_LOG
462 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock)); 462 return std::unique_ptr<RtcEventLog>(new RtcEventLogImpl(clock));
463 #else 463 #else
464 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl()); 464 return std::unique_ptr<RtcEventLog>(new RtcEventLogNullImpl());
465 #endif // ENABLE_RTC_EVENT_LOG 465 #endif // ENABLE_RTC_EVENT_LOG
466 } 466 }
467 467
468 } // namespace webrtc 468 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/call/rtc_event_log_helper_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698