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 #include "base/trace_event/trace_event_impl.h" | 5 #include "base/trace_event/trace_event_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "base/synchronization/waitable_event.h" | 28 #include "base/synchronization/waitable_event.h" |
29 #include "base/sys_info.h" | 29 #include "base/sys_info.h" |
30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
31 #include "base/threading/platform_thread.h" | 31 #include "base/threading/platform_thread.h" |
32 #include "base/threading/thread_id_name_manager.h" | 32 #include "base/threading/thread_id_name_manager.h" |
33 #include "base/time/time.h" | 33 #include "base/time/time.h" |
34 #include "base/trace_event/trace_event.h" | 34 #include "base/trace_event/trace_event.h" |
35 #include "base/trace_event/trace_event_synthetic_delay.h" | 35 #include "base/trace_event/trace_event_synthetic_delay.h" |
36 | 36 |
37 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 38 #include "base/trace_event/trace_event_etw_export_win.h" |
38 #include "base/trace_event/trace_event_win.h" | 39 #include "base/trace_event/trace_event_win.h" |
39 #endif | 40 #endif |
40 | 41 |
41 class DeleteTraceLogForTesting { | 42 class DeleteTraceLogForTesting { |
42 public: | 43 public: |
43 static void Delete() { | 44 static void Delete() { |
44 Singleton<base::trace_event::TraceLog, | 45 Singleton<base::trace_event::TraceLog, |
45 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); | 46 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); |
46 } | 47 } |
47 }; | 48 }; |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 const char* category_group = g_category_groups[category_index]; | 1284 const char* category_group = g_category_groups[category_index]; |
1284 if (mode_ == RECORDING_MODE && | 1285 if (mode_ == RECORDING_MODE && |
1285 category_filter_.IsCategoryGroupEnabled(category_group)) | 1286 category_filter_.IsCategoryGroupEnabled(category_group)) |
1286 enabled_flag |= ENABLED_FOR_RECORDING; | 1287 enabled_flag |= ENABLED_FOR_RECORDING; |
1287 else if (mode_ == MONITORING_MODE && | 1288 else if (mode_ == MONITORING_MODE && |
1288 category_filter_.IsCategoryGroupEnabled(category_group)) | 1289 category_filter_.IsCategoryGroupEnabled(category_group)) |
1289 enabled_flag |= ENABLED_FOR_MONITORING; | 1290 enabled_flag |= ENABLED_FOR_MONITORING; |
1290 if (event_callback_ && | 1291 if (event_callback_ && |
1291 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) | 1292 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) |
1292 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 1293 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
| 1294 #if defined(OS_WIN) |
| 1295 if (base::trace_event::TraceEventETWExport::isETWExportEnabled()) |
| 1296 enabled_flag |= ENABLED_FOR_ETW_EXPORT; |
| 1297 #endif |
| 1298 |
1293 g_category_group_enabled[category_index] = enabled_flag; | 1299 g_category_group_enabled[category_index] = enabled_flag; |
1294 } | 1300 } |
1295 | 1301 |
1296 void TraceLog::UpdateCategoryGroupEnabledFlags() { | 1302 void TraceLog::UpdateCategoryGroupEnabledFlags() { |
1297 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1303 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
1298 for (size_t i = 0; i < category_index; i++) | 1304 for (size_t i = 0; i < category_index; i++) |
1299 UpdateCategoryGroupEnabledFlag(i); | 1305 UpdateCategoryGroupEnabledFlag(i); |
1300 } | 1306 } |
1301 | 1307 |
1302 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { | 1308 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1964 new_name) != existing_names.end(); | 1970 new_name) != existing_names.end(); |
1965 if (!found) { | 1971 if (!found) { |
1966 if (existing_names.size()) | 1972 if (existing_names.size()) |
1967 existing_name->second.push_back(','); | 1973 existing_name->second.push_back(','); |
1968 existing_name->second.append(new_name); | 1974 existing_name->second.append(new_name); |
1969 } | 1975 } |
1970 } | 1976 } |
1971 } | 1977 } |
1972 } | 1978 } |
1973 | 1979 |
| 1980 #if defined(OS_WIN) |
| 1981 // This is done sooner rather than later, to avoid creating the event and |
| 1982 // acquiring the lock, which is not needed for ETW as it's already threadsafe. |
| 1983 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) |
| 1984 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, |
| 1985 num_args, arg_names, arg_types, arg_values, |
| 1986 convertable_values); |
| 1987 #endif // OS_WIN |
| 1988 |
1974 std::string console_message; | 1989 std::string console_message; |
1975 if (*category_group_enabled & | 1990 if (*category_group_enabled & |
1976 (ENABLED_FOR_RECORDING | ENABLED_FOR_MONITORING)) { | 1991 (ENABLED_FOR_RECORDING | ENABLED_FOR_MONITORING)) { |
1977 OptionalAutoLock lock(&lock_); | 1992 OptionalAutoLock lock(&lock_); |
1978 | 1993 |
1979 TraceEvent* trace_event = NULL; | 1994 TraceEvent* trace_event = NULL; |
1980 if (thread_local_event_buffer) { | 1995 if (thread_local_event_buffer) { |
1981 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); | 1996 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
1982 } else { | 1997 } else { |
1983 lock.EnsureAcquired(); | 1998 lock.EnsureAcquired(); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 } | 2617 } |
2603 | 2618 |
2604 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2619 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
2605 if (*category_group_enabled_) { | 2620 if (*category_group_enabled_) { |
2606 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2621 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
2607 name_, event_handle_); | 2622 name_, event_handle_); |
2608 } | 2623 } |
2609 } | 2624 } |
2610 | 2625 |
2611 } // namespace trace_event_internal | 2626 } // namespace trace_event_internal |
OLD | NEW |