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

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

Issue 2179903004: Fix a memory leak where EventLogger is created two times in the event tracer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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) 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 g_event_logger->AddTraceEvent(name, category_enabled, phase, 232 g_event_logger->AddTraceEvent(name, category_enabled, phase,
233 rtc::TimeMicros(), 1, rtc::CurrentThreadId()); 233 rtc::TimeMicros(), 1, rtc::CurrentThreadId());
234 } 234 }
235 235
236 } // namespace 236 } // namespace
237 237
238 void SetupInternalTracer() { 238 void SetupInternalTracer() {
239 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( 239 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr(
240 &g_event_logger, static_cast<EventLogger*>(nullptr), 240 &g_event_logger, static_cast<EventLogger*>(nullptr),
241 new EventLogger()) == nullptr); 241 new EventLogger()) == nullptr);
242 g_event_logger = new EventLogger();
243 webrtc::SetupEventTracer(InternalGetCategoryEnabled, InternalAddTraceEvent); 242 webrtc::SetupEventTracer(InternalGetCategoryEnabled, InternalAddTraceEvent);
244 } 243 }
245 244
246 void StartInternalCaptureToFile(FILE* file) { 245 void StartInternalCaptureToFile(FILE* file) {
247 g_event_logger->Start(file, false); 246 g_event_logger->Start(file, false);
248 } 247 }
249 248
250 bool StartInternalCapture(const char* filename) { 249 bool StartInternalCapture(const char* filename) {
251 FILE* file = fopen(filename, "w"); 250 FILE* file = fopen(filename, "w");
252 if (!file) { 251 if (!file) {
(...skipping 15 matching lines...) Expand all
268 RTC_DCHECK(old_logger); 267 RTC_DCHECK(old_logger);
269 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr( 268 RTC_CHECK(rtc::AtomicOps::CompareAndSwapPtr(
270 &g_event_logger, old_logger, 269 &g_event_logger, old_logger,
271 static_cast<EventLogger*>(nullptr)) == old_logger); 270 static_cast<EventLogger*>(nullptr)) == old_logger);
272 delete old_logger; 271 delete old_logger;
273 webrtc::SetupEventTracer(nullptr, nullptr); 272 webrtc::SetupEventTracer(nullptr, nullptr);
274 } 273 }
275 274
276 } // namespace tracing 275 } // namespace tracing
277 } // namespace rtc 276 } // namespace rtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698