| 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 "base/cpu.h" | 7 #include "base/cpu.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 enum BackgroundTracingMetrics { | 30 enum BackgroundTracingMetrics { |
| 31 SCENARIO_ACTIVATION_REQUESTED = 0, | 31 SCENARIO_ACTIVATION_REQUESTED = 0, |
| 32 SCENARIO_ACTIVATED_SUCCESSFULLY = 1, | 32 SCENARIO_ACTIVATED_SUCCESSFULLY = 1, |
| 33 RECORDING_ENABLED = 2, | 33 RECORDING_ENABLED = 2, |
| 34 PREEMPTIVE_TRIGGERED = 3, | 34 PREEMPTIVE_TRIGGERED = 3, |
| 35 REACTIVE_TRIGGERED = 4, | 35 REACTIVE_TRIGGERED = 4, |
| 36 FINALIZATION_ALLOWED = 5, | 36 FINALIZATION_ALLOWED = 5, |
| 37 FINALIZATION_DISALLOWED = 6, | 37 FINALIZATION_DISALLOWED = 6, |
| 38 FINALIZATION_STARTED = 7, | 38 FINALIZATION_STARTED = 7, |
| 39 FINALIZATION_COMPLETE = 8, | 39 FINALIZATION_COMPLETE = 8, |
| 40 SCENARIO_ACTION_FAILED_LOWRES_CLOCK = 9, |
| 40 NUMBER_OF_BACKGROUND_TRACING_METRICS, | 41 NUMBER_OF_BACKGROUND_TRACING_METRICS, |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { | 44 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { |
| 44 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, | 45 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, |
| 45 NUMBER_OF_BACKGROUND_TRACING_METRICS); | 46 NUMBER_OF_BACKGROUND_TRACING_METRICS); |
| 46 } | 47 } |
| 47 | 48 |
| 48 std::string GetNetworkTypeString() { | 49 std::string GetNetworkTypeString() { |
| 49 switch (net::NetworkChangeNotifier::GetConnectionType()) { | 50 switch (net::NetworkChangeNotifier::GetConnectionType()) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool BackgroundTracingManagerImpl::SetActiveScenario( | 126 bool BackgroundTracingManagerImpl::SetActiveScenario( |
| 126 scoped_ptr<BackgroundTracingConfig> config, | 127 scoped_ptr<BackgroundTracingConfig> config, |
| 127 const BackgroundTracingManager::ReceiveCallback& receive_callback, | 128 const BackgroundTracingManager::ReceiveCallback& receive_callback, |
| 128 DataFiltering data_filtering) { | 129 DataFiltering data_filtering) { |
| 129 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 130 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 130 RecordBackgroundTracingMetric(SCENARIO_ACTIVATION_REQUESTED); | 131 RecordBackgroundTracingMetric(SCENARIO_ACTIVATION_REQUESTED); |
| 131 | 132 |
| 132 if (is_tracing_) | 133 if (is_tracing_) |
| 133 return false; | 134 return false; |
| 134 | 135 |
| 136 // If we don't have a high resolution timer available, traces will be |
| 137 // too inaccurate to be useful. |
| 138 if (!base::TimeTicks::IsHighResolution()) { |
| 139 RecordBackgroundTracingMetric(SCENARIO_ACTION_FAILED_LOWRES_CLOCK); |
| 140 return false; |
| 141 } |
| 142 |
| 135 bool requires_anonymized_data = (data_filtering == ANONYMIZE_DATA); | 143 bool requires_anonymized_data = (data_filtering == ANONYMIZE_DATA); |
| 136 | 144 |
| 137 // If the I/O thread isn't running, this is a startup scenario and | 145 // If the I/O thread isn't running, this is a startup scenario and |
| 138 // we have to wait until initialization is finished to validate that the | 146 // we have to wait until initialization is finished to validate that the |
| 139 // scenario can run. | 147 // scenario can run. |
| 140 if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) { | 148 if (BrowserThread::IsThreadInitialized(BrowserThread::IO)) { |
| 141 // TODO(oysteine): Retry when time_until_allowed has elapsed. | 149 // TODO(oysteine): Retry when time_until_allowed has elapsed. |
| 142 if (config && delegate_ && | 150 if (config && delegate_ && |
| 143 !delegate_->IsAllowedToBeginBackgroundScenario( | 151 !delegate_->IsAllowedToBeginBackgroundScenario( |
| 144 *config.get(), requires_anonymized_data)) { | 152 *config.get(), requires_anonymized_data)) { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_STARTUP: | 557 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_STARTUP: |
| 550 return "benchmark,toplevel,startup,disabled-by-default-file," | 558 return "benchmark,toplevel,startup,disabled-by-default-file," |
| 551 "disabled-by-default-toplevel.flow," | 559 "disabled-by-default-toplevel.flow," |
| 552 "disabled-by-default-ipc.flow"; | 560 "disabled-by-default-ipc.flow"; |
| 553 } | 561 } |
| 554 NOTREACHED(); | 562 NOTREACHED(); |
| 555 return ""; | 563 return ""; |
| 556 } | 564 } |
| 557 | 565 |
| 558 } // namspace content | 566 } // namspace content |
| OLD | NEW |