| 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 18 matching lines...) Expand all Loading... |
| 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/threading/worker_pool.h" | 33 #include "base/threading/worker_pool.h" |
| 34 #include "base/time/time.h" | 34 #include "base/time/time.h" |
| 35 #include "base/trace_event/trace_event.h" | 35 #include "base/trace_event/trace_event.h" |
| 36 #include "base/trace_event/trace_event_synthetic_delay.h" | 36 #include "base/trace_event/trace_event_synthetic_delay.h" |
| 37 | 37 |
| 38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 #include "base/trace_event/trace_event_etw_export_win.h" | |
| 40 #include "base/trace_event/trace_event_win.h" | 39 #include "base/trace_event/trace_event_win.h" |
| 41 #endif | 40 #endif |
| 42 | 41 |
| 43 class DeleteTraceLogForTesting { | 42 class DeleteTraceLogForTesting { |
| 44 public: | 43 public: |
| 45 static void Delete() { | 44 static void Delete() { |
| 46 Singleton<base::trace_event::TraceLog, | 45 Singleton<base::trace_event::TraceLog, |
| 47 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); | 46 LeakySingletonTraits<base::trace_event::TraceLog>>::OnExit(0); |
| 48 } | 47 } |
| 49 }; | 48 }; |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 const char* category_group = g_category_groups[category_index]; | 1285 const char* category_group = g_category_groups[category_index]; |
| 1287 if (mode_ == RECORDING_MODE && | 1286 if (mode_ == RECORDING_MODE && |
| 1288 category_filter_.IsCategoryGroupEnabled(category_group)) | 1287 category_filter_.IsCategoryGroupEnabled(category_group)) |
| 1289 enabled_flag |= ENABLED_FOR_RECORDING; | 1288 enabled_flag |= ENABLED_FOR_RECORDING; |
| 1290 else if (mode_ == MONITORING_MODE && | 1289 else if (mode_ == MONITORING_MODE && |
| 1291 category_filter_.IsCategoryGroupEnabled(category_group)) | 1290 category_filter_.IsCategoryGroupEnabled(category_group)) |
| 1292 enabled_flag |= ENABLED_FOR_MONITORING; | 1291 enabled_flag |= ENABLED_FOR_MONITORING; |
| 1293 if (event_callback_ && | 1292 if (event_callback_ && |
| 1294 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) | 1293 event_callback_category_filter_.IsCategoryGroupEnabled(category_group)) |
| 1295 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; | 1294 enabled_flag |= ENABLED_FOR_EVENT_CALLBACK; |
| 1296 #if defined(OS_WIN) | |
| 1297 if (base::trace_event::TraceEventETWExport::isETWExportEnabled()) | |
| 1298 enabled_flag |= ENABLED_FOR_ETW_EXPORT; | |
| 1299 #endif | |
| 1300 | |
| 1301 g_category_group_enabled[category_index] = enabled_flag; | 1295 g_category_group_enabled[category_index] = enabled_flag; |
| 1302 } | 1296 } |
| 1303 | 1297 |
| 1304 void TraceLog::UpdateCategoryGroupEnabledFlags() { | 1298 void TraceLog::UpdateCategoryGroupEnabledFlags() { |
| 1305 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); | 1299 size_t category_index = base::subtle::NoBarrier_Load(&g_category_index); |
| 1306 for (size_t i = 0; i < category_index; i++) | 1300 for (size_t i = 0; i < category_index; i++) |
| 1307 UpdateCategoryGroupEnabledFlag(i); | 1301 UpdateCategoryGroupEnabledFlag(i); |
| 1308 } | 1302 } |
| 1309 | 1303 |
| 1310 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { | 1304 void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() { |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 new_name) != existing_names.end(); | 1977 new_name) != existing_names.end(); |
| 1984 if (!found) { | 1978 if (!found) { |
| 1985 if (existing_names.size()) | 1979 if (existing_names.size()) |
| 1986 existing_name->second.push_back(','); | 1980 existing_name->second.push_back(','); |
| 1987 existing_name->second.append(new_name); | 1981 existing_name->second.append(new_name); |
| 1988 } | 1982 } |
| 1989 } | 1983 } |
| 1990 } | 1984 } |
| 1991 } | 1985 } |
| 1992 | 1986 |
| 1993 #if defined(OS_WIN) | |
| 1994 // This is done sooner rather than later, to avoid creating the event and | |
| 1995 // acquiring the lock, which is not needed for ETW as it's already threadsafe. | |
| 1996 if (*category_group_enabled & ENABLED_FOR_ETW_EXPORT) | |
| 1997 TraceEventETWExport::AddEvent(phase, category_group_enabled, name, id, | |
| 1998 num_args, arg_names, arg_types, arg_values, | |
| 1999 convertable_values); | |
| 2000 #endif // OS_WIN | |
| 2001 | |
| 2002 std::string console_message; | 1987 std::string console_message; |
| 2003 if (*category_group_enabled & | 1988 if (*category_group_enabled & |
| 2004 (ENABLED_FOR_RECORDING | ENABLED_FOR_MONITORING)) { | 1989 (ENABLED_FOR_RECORDING | ENABLED_FOR_MONITORING)) { |
| 2005 OptionalAutoLock lock(&lock_); | 1990 OptionalAutoLock lock(&lock_); |
| 2006 | 1991 |
| 2007 TraceEvent* trace_event = NULL; | 1992 TraceEvent* trace_event = NULL; |
| 2008 if (thread_local_event_buffer) { | 1993 if (thread_local_event_buffer) { |
| 2009 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); | 1994 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
| 2010 } else { | 1995 } else { |
| 2011 lock.EnsureAcquired(); | 1996 lock.EnsureAcquired(); |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2630 } | 2615 } |
| 2631 | 2616 |
| 2632 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2617 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 2633 if (*category_group_enabled_) { | 2618 if (*category_group_enabled_) { |
| 2634 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2619 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
| 2635 name_, event_handle_); | 2620 name_, event_handle_); |
| 2636 } | 2621 } |
| 2637 } | 2622 } |
| 2638 | 2623 |
| 2639 } // namespace trace_event_internal | 2624 } // namespace trace_event_internal |
| OLD | NEW |