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

Side by Side Diff: webrtc/base/event_tracer.cc

Issue 2961663002: Trace loggging: Check for g_event_logger is not null before calling it. (Closed)
Patch Set: Formatting. Created 3 years, 5 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
OLDNEW
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
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) {
381 FILE* file = fopen(filename, "w"); 383 if (g_event_logger) {
tommi 2017/07/07 08:53:50 can you turn this around and do: if (!g_event_log
jtt_webrtc 2017/07/07 16:22:40 Done.
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
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/BUILD.gn » ('j') | webrtc/sdk/objc/Framework/UnitTests/RTCPeerConnectionTest.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698