| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/metrics/metrics_service.h" | 5 #include "components/metrics/metrics_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/metrics_hashes.h" |
| 12 #include "base/metrics/statistics_recorder.h" | 13 #include "base/metrics/statistics_recorder.h" |
| 13 #include "base/prefs/testing_pref_service.h" | 14 #include "base/prefs/testing_pref_service.h" |
| 14 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
| 15 #include "components/compression/compression_utils.h" | 16 #include "components/compression/compression_utils.h" |
| 16 #include "components/metrics/client_info.h" | 17 #include "components/metrics/client_info.h" |
| 17 #include "components/metrics/metrics_hashes.h" | |
| 18 #include "components/metrics/metrics_log.h" | 18 #include "components/metrics/metrics_log.h" |
| 19 #include "components/metrics/metrics_pref_names.h" | 19 #include "components/metrics/metrics_pref_names.h" |
| 20 #include "components/metrics/metrics_state_manager.h" | 20 #include "components/metrics/metrics_state_manager.h" |
| 21 #include "components/metrics/test_metrics_provider.h" | 21 #include "components/metrics/test_metrics_provider.h" |
| 22 #include "components/metrics/test_metrics_service_client.h" | 22 #include "components/metrics/test_metrics_service_client.h" |
| 23 #include "components/variations/metrics_util.h" | 23 #include "components/variations/metrics_util.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 namespace metrics { | 26 namespace metrics { |
| 27 | 27 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 return false; | 117 return false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Finds a histogram with the specified |name_hash| in |histograms|. | 120 // Finds a histogram with the specified |name_hash| in |histograms|. |
| 121 const base::HistogramBase* FindHistogram( | 121 const base::HistogramBase* FindHistogram( |
| 122 const base::StatisticsRecorder::Histograms& histograms, | 122 const base::StatisticsRecorder::Histograms& histograms, |
| 123 uint64 name_hash) { | 123 uint64 name_hash) { |
| 124 for (const base::HistogramBase* histogram : histograms) { | 124 for (const base::HistogramBase* histogram : histograms) { |
| 125 if (name_hash == HashMetricName(histogram->histogram_name())) | 125 if (name_hash == base::HashMetricName(histogram->histogram_name())) |
| 126 return histogram; | 126 return histogram; |
| 127 } | 127 } |
| 128 return nullptr; | 128 return nullptr; |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Checks whether |uma_log| contains any histograms that are not flagged | 131 // Checks whether |uma_log| contains any histograms that are not flagged |
| 132 // with kUmaStabilityHistogramFlag. Stability logs should only contain such | 132 // with kUmaStabilityHistogramFlag. Stability logs should only contain such |
| 133 // histograms. | 133 // histograms. |
| 134 void CheckForNonStabilityHistograms( | 134 void CheckForNonStabilityHistograms( |
| 135 const ChromeUserMetricsExtension& uma_log) { | 135 const ChromeUserMetricsExtension& uma_log) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 TestMetricsProvider* test_provider = new TestMetricsProvider(); | 382 TestMetricsProvider* test_provider = new TestMetricsProvider(); |
| 383 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); | 383 service.RegisterMetricsProvider(scoped_ptr<MetricsProvider>(test_provider)); |
| 384 | 384 |
| 385 service.InitializeMetricsRecordingState(); | 385 service.InitializeMetricsRecordingState(); |
| 386 service.Stop(); | 386 service.Stop(); |
| 387 | 387 |
| 388 EXPECT_TRUE(test_provider->on_recording_disabled_called()); | 388 EXPECT_TRUE(test_provider->on_recording_disabled_called()); |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace metrics | 391 } // namespace metrics |
| OLD | NEW |