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

Side by Side Diff: content/browser/tracing/background_tracing_manager_impl.cc

Issue 2041583003: [tracing] Introduce "allowed_dump_modes" for memory dump config (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@background_config
Patch Set: Change mode to int. Created 4 years, 6 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
« no previous file with comments | « content/browser/devtools/protocol/tracing_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/tracing/background_tracing_manager_impl.h" 5 #include "content/browser/tracing/background_tracing_manager_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 SCENARIO_ACTION_FAILED_LOWRES_CLOCK = 9, 43 SCENARIO_ACTION_FAILED_LOWRES_CLOCK = 9,
44 NUMBER_OF_BACKGROUND_TRACING_METRICS, 44 NUMBER_OF_BACKGROUND_TRACING_METRICS,
45 }; 45 };
46 46
47 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { 47 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) {
48 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, 48 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric,
49 NUMBER_OF_BACKGROUND_TRACING_METRICS); 49 NUMBER_OF_BACKGROUND_TRACING_METRICS);
50 } 50 }
51 51
52 // Tracing enabled callback for BENCHMARK_MEMORY_LIGHT category preset. 52 // Tracing enabled callback for BENCHMARK_MEMORY_LIGHT category preset.
53 // TODO(ssid): Remove this when background tracing supports trace config strings
54 // and memory-infra supports peak detection crbug.com/609935.
55 void BenchmarkMemoryLight_TracingEnabledCallback() { 53 void BenchmarkMemoryLight_TracingEnabledCallback() {
56 base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump( 54 auto dump_manager = base::trace_event::MemoryDumpManager::GetInstance();
55 // Safety check to make sure the memory-infra restrictions are properly
56 // propagated via TraceConfig
57 CHECK(!dump_manager->IsDumpModeAllowed(
58 base::trace_event::MemoryDumpLevelOfDetail::DETAILED));
59 dump_manager->RequestGlobalDump(
57 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, 60 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
58 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); 61 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND);
59 } 62 }
60 63
61 } // namespace 64 } // namespace
62 65
63 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( 66 BackgroundTracingManagerImpl::TracingTimer::TracingTimer(
64 StartedFinalizingCallback callback) : callback_(callback) { 67 StartedFinalizingCallback callback) : callback_(callback) {
65 } 68 }
66 69
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (requires_anonymized_data_) 410 if (requires_anonymized_data_)
408 trace_config.EnableArgumentFilter(); 411 trace_config.EnableArgumentFilter();
409 412
410 base::Closure tracing_enabled_callback; 413 base::Closure tracing_enabled_callback;
411 if (!tracing_enabled_callback_for_testing_.is_null()) { 414 if (!tracing_enabled_callback_for_testing_.is_null()) {
412 tracing_enabled_callback = tracing_enabled_callback_for_testing_; 415 tracing_enabled_callback = tracing_enabled_callback_for_testing_;
413 } else if (preset == BackgroundTracingConfigImpl::CategoryPreset:: 416 } else if (preset == BackgroundTracingConfigImpl::CategoryPreset::
414 BENCHMARK_MEMORY_LIGHT) { 417 BENCHMARK_MEMORY_LIGHT) {
415 // On memory light mode, the periodic memory dumps are disabled and a single 418 // On memory light mode, the periodic memory dumps are disabled and a single
416 // memory dump is requested after tracing is enabled in all the processes. 419 // memory dump is requested after tracing is enabled in all the processes.
417 trace_config.ResetMemoryDumpConfig( 420 // TODO(ssid): Remove this when background tracing supports trace config
418 base::trace_event::TraceConfig::MemoryDumpConfig()); 421 // strings and memory-infra supports peak detection crbug.com/609935.
422 base::trace_event::TraceConfig::MemoryDumpConfig memory_config;
423 memory_config.allowed_dump_modes =
424 std::set<base::trace_event::MemoryDumpLevelOfDetail>(
425 {base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND});
426 trace_config.ResetMemoryDumpConfig(memory_config);
419 tracing_enabled_callback = 427 tracing_enabled_callback =
420 base::Bind(&BenchmarkMemoryLight_TracingEnabledCallback); 428 base::Bind(&BenchmarkMemoryLight_TracingEnabledCallback);
421 } 429 }
422 430
423 is_tracing_ = TracingController::GetInstance()->StartTracing( 431 is_tracing_ = TracingController::GetInstance()->StartTracing(
424 trace_config, tracing_enabled_callback); 432 trace_config, tracing_enabled_callback);
425 RecordBackgroundTracingMetric(RECORDING_ENABLED); 433 RecordBackgroundTracingMetric(RECORDING_ENABLED);
426 } 434 }
427 435
428 void BackgroundTracingManagerImpl::OnFinalizeStarted( 436 void BackgroundTracingManagerImpl::OnFinalizeStarted(
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: 563 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE:
556 return "blink_style"; 564 return "blink_style";
557 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: 565 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET:
558 NOTREACHED(); 566 NOTREACHED();
559 } 567 }
560 NOTREACHED(); 568 NOTREACHED();
561 return ""; 569 return "";
562 } 570 }
563 571
564 } // namspace content 572 } // namspace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/tracing_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698