| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 5 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // have changed from the last invocation. | 103 // have changed from the last invocation. |
| 104 const char* histogramName[] = { | 104 const char* histogramName[] = { |
| 105 "SpellCheck.CheckedWords", | 105 "SpellCheck.CheckedWords", |
| 106 "SpellCheck.MisspelledWords", | 106 "SpellCheck.MisspelledWords", |
| 107 "SpellCheck.ReplacedWords", | 107 "SpellCheck.ReplacedWords", |
| 108 "SpellCheck.UniqueWords", | 108 "SpellCheck.UniqueWords", |
| 109 "SpellCheck.ShownSuggestions" | 109 "SpellCheck.ShownSuggestions" |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 // Ensure all histograms exist. | 112 // Ensure all histograms exist. |
| 113 metrics()->RecordCheckedWordStats(ASCIIToUTF16("test"), false); | 113 metrics()->RecordCheckedWordStats(base::ASCIIToUTF16("test"), false); |
| 114 RecordWordCountsForTesting(); | 114 RecordWordCountsForTesting(); |
| 115 | 115 |
| 116 // Get baselines for all affected histograms. | 116 // Get baselines for all affected histograms. |
| 117 scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)]; | 117 scoped_ptr<HistogramSamples> baselines[arraysize(histogramName)]; |
| 118 for (size_t i = 0; i < arraysize(histogramName); ++i) { | 118 for (size_t i = 0; i < arraysize(histogramName); ++i) { |
| 119 HistogramBase* histogram = | 119 HistogramBase* histogram = |
| 120 StatisticsRecorder::FindHistogram(histogramName[i]); | 120 StatisticsRecorder::FindHistogram(histogramName[i]); |
| 121 if (histogram) | 121 if (histogram) |
| 122 baselines[i] = histogram->SnapshotSamples(); | 122 baselines[i] = histogram->SnapshotSamples(); |
| 123 } | 123 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 metrics()->RecordSpellingServiceStats(true); | 162 metrics()->RecordSpellingServiceStats(true); |
| 163 | 163 |
| 164 histogram = | 164 histogram = |
| 165 StatisticsRecorder::FindHistogram(kMetricName); | 165 StatisticsRecorder::FindHistogram(kMetricName); |
| 166 ASSERT_TRUE(histogram != NULL); | 166 ASSERT_TRUE(histogram != NULL); |
| 167 samples = histogram->SnapshotSamples(); | 167 samples = histogram->SnapshotSamples(); |
| 168 samples->Subtract(*baseline); | 168 samples->Subtract(*baseline); |
| 169 EXPECT_EQ(0, samples->GetCount(0)); | 169 EXPECT_EQ(0, samples->GetCount(0)); |
| 170 EXPECT_EQ(1, samples->GetCount(1)); | 170 EXPECT_EQ(1, samples->GetCount(1)); |
| 171 } | 171 } |
| OLD | NEW |