| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Trace events are for tracking application performance. | 5 // Trace events are for tracking application performance. |
| 6 // | 6 // |
| 7 // Events are issued against categories. Whereas LOG's | 7 // Events are issued against categories. Whereas LOG's |
| 8 // categories are statically defined, TRACE categories are created | 8 // categories are statically defined, TRACE categories are created |
| 9 // implicitly with a string. For example: | 9 // implicitly with a string. For example: |
| 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") | 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // statically allocated and safe at all times, even after exit. Fetching a | 47 // statically allocated and safe at all times, even after exit. Fetching a |
| 48 // category is protected by the TraceLog::lock_. Multiple threads initializing | 48 // category is protected by the TraceLog::lock_. Multiple threads initializing |
| 49 // the static variable is safe, as they will be serialized by the lock and | 49 // the static variable is safe, as they will be serialized by the lock and |
| 50 // multiple calls will return the same pointer to the category. | 50 // multiple calls will return the same pointer to the category. |
| 51 // | 51 // |
| 52 // Then the category.enabled flag is checked. This is a volatile bool, and | 52 // Then the category.enabled flag is checked. This is a volatile bool, and |
| 53 // not intended to be multithread safe. It optimizes access to AddTraceEvent | 53 // not intended to be multithread safe. It optimizes access to AddTraceEvent |
| 54 // which is threadsafe internally via TraceLog::lock_. The enabled flag may | 54 // which is threadsafe internally via TraceLog::lock_. The enabled flag may |
| 55 // cause some threads to incorrectly call or skip calling AddTraceEvent near | 55 // cause some threads to incorrectly call or skip calling AddTraceEvent near |
| 56 // the time of the system being enabled or disabled. This is acceptable as | 56 // the time of the system being enabled or disabled. This is acceptable as |
| 57 // we tollerate some data loss while the system is being enabled/disabled and | 57 // we tolerate some data loss while the system is being enabled/disabled and |
| 58 // because AddTraceEvent is threadsafe internally and checks the enabled state | 58 // because AddTraceEvent is threadsafe internally and checks the enabled state |
| 59 // again under lock. | 59 // again under lock. |
| 60 // | 60 // |
| 61 // Without the use of these static category pointers and enabled flags all | 61 // Without the use of these static category pointers and enabled flags all |
| 62 // trace points would carry a significant performance cost of aquiring a lock | 62 // trace points would carry a significant performance cost of aquiring a lock |
| 63 // and resolving the category. | 63 // and resolving the category. |
| 64 // | 64 // |
| 65 // ANNOTATE_BENIGN_RACE is used to suppress the warning on the static category | 65 // ANNOTATE_BENIGN_RACE is used to suppress the warning on the static category |
| 66 // pointers. | 66 // pointers. |
| 67 | 67 |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 const TraceCategory* category_; | 484 const TraceCategory* category_; |
| 485 const char* name_; | 485 const char* name_; |
| 486 }; | 486 }; |
| 487 | 487 |
| 488 } // namespace internal | 488 } // namespace internal |
| 489 | 489 |
| 490 } // namespace debug | 490 } // namespace debug |
| 491 } // namespace base | 491 } // namespace base |
| 492 | 492 |
| 493 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 493 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
| OLD | NEW |