Chromium Code Reviews| 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/base/event_tracer.h" | 10 #include "webrtc/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) { |
|
tkchin_webrtc
2017/06/27 22:56:40
I'm not sure how thread-safe this check is. Ask ow
jtt_webrtc
2017/06/28 17:44:25
The only time g_event_logger is changed is when Se
| |
| 378 g_event_logger->Start(file, false); | |
| 379 } | |
| 378 } | 380 } |
| 379 | 381 |
| 380 bool StartInternalCapture(const char* filename) { | 382 bool StartInternalCapture(const char* filename) { |
| 381 FILE* file = fopen(filename, "w"); | 383 if (g_event_logger) { |
| 382 if (!file) { | 384 FILE* file = fopen(filename, "w"); |
| 383 LOG(LS_ERROR) << "Failed to open trace file '" << filename | 385 if (!file) { |
| 384 << "' for writing."; | 386 LOG(LS_ERROR) << "Failed to open trace file '" << filename |
| 387 << "' for writing."; | |
| 388 return false; | |
| 389 } | |
| 390 g_event_logger->Start(file, true); | |
| 391 return true; | |
| 392 } else { | |
| 385 return false; | 393 return false; |
| 386 } | 394 } |
| 387 g_event_logger->Start(file, true); | |
| 388 return true; | |
| 389 } | 395 } |
| 390 | 396 |
| 391 void StopInternalCapture() { | 397 void StopInternalCapture() { |
| 392 g_event_logger->Stop(); | 398 if (g_event_logger) { |
| 399 g_event_logger->Stop(); | |
| 400 } | |
| 393 } | 401 } |
| 394 | 402 |
| 395 void ShutdownInternalTracer() { | 403 void ShutdownInternalTracer() { |
| 396 StopInternalCapture(); | 404 StopInternalCapture(); |
| 397 EventLogger* old_logger = rtc::AtomicOps::AcquireLoadPtr(&g_event_logger); | 405 EventLogger* old_logger = rtc::AtomicOps::AcquireLoadPtr(&g_event_logger); |
| 398 RTC_DCHECK(old_logger); | 406 RTC_DCHECK(old_logger); |
| 399 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( | 407 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( |
| 400 &g_event_logger, old_logger, | 408 &g_event_logger, old_logger, |
| 401 static_cast<EventLogger*>(nullptr)) == old_logger); | 409 static_cast<EventLogger*>(nullptr)) == old_logger); |
| 402 delete old_logger; | 410 delete old_logger; |
| 403 webrtc::SetupEventTracer(nullptr, nullptr); | 411 webrtc::SetupEventTracer(nullptr, nullptr); |
| 404 } | 412 } |
| 405 | 413 |
| 406 } // namespace tracing | 414 } // namespace tracing |
| 407 } // namespace rtc | 415 } // namespace rtc |
| OLD | NEW |