| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_log.h" | 5 #include "base/trace_event/trace_log.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/debug/leak_annotations.h" | 15 #include "base/debug/leak_annotations.h" |
| 16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/location.h" | 17 #include "base/location.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
| 20 #include "base/memory/ref_counted_memory.h" | 20 #include "base/memory/ref_counted_memory.h" |
| 21 #include "base/memory/singleton.h" | 21 #include "base/memory/singleton.h" |
| 22 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
| 23 #include "base/process/process_metrics.h" | 23 #include "base/process/process_metrics.h" |
| 24 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
| 25 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
| 26 #include "base/strings/string_tokenizer.h" | 26 #include "base/strings/string_tokenizer.h" |
| 27 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 28 #include "base/sys_info.h" | 28 #include "base/sys_info.h" |
| 29 #include "base/task_scheduler/post_task.h" |
| 29 #include "base/threading/platform_thread.h" | 30 #include "base/threading/platform_thread.h" |
| 30 #include "base/threading/thread_id_name_manager.h" | 31 #include "base/threading/thread_id_name_manager.h" |
| 31 #include "base/threading/thread_task_runner_handle.h" | 32 #include "base/threading/thread_task_runner_handle.h" |
| 32 #include "base/threading/worker_pool.h" | |
| 33 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 34 #include "base/trace_event/category_registry.h" | 34 #include "base/trace_event/category_registry.h" |
| 35 #include "base/trace_event/event_name_filter.h" | 35 #include "base/trace_event/event_name_filter.h" |
| 36 #include "base/trace_event/heap_profiler.h" | 36 #include "base/trace_event/heap_profiler.h" |
| 37 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" | 37 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
| 38 #include "base/trace_event/heap_profiler_event_filter.h" | 38 #include "base/trace_event/heap_profiler_event_filter.h" |
| 39 #include "base/trace_event/memory_dump_manager.h" | 39 #include "base/trace_event/memory_dump_manager.h" |
| 40 #include "base/trace_event/memory_dump_provider.h" | 40 #include "base/trace_event/memory_dump_provider.h" |
| 41 #include "base/trace_event/process_memory_dump.h" | 41 #include "base/trace_event/process_memory_dump.h" |
| 42 #include "base/trace_event/trace_buffer.h" | 42 #include "base/trace_event/trace_buffer.h" |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 } | 963 } |
| 964 | 964 |
| 965 if (discard_events) { | 965 if (discard_events) { |
| 966 if (!flush_output_callback.is_null()) { | 966 if (!flush_output_callback.is_null()) { |
| 967 scoped_refptr<RefCountedString> empty_result = new RefCountedString; | 967 scoped_refptr<RefCountedString> empty_result = new RefCountedString; |
| 968 flush_output_callback.Run(empty_result, false); | 968 flush_output_callback.Run(empty_result, false); |
| 969 } | 969 } |
| 970 return; | 970 return; |
| 971 } | 971 } |
| 972 | 972 |
| 973 if (use_worker_thread_ && | 973 if (use_worker_thread_) { |
| 974 WorkerPool::PostTask( | 974 base::PostTaskWithTraits( |
| 975 FROM_HERE, Bind(&TraceLog::ConvertTraceEventsToTraceFormat, | 975 FROM_HERE, base::TaskTraits() |
| 976 Passed(&previous_logged_events), | 976 .MayBlock() |
| 977 flush_output_callback, argument_filter_predicate), | 977 .WithPriority(base::TaskPriority::BACKGROUND) |
| 978 true)) { | 978 .WithShutdownBehavior( |
| 979 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), |
| 980 Bind(&TraceLog::ConvertTraceEventsToTraceFormat, |
| 981 Passed(&previous_logged_events), flush_output_callback, |
| 982 argument_filter_predicate)); |
| 979 return; | 983 return; |
| 980 } | 984 } |
| 981 | 985 |
| 982 ConvertTraceEventsToTraceFormat(std::move(previous_logged_events), | 986 ConvertTraceEventsToTraceFormat(std::move(previous_logged_events), |
| 983 flush_output_callback, | 987 flush_output_callback, |
| 984 argument_filter_predicate); | 988 argument_filter_predicate); |
| 985 } | 989 } |
| 986 | 990 |
| 987 // Run in each thread holding a local event buffer. | 991 // Run in each thread holding a local event buffer. |
| 988 void TraceLog::FlushCurrentThread(int generation, bool discard_events) { | 992 void TraceLog::FlushCurrentThread(int generation, bool discard_events) { |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 } | 1726 } |
| 1723 | 1727 |
| 1724 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1728 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 1725 if (*category_group_enabled_) { | 1729 if (*category_group_enabled_) { |
| 1726 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1730 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
| 1727 event_handle_); | 1731 event_handle_); |
| 1728 } | 1732 } |
| 1729 } | 1733 } |
| 1730 | 1734 |
| 1731 } // namespace trace_event_internal | 1735 } // namespace trace_event_internal |
| OLD | NEW |