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

Side by Side Diff: webrtc/system_wrappers/source/trace_impl.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 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 10
(...skipping 26 matching lines...) Expand all
37 volatile int Trace::level_filter_ = kTraceDefault; 37 volatile int Trace::level_filter_ = kTraceDefault;
38 38
39 // Construct On First Use idiom. Avoids "static initialization order fiasco". 39 // Construct On First Use idiom. Avoids "static initialization order fiasco".
40 TraceImpl* TraceImpl::StaticInstance(CountOperation count_operation, 40 TraceImpl* TraceImpl::StaticInstance(CountOperation count_operation,
41 const TraceLevel level) { 41 const TraceLevel level) {
42 // Sanities to avoid taking lock unless absolutely necessary (for 42 // Sanities to avoid taking lock unless absolutely necessary (for
43 // performance reasons). count_operation == kAddRefNoCreate implies that a 43 // performance reasons). count_operation == kAddRefNoCreate implies that a
44 // message will be written to file. 44 // message will be written to file.
45 if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) { 45 if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) {
46 if (!(level & level_filter())) { 46 if (!(level & level_filter())) {
47 return NULL; 47 return nullptr;
48 } 48 }
49 } 49 }
50 TraceImpl* impl = 50 TraceImpl* impl =
51 GetStaticInstance<TraceImpl>(count_operation); 51 GetStaticInstance<TraceImpl>(count_operation);
52 return impl; 52 return impl;
53 } 53 }
54 54
55 TraceImpl* TraceImpl::GetTrace(const TraceLevel level) { 55 TraceImpl* TraceImpl::GetTrace(const TraceLevel level) {
56 return StaticInstance(kAddRefNoCreate, level); 56 return StaticInstance(kAddRefNoCreate, level);
57 } 57 }
58 58
59 TraceImpl* TraceImpl::CreateInstance() { 59 TraceImpl* TraceImpl::CreateInstance() {
60 #if defined(_WIN32) 60 #if defined(_WIN32)
61 return new TraceWindows(); 61 return new TraceWindows();
62 #else 62 #else
63 return new TracePosix(); 63 return new TracePosix();
64 #endif 64 #endif
65 } 65 }
66 66
67 TraceImpl::TraceImpl() 67 TraceImpl::TraceImpl()
68 : callback_(NULL), 68 : callback_(nullptr),
69 row_count_text_(0), 69 row_count_text_(0),
70 file_count_text_(0), 70 file_count_text_(0),
71 trace_file_(FileWrapper::Create()) { 71 trace_file_(FileWrapper::Create()) {}
72 }
73 72
74 TraceImpl::~TraceImpl() { 73 TraceImpl::~TraceImpl() {
75 trace_file_->CloseFile(); 74 trace_file_->CloseFile();
76 } 75 }
77 76
78 int32_t TraceImpl::AddThreadId(char* trace_message) const { 77 int32_t TraceImpl::AddThreadId(char* trace_message) const {
79 uint32_t thread_id = rtc::CurrentThreadId(); 78 uint32_t thread_id = rtc::CurrentThreadId();
80 // Messages is 12 characters. 79 // Messages is 12 characters.
81 return sprintf(trace_message, "%10u; ", thread_id); 80 return sprintf(trace_message, "%10u; ", thread_id);
82 } 81 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 318 }
320 319
321 int32_t TraceImpl::AddMessage( 320 int32_t TraceImpl::AddMessage(
322 char* trace_message, 321 char* trace_message,
323 const char msg[WEBRTC_TRACE_MAX_MESSAGE_SIZE], 322 const char msg[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
324 const uint16_t written_so_far) const { 323 const uint16_t written_so_far) const {
325 int length = 0; 324 int length = 0;
326 if (written_so_far >= WEBRTC_TRACE_MAX_MESSAGE_SIZE) { 325 if (written_so_far >= WEBRTC_TRACE_MAX_MESSAGE_SIZE) {
327 return -1; 326 return -1;
328 } 327 }
329 // - 2 to leave room for newline and NULL termination. 328 // - 2 to leave room for newline and null termination.
330 #ifdef _WIN32 329 #ifdef _WIN32
331 length = _snprintf(trace_message, 330 length = _snprintf(trace_message,
332 WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2, 331 WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2,
333 "%s", msg); 332 "%s", msg);
334 if (length < 0) { 333 if (length < 0) {
335 length = WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2; 334 length = WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2;
336 trace_message[length] = 0; 335 trace_message[length] = 0;
337 } 336 }
338 #else 337 #else
339 length = snprintf(trace_message, 338 length = snprintf(trace_message,
340 WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2, 339 WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2,
341 "%s", msg); 340 "%s", msg);
342 if (length < 0 || 341 if (length < 0 ||
343 length > WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2) { 342 length > WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2) {
344 length = WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2; 343 length = WEBRTC_TRACE_MAX_MESSAGE_SIZE - written_so_far - 2;
345 trace_message[length] = 0; 344 trace_message[length] = 0;
346 } 345 }
347 #endif 346 #endif
348 // Length with NULL termination. 347 // Length with null termination.
349 return length + 1; 348 return length + 1;
350 } 349 }
351 350
352 void TraceImpl::AddMessageToList( 351 void TraceImpl::AddMessageToList(
353 const char trace_message[WEBRTC_TRACE_MAX_MESSAGE_SIZE], 352 const char trace_message[WEBRTC_TRACE_MAX_MESSAGE_SIZE],
354 const uint16_t length, 353 const uint16_t length,
355 const TraceLevel level) { 354 const TraceLevel level) {
356 rtc::CritScope lock(&crit_); 355 rtc::CritScope lock(&crit_);
357 if (callback_) 356 if (callback_)
358 callback_->Print(level, trace_message, length); 357 callback_->Print(level, trace_message, length);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 va_end(args); 573 va_end(args);
575 buff = temp_buff; 574 buff = temp_buff;
576 } 575 }
577 trace->AddImpl(level, module, id, buff); 576 trace->AddImpl(level, module, id, buff);
578 } 577 }
579 ReturnTrace(); 578 ReturnTrace();
580 } 579 }
581 } 580 }
582 581
583 } // namespace webrtc 582 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698