Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / spellchecker / spellcheck_host_metrics.h
blob60e61d96b79aac41fe46493d0c97af8e82b342e1
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_
6 #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_
8 #include <string>
9 #include <vector>
11 #include "base/containers/hash_tables.h"
12 #include "base/time/time.h"
13 #include "base/timer/timer.h"
15 // A helper object for recording spell-check related histograms.
16 // This class encapsulates histogram names and metrics API.
17 // This also carries a set of counters for collecting histograms
18 // and a timer for making a periodical summary.
20 // We expect a user of SpellCheckHost class to instantiate this object,
21 // and pass the metrics object to SpellCheckHost's factory method.
23 // metrics.reset(new SpellCheckHostMetrics());
24 // spell_check_host = SpellChecHost::Create(...., metrics.get());
26 // The lifetime of the object should be managed by a caller,
27 // and the lifetime should be longer than SpellCheckHost instance
28 // because SpellCheckHost will use the object.
29 class SpellCheckHostMetrics {
30 public:
31 SpellCheckHostMetrics();
32 ~SpellCheckHostMetrics();
34 // Collects the number of words in the custom dictionary, which is
35 // to be uploaded via UMA.
36 static void RecordCustomWordCountStats(size_t count);
38 // Collects status of spellchecking enabling state, which is
39 // to be uploaded via UMA
40 void RecordEnabledStats(bool enabled);
42 // Collects a histogram for dictionary corruption rate
43 // to be uploaded via UMA
44 void RecordDictionaryCorruptionStats(bool corrupted);
46 // Collects status of spellchecking enabling state, which is
47 // to be uploaded via UMA
48 void RecordCheckedWordStats(const base::string16& word, bool misspell);
50 // Collects a histogram for misspelled word replacement
51 // to be uploaded via UMA
52 void RecordReplacedWordStats(int delta);
54 // Collects a histogram for context menu showing as a spell correction
55 // attempt to be uploaded via UMA
56 void RecordSuggestionStats(int delta);
58 // Records if spelling service is enabled or disabled.
59 void RecordSpellingServiceStats(bool enabled);
61 private:
62 friend class SpellcheckHostMetricsTest;
63 void OnHistogramTimerExpired();
65 // Records various counters without changing their values.
66 void RecordWordCounts();
68 // Number of corrected words of checked words.
69 int misspelled_word_count_;
70 int last_misspelled_word_count_;
72 // Number of checked words.
73 int spellchecked_word_count_;
74 int last_spellchecked_word_count_;
76 // Number of suggestion list showings.
77 int suggestion_show_count_;
78 int last_suggestion_show_count_;
80 // Number of misspelled words replaced by a user.
81 int replaced_word_count_;
82 int last_replaced_word_count_;
84 // Last recorded number of unique words.
85 int last_unique_word_count_;
87 // Time when first spellcheck happened.
88 base::TimeTicks start_time_;
89 // Set of checked words in the hashed form.
90 base::hash_set<std::string> checked_word_hashes_;
91 base::RepeatingTimer<SpellCheckHostMetrics> recording_timer_;
94 #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_