| 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 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifdef _WIN32 | 28 #ifdef _WIN32 |
| 29 #pragma warning(disable:4355) | 29 #pragma warning(disable:4355) |
| 30 #endif // _WIN32 | 30 #endif // _WIN32 |
| 31 | 31 |
| 32 namespace webrtc { | 32 namespace webrtc { |
| 33 | 33 |
| 34 const int Trace::kBoilerplateLength = 71; | 34 const int Trace::kBoilerplateLength = 71; |
| 35 const int Trace::kTimestampPosition = 13; | 35 const int Trace::kTimestampPosition = 13; |
| 36 const int Trace::kTimestampLength = 12; | 36 const int Trace::kTimestampLength = 12; |
| 37 rtc::AtomicInt 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 NULL; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 if (trace) { | 541 if (trace) { |
| 542 int ret_val = trace->TraceFileImpl(file_name); | 542 int ret_val = trace->TraceFileImpl(file_name); |
| 543 ReturnTrace(); | 543 ReturnTrace(); |
| 544 return ret_val; | 544 return ret_val; |
| 545 } | 545 } |
| 546 return -1; | 546 return -1; |
| 547 } | 547 } |
| 548 | 548 |
| 549 // static | 549 // static |
| 550 void Trace::set_level_filter(int filter) { | 550 void Trace::set_level_filter(int filter) { |
| 551 rtc::AtomicInt::ReleaseStore(&level_filter_, filter); | 551 rtc::AtomicOps::ReleaseStore(&level_filter_, filter); |
| 552 } | 552 } |
| 553 | 553 |
| 554 // static | 554 // static |
| 555 int Trace::level_filter() { | 555 int Trace::level_filter() { |
| 556 return rtc::AtomicInt::AcquireLoad(&level_filter_); | 556 return rtc::AtomicOps::AcquireLoad(&level_filter_); |
| 557 } | 557 } |
| 558 | 558 |
| 559 // static | 559 // static |
| 560 int32_t Trace::SetTraceFile(const char* file_name, | 560 int32_t Trace::SetTraceFile(const char* file_name, |
| 561 const bool add_file_counter) { | 561 const bool add_file_counter) { |
| 562 TraceImpl* trace = TraceImpl::GetTrace(); | 562 TraceImpl* trace = TraceImpl::GetTrace(); |
| 563 if (trace) { | 563 if (trace) { |
| 564 int ret_val = trace->SetTraceFileImpl(file_name, add_file_counter); | 564 int ret_val = trace->SetTraceFileImpl(file_name, add_file_counter); |
| 565 ReturnTrace(); | 565 ReturnTrace(); |
| 566 return ret_val; | 566 return ret_val; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 596 va_end(args); | 596 va_end(args); |
| 597 buff = temp_buff; | 597 buff = temp_buff; |
| 598 } | 598 } |
| 599 trace->AddImpl(level, module, id, buff); | 599 trace->AddImpl(level, module, id, buff); |
| 600 } | 600 } |
| 601 ReturnTrace(); | 601 ReturnTrace(); |
| 602 } | 602 } |
| 603 } | 603 } |
| 604 | 604 |
| 605 } // namespace webrtc | 605 } // namespace webrtc |
| OLD | NEW |