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 "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 Loading... | |
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 CHECK(!dump_manager->IsDumpModeAllowed( | |
Primiano Tucci (use gerrit)
2016/06/10 12:31:57
maybe add a comment saying:
"Safety check to make
ssid
2016/06/10 18:23:48
Done.
| |
56 base::trace_event::MemoryDumpLevelOfDetail::DETAILED)); | |
57 dump_manager->RequestGlobalDump( | |
57 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, | 58 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, |
58 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); | 59 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND); |
59 } | 60 } |
60 | 61 |
61 } // namespace | 62 } // namespace |
62 | 63 |
63 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( | 64 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( |
64 StartedFinalizingCallback callback) : callback_(callback) { | 65 StartedFinalizingCallback callback) : callback_(callback) { |
65 } | 66 } |
66 | 67 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
407 if (requires_anonymized_data_) | 408 if (requires_anonymized_data_) |
408 trace_config.EnableArgumentFilter(); | 409 trace_config.EnableArgumentFilter(); |
409 | 410 |
410 base::Closure tracing_enabled_callback; | 411 base::Closure tracing_enabled_callback; |
411 if (!tracing_enabled_callback_for_testing_.is_null()) { | 412 if (!tracing_enabled_callback_for_testing_.is_null()) { |
412 tracing_enabled_callback = tracing_enabled_callback_for_testing_; | 413 tracing_enabled_callback = tracing_enabled_callback_for_testing_; |
413 } else if (preset == BackgroundTracingConfigImpl::CategoryPreset:: | 414 } else if (preset == BackgroundTracingConfigImpl::CategoryPreset:: |
414 BENCHMARK_MEMORY_LIGHT) { | 415 BENCHMARK_MEMORY_LIGHT) { |
415 // On memory light mode, the periodic memory dumps are disabled and a single | 416 // 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. | 417 // memory dump is requested after tracing is enabled in all the processes. |
417 trace_config.ResetMemoryDumpConfig( | 418 // TODO(ssid): Remove this when background tracing supports trace config |
418 base::trace_event::TraceConfig::MemoryDumpConfig()); | 419 // strings and memory-infra supports peak detection crbug.com/609935. |
420 base::trace_event::TraceConfig::MemoryDumpConfig memory_config; | |
421 memory_config.allowed_dump_modes = | |
422 std::set<base::trace_event::MemoryDumpLevelOfDetail>( | |
423 {base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND}); | |
424 trace_config.ResetMemoryDumpConfig(memory_config); | |
419 tracing_enabled_callback = | 425 tracing_enabled_callback = |
420 base::Bind(&BenchmarkMemoryLight_TracingEnabledCallback); | 426 base::Bind(&BenchmarkMemoryLight_TracingEnabledCallback); |
421 } | 427 } |
422 | 428 |
423 is_tracing_ = TracingController::GetInstance()->StartTracing( | 429 is_tracing_ = TracingController::GetInstance()->StartTracing( |
424 trace_config, tracing_enabled_callback); | 430 trace_config, tracing_enabled_callback); |
425 RecordBackgroundTracingMetric(RECORDING_ENABLED); | 431 RecordBackgroundTracingMetric(RECORDING_ENABLED); |
426 } | 432 } |
427 | 433 |
428 void BackgroundTracingManagerImpl::OnFinalizeStarted( | 434 void BackgroundTracingManagerImpl::OnFinalizeStarted( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: | 561 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: |
556 return "blink_style"; | 562 return "blink_style"; |
557 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: | 563 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: |
558 NOTREACHED(); | 564 NOTREACHED(); |
559 } | 565 } |
560 NOTREACHED(); | 566 NOTREACHED(); |
561 return ""; | 567 return ""; |
562 } | 568 } |
563 | 569 |
564 } // namspace content | 570 } // namspace content |
OLD | NEW |