Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: base/trace_event/memory_dump_manager.cc

Issue 2323483005: [tracing] Add filtering mode in TraceLog (Closed)
Patch Set: Fixes. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/allocator/features.h" 10 #include "base/allocator/features.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Enable the core dump providers. 194 // Enable the core dump providers.
195 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) 195 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED)
196 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr); 196 RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr);
197 #endif 197 #endif
198 198
199 #if defined(OS_ANDROID) 199 #if defined(OS_ANDROID)
200 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap", 200 RegisterDumpProvider(JavaHeapDumpProvider::GetInstance(), "JavaHeap",
201 nullptr); 201 nullptr);
202 #endif 202 #endif
203 203
204 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
205
206 // TODO(ssid): This should be done in EnableHeapProfiling so that we capture
207 // more allocations (crbug.com/625170).
208 if (heap_profiling_enabled_ &&
209 !TraceLog::GetInstance()->HaveActiveFilters()) {
Primiano Tucci (use gerrit) 2016/09/23 18:34:31 can you expand what is the sense of the HaveActive
ssid 2016/09/26 18:39:53 So, filters are a list and adding more objects to
210 TraceConfig::EventFilterConfig heap_profiler_filter_config(
211 TraceLog::TraceEventFilter::kHeapProfilerPredicate);
212 heap_profiler_filter_config.AddIncludedCategory("*");
213 heap_profiler_filter_config.AddIncludedCategory(
214 MemoryDumpManager::kTraceCategory);
215 TraceConfig::EventFilters filters;
216 filters.push_back(heap_profiler_filter_config);
217 TraceConfig filtering_trace_config;
218 filtering_trace_config.SetEventFilterConfigs(filters);
219 TraceLog::GetInstance()->SetEnabled(filtering_trace_config,
220 TraceLog::FILTERING_MODE);
221 }
222
204 // If tracing was enabled before initializing MemoryDumpManager, we missed the 223 // If tracing was enabled before initializing MemoryDumpManager, we missed the
205 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party. 224 // OnTraceLogEnabled() event. Synthetize it so we can late-join the party.
206 bool is_tracing_already_enabled = TraceLog::GetInstance()->IsEnabled(); 225 bool tracing_already_enabled = TraceLog::GetInstance()->IsEnabled();
207 TRACE_EVENT0(kTraceCategory, "init"); // Add to trace-viewer category list.
208 TraceLog::GetInstance()->AddEnabledStateObserver(this); 226 TraceLog::GetInstance()->AddEnabledStateObserver(this);
209 if (is_tracing_already_enabled) 227 if (tracing_already_enabled)
210 OnTraceLogEnabled(); 228 OnTraceLogEnabled();
211 } 229 }
212 230
213 void MemoryDumpManager::RegisterDumpProvider( 231 void MemoryDumpManager::RegisterDumpProvider(
214 MemoryDumpProvider* mdp, 232 MemoryDumpProvider* mdp,
215 const char* name, 233 const char* name,
216 scoped_refptr<SingleThreadTaskRunner> task_runner, 234 scoped_refptr<SingleThreadTaskRunner> task_runner,
217 MemoryDumpProvider::Options options) { 235 MemoryDumpProvider::Options options) {
218 options.dumps_on_single_thread_task_runner = true; 236 options.dumps_on_single_thread_task_runner = true;
219 RegisterDumpProviderInternal(mdp, name, std::move(task_runner), options); 237 RegisterDumpProviderInternal(mdp, name, std::move(task_runner), options);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 883 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
866 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 884 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
867 ++periodic_dumps_count_; 885 ++periodic_dumps_count_;
868 886
869 MemoryDumpManager::GetInstance()->RequestGlobalDump( 887 MemoryDumpManager::GetInstance()->RequestGlobalDump(
870 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 888 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
871 } 889 }
872 890
873 } // namespace trace_event 891 } // namespace trace_event
874 } // namespace base 892 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698