| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This header file defines the set of trace_event macros without specifying | 5 // This header file defines the set of trace_event macros without specifying |
| 6 // how the events actually get collected and stored. If you need to expose trace | 6 // how the events actually get collected and stored. If you need to expose trace |
| 7 // events to some other universe, you can copy-and-paste this file as well as | 7 // events to some other universe, you can copy-and-paste this file as well as |
| 8 // trace_event.h, modifying the macros contained there as necessary for the | 8 // trace_event.h, modifying the macros contained there as necessary for the |
| 9 // target platform. The end result is that multiple libraries can funnel events | 9 // target platform. The end result is that multiple libraries can funnel events |
| 10 // through to a shared trace event collector. | 10 // through to a shared trace event collector. |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 781 |
| 782 // Defines atomic operations used internally by the tracing system. | 782 // Defines atomic operations used internally by the tracing system. |
| 783 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord | 783 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord |
| 784 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) | 784 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) |
| 785 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ | 785 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ |
| 786 base::subtle::NoBarrier_Store(&(var), (value)) | 786 base::subtle::NoBarrier_Store(&(var), (value)) |
| 787 | 787 |
| 788 // Defines visibility for classes in trace_event.h | 788 // Defines visibility for classes in trace_event.h |
| 789 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT | 789 #define TRACE_EVENT_API_CLASS_EXPORT BASE_EXPORT |
| 790 | 790 |
| 791 // Not supported in split-dll build. http://crbug.com/256965 | |
| 792 #if !defined(CHROME_SPLIT_DLL) | |
| 793 // The thread buckets for the sampling profiler. | 791 // The thread buckets for the sampling profiler. |
| 794 TRACE_EVENT_API_CLASS_EXPORT extern \ | 792 TRACE_EVENT_API_CLASS_EXPORT extern \ |
| 795 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; | 793 TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3]; |
| 796 | 794 |
| 797 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \ | 795 #define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \ |
| 798 g_trace_state[thread_bucket] | 796 g_trace_state[thread_bucket] |
| 799 | 797 |
| 800 #endif | |
| 801 | |
| 802 //////////////////////////////////////////////////////////////////////////////// | 798 //////////////////////////////////////////////////////////////////////////////// |
| 803 | 799 |
| 804 // Implementation detail: trace event macros create temporary variables | 800 // Implementation detail: trace event macros create temporary variables |
| 805 // to keep instrumentation overhead low. These macros give each temporary | 801 // to keep instrumentation overhead low. These macros give each temporary |
| 806 // variable a unique name based on the line number to prevent name collissions. | 802 // variable a unique name based on the line number to prevent name collissions. |
| 807 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ | 803 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ |
| 808 trace_event_unique_##a##b | 804 trace_event_unique_##a##b |
| 809 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ | 805 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ |
| 810 INTERNAL_TRACE_EVENT_UID3(a,b) | 806 INTERNAL_TRACE_EVENT_UID3(a,b) |
| 811 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ | 807 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 TraceEventSamplingStateScope(const char* category_and_name) { | 1478 TraceEventSamplingStateScope(const char* category_and_name) { |
| 1483 previous_state_ = TraceEventSamplingStateScope<BucketNumber>::Current(); | 1479 previous_state_ = TraceEventSamplingStateScope<BucketNumber>::Current(); |
| 1484 TraceEventSamplingStateScope<BucketNumber>::Set(category_and_name); | 1480 TraceEventSamplingStateScope<BucketNumber>::Set(category_and_name); |
| 1485 } | 1481 } |
| 1486 | 1482 |
| 1487 ~TraceEventSamplingStateScope() { | 1483 ~TraceEventSamplingStateScope() { |
| 1488 TraceEventSamplingStateScope<BucketNumber>::Set(previous_state_); | 1484 TraceEventSamplingStateScope<BucketNumber>::Set(previous_state_); |
| 1489 } | 1485 } |
| 1490 | 1486 |
| 1491 static inline const char* Current() { | 1487 static inline const char* Current() { |
| 1492 // Not supported in split-dll build. http://crbug.com/256965 | |
| 1493 #if !defined(CHROME_SPLIT_DLL) | |
| 1494 return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD( | 1488 return reinterpret_cast<const char*>(TRACE_EVENT_API_ATOMIC_LOAD( |
| 1495 g_trace_state[BucketNumber])); | 1489 g_trace_state[BucketNumber])); |
| 1496 #else | |
| 1497 return NULL; | |
| 1498 #endif | |
| 1499 } | 1490 } |
| 1500 | 1491 |
| 1501 static inline void Set(const char* category_and_name) { | 1492 static inline void Set(const char* category_and_name) { |
| 1502 // Not supported in split-dll build. http://crbug.com/256965 | |
| 1503 #if !defined(CHROME_SPLIT_DLL) | |
| 1504 TRACE_EVENT_API_ATOMIC_STORE( | 1493 TRACE_EVENT_API_ATOMIC_STORE( |
| 1505 g_trace_state[BucketNumber], | 1494 g_trace_state[BucketNumber], |
| 1506 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( | 1495 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( |
| 1507 const_cast<char*>(category_and_name))); | 1496 const_cast<char*>(category_and_name))); |
| 1508 #endif | |
| 1509 } | 1497 } |
| 1510 | 1498 |
| 1511 private: | 1499 private: |
| 1512 const char* previous_state_; | 1500 const char* previous_state_; |
| 1513 }; | 1501 }; |
| 1514 | 1502 |
| 1515 } // namespace trace_event_internal | 1503 } // namespace trace_event_internal |
| 1516 | 1504 |
| 1517 namespace base { | 1505 namespace base { |
| 1518 namespace debug { | 1506 namespace debug { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1540 const char* name_; | 1528 const char* name_; |
| 1541 IDType id_; | 1529 IDType id_; |
| 1542 | 1530 |
| 1543 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1531 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1544 }; | 1532 }; |
| 1545 | 1533 |
| 1546 } // namespace debug | 1534 } // namespace debug |
| 1547 } // namespace base | 1535 } // namespace base |
| 1548 | 1536 |
| 1549 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1537 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
| OLD | NEW |