| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2012 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 #include "webrtc/rtc_base/event_tracer.h" | 10 #include "webrtc/rtc_base/event_tracer.h" | 
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 367 }  // namespace | 367 }  // namespace | 
| 368 | 368 | 
| 369 void SetupInternalTracer() { | 369 void SetupInternalTracer() { | 
| 370   RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( | 370   RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( | 
| 371                 &g_event_logger, static_cast<EventLogger*>(nullptr), | 371                 &g_event_logger, static_cast<EventLogger*>(nullptr), | 
| 372                 new EventLogger()) == nullptr); | 372                 new EventLogger()) == nullptr); | 
| 373   webrtc::SetupEventTracer(InternalGetCategoryEnabled, InternalAddTraceEvent); | 373   webrtc::SetupEventTracer(InternalGetCategoryEnabled, InternalAddTraceEvent); | 
| 374 } | 374 } | 
| 375 | 375 | 
| 376 void StartInternalCaptureToFile(FILE* file) { | 376 void StartInternalCaptureToFile(FILE* file) { | 
| 377   g_event_logger->Start(file, false); | 377   if (g_event_logger) { | 
|  | 378     g_event_logger->Start(file, false); | 
|  | 379   } | 
| 378 } | 380 } | 
| 379 | 381 | 
| 380 bool StartInternalCapture(const char* filename) { | 382 bool StartInternalCapture(const char* filename) { | 
|  | 383   if (!g_event_logger) | 
|  | 384     return false; | 
|  | 385 | 
| 381   FILE* file = fopen(filename, "w"); | 386   FILE* file = fopen(filename, "w"); | 
| 382   if (!file) { | 387   if (!file) { | 
| 383     LOG(LS_ERROR) << "Failed to open trace file '" << filename | 388     LOG(LS_ERROR) << "Failed to open trace file '" << filename | 
| 384                   << "' for writing."; | 389                   << "' for writing."; | 
| 385     return false; | 390     return false; | 
| 386   } | 391   } | 
| 387   g_event_logger->Start(file, true); | 392   g_event_logger->Start(file, true); | 
| 388   return true; | 393   return true; | 
| 389 } | 394 } | 
| 390 | 395 | 
| 391 void StopInternalCapture() { | 396 void StopInternalCapture() { | 
| 392   g_event_logger->Stop(); | 397   if (g_event_logger) { | 
|  | 398     g_event_logger->Stop(); | 
|  | 399   } | 
| 393 } | 400 } | 
| 394 | 401 | 
| 395 void ShutdownInternalTracer() { | 402 void ShutdownInternalTracer() { | 
| 396   StopInternalCapture(); | 403   StopInternalCapture(); | 
| 397   EventLogger* old_logger = rtc::AtomicOps::AcquireLoadPtr(&g_event_logger); | 404   EventLogger* old_logger = rtc::AtomicOps::AcquireLoadPtr(&g_event_logger); | 
| 398   RTC_DCHECK(old_logger); | 405   RTC_DCHECK(old_logger); | 
| 399   RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( | 406   RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( | 
| 400                 &g_event_logger, old_logger, | 407                 &g_event_logger, old_logger, | 
| 401                 static_cast<EventLogger*>(nullptr)) == old_logger); | 408                 static_cast<EventLogger*>(nullptr)) == old_logger); | 
| 402   delete old_logger; | 409   delete old_logger; | 
| 403   webrtc::SetupEventTracer(nullptr, nullptr); | 410   webrtc::SetupEventTracer(nullptr, nullptr); | 
| 404 } | 411 } | 
| 405 | 412 | 
| 406 }  // namespace tracing | 413 }  // namespace tracing | 
| 407 }  // namespace rtc | 414 }  // namespace rtc | 
| OLD | NEW | 
|---|