| 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 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #ifdef _WIN32 | 27 #ifdef _WIN32 |
| 28 #pragma warning(disable:4355) | 28 #pragma warning(disable:4355) |
| 29 #endif // _WIN32 | 29 #endif // _WIN32 |
| 30 | 30 |
| 31 namespace webrtc { | 31 namespace webrtc { |
| 32 | 32 |
| 33 const int Trace::kBoilerplateLength = 71; | 33 const int Trace::kBoilerplateLength = 71; |
| 34 const int Trace::kTimestampPosition = 13; | 34 const int Trace::kTimestampPosition = 13; |
| 35 const int Trace::kTimestampLength = 12; | 35 const int Trace::kTimestampLength = 12; |
| 36 volatile int Trace::level_filter_ = kTraceDefault; | 36 rtc::AtomicInt Trace::level_filter_(kTraceDefault); |
| 37 | 37 |
| 38 // Construct On First Use idiom. Avoids "static initialization order fiasco". | 38 // Construct On First Use idiom. Avoids "static initialization order fiasco". |
| 39 TraceImpl* TraceImpl::StaticInstance(CountOperation count_operation, | 39 TraceImpl* TraceImpl::StaticInstance(CountOperation count_operation, |
| 40 const TraceLevel level) { | 40 const TraceLevel level) { |
| 41 // Sanities to avoid taking lock unless absolutely necessary (for | 41 // Sanities to avoid taking lock unless absolutely necessary (for |
| 42 // performance reasons). count_operation == kAddRefNoCreate implies that a | 42 // performance reasons). count_operation == kAddRefNoCreate implies that a |
| 43 // message will be written to file. | 43 // message will be written to file. |
| 44 if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) { | 44 if ((level != kTraceAll) && (count_operation == kAddRefNoCreate)) { |
| 45 if (!(level & level_filter())) { | 45 if (!(level & level_filter())) { |
| 46 return NULL; | 46 return NULL; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 if (trace) { | 540 if (trace) { |
| 541 int ret_val = trace->TraceFileImpl(file_name); | 541 int ret_val = trace->TraceFileImpl(file_name); |
| 542 ReturnTrace(); | 542 ReturnTrace(); |
| 543 return ret_val; | 543 return ret_val; |
| 544 } | 544 } |
| 545 return -1; | 545 return -1; |
| 546 } | 546 } |
| 547 | 547 |
| 548 // static | 548 // static |
| 549 void Trace::set_level_filter(int filter) { | 549 void Trace::set_level_filter(int filter) { |
| 550 rtc::AtomicOps::ReleaseStore(&level_filter_, filter); | 550 rtc::AtomicInt::ReleaseStore(&level_filter_, filter); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // static | 553 // static |
| 554 int Trace::level_filter() { | 554 int Trace::level_filter() { |
| 555 return rtc::AtomicOps::AcquireLoad(&level_filter_); | 555 return rtc::AtomicInt::AcquireLoad(&level_filter_); |
| 556 } | 556 } |
| 557 | 557 |
| 558 // static | 558 // static |
| 559 int32_t Trace::SetTraceFile(const char* file_name, | 559 int32_t Trace::SetTraceFile(const char* file_name, |
| 560 const bool add_file_counter) { | 560 const bool add_file_counter) { |
| 561 TraceImpl* trace = TraceImpl::GetTrace(); | 561 TraceImpl* trace = TraceImpl::GetTrace(); |
| 562 if (trace) { | 562 if (trace) { |
| 563 int ret_val = trace->SetTraceFileImpl(file_name, add_file_counter); | 563 int ret_val = trace->SetTraceFileImpl(file_name, add_file_counter); |
| 564 ReturnTrace(); | 564 ReturnTrace(); |
| 565 return ret_val; | 565 return ret_val; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 595 va_end(args); | 595 va_end(args); |
| 596 buff = temp_buff; | 596 buff = temp_buff; |
| 597 } | 597 } |
| 598 trace->AddImpl(level, module, id, buff); | 598 trace->AddImpl(level, module, id, buff); |
| 599 } | 599 } |
| 600 ReturnTrace(); | 600 ReturnTrace(); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 } // namespace webrtc | 604 } // namespace webrtc |
| OLD | NEW |