[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 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. | ||||
4 | |||||
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_ |
6 | #define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_ | ||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 7 | |
8 | #include <string> | ||||
9 | #include <vector> | ||||
10 | |||||
[email protected] | 14c1c23 | 2013-06-11 17:52:44 | [diff] [blame] | 11 | #include "base/containers/hash_tables.h" |
[email protected] | cc86ccfe | 2013-06-28 00:10:50 | [diff] [blame] | 12 | #include "base/time/time.h" |
13 | #include "base/timer/timer.h" | ||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 14 | |
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. | ||||
19 | // | ||||
20 | // We expect a user of SpellCheckHost class to instantiate this object, | ||||
21 | // and pass the metrics object to SpellCheckHost's factory method. | ||||
22 | // | ||||
23 | // metrics.reset(new SpellCheckHostMetrics()); | ||||
24 | // spell_check_host = SpellChecHost::Create(...., metrics.get()); | ||||
25 | // | ||||
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(); | ||||
33 | |||||
34 | // Collects the number of words in the custom dictionary, which is | ||||
35 | // to be uploaded via UMA. | ||||
[email protected] | 1c2b985 | 2013-04-06 01:16:42 | [diff] [blame] | 36 | static void RecordCustomWordCountStats(size_t count); |
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 37 | |
38 | // Collects status of spellchecking enabling state, which is | ||||
39 | // to be uploaded via UMA | ||||
40 | void RecordEnabledStats(bool enabled); | ||||
41 | |||||
42 | // Collects a histogram for dictionary corruption rate | ||||
43 | // to be uploaded via UMA | ||||
44 | void RecordDictionaryCorruptionStats(bool corrupted); | ||||
45 | |||||
46 | // Collects status of spellchecking enabling state, which is | ||||
47 | // to be uploaded via UMA | ||||
[email protected] | a04db82 | 2013-12-11 19:14:40 | [diff] [blame^] | 48 | void RecordCheckedWordStats(const base::string16& word, bool misspell); |
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 49 | |
50 | // Collects a histogram for misspelled word replacement | ||||
51 | // to be uploaded via UMA | ||||
52 | void RecordReplacedWordStats(int delta); | ||||
53 | |||||
54 | // Collects a histogram for context menu showing as a spell correction | ||||
55 | // attempt to be uploaded via UMA | ||||
56 | void RecordSuggestionStats(int delta); | ||||
57 | |||||
[email protected] | 8e6ca16 | 2013-02-22 11:37:30 | [diff] [blame] | 58 | // Records if spelling service is enabled or disabled. |
59 | void RecordSpellingServiceStats(bool enabled); | ||||
60 | |||||
[email protected] | 253f137 | 2011-09-29 17:36:55 | [diff] [blame] | 61 | private: |
[email protected] | 80131930 | 2012-11-28 00:54:19 | [diff] [blame] | 62 | friend class SpellcheckHostMetricsTest; |
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 63 | void OnHistogramTimerExpired(); |
64 | |||||
[email protected] | 7e1f665 | 2011-06-27 07:10:43 | [diff] [blame] | 65 | // Records various counters without changing their values. |
66 | void RecordWordCounts(); | ||||
67 | |||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 68 | // Number of corrected words of checked words. |
69 | int misspelled_word_count_; | ||||
[email protected] | 80131930 | 2012-11-28 00:54:19 | [diff] [blame] | 70 | int last_misspelled_word_count_; |
71 | |||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 72 | // Number of checked words. |
73 | int spellchecked_word_count_; | ||||
[email protected] | 80131930 | 2012-11-28 00:54:19 | [diff] [blame] | 74 | int last_spellchecked_word_count_; |
75 | |||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 76 | // Number of suggestion list showings. |
77 | int suggestion_show_count_; | ||||
[email protected] | 80131930 | 2012-11-28 00:54:19 | [diff] [blame] | 78 | int last_suggestion_show_count_; |
79 | |||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 80 | // Number of misspelled words replaced by a user. |
81 | int replaced_word_count_; | ||||
[email protected] | 80131930 | 2012-11-28 00:54:19 | [diff] [blame] | 82 | int last_replaced_word_count_; |
83 | |||||
84 | // Last recorded number of unique words. | ||||
85 | int last_unique_word_count_; | ||||
86 | |||||
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 87 | // Time when first spellcheck happened. |
[email protected] | 253f137 | 2011-09-29 17:36:55 | [diff] [blame] | 88 | base::TimeTicks start_time_; |
[email protected] | 88269e47 | 2011-06-24 06:32:59 | [diff] [blame] | 89 | // Set of checked words in the hashed form. |
90 | base::hash_set<std::string> checked_word_hashes_; | ||||
91 | base::RepeatingTimer<SpellCheckHostMetrics> recording_timer_; | ||||
92 | }; | ||||
93 | |||||
[email protected] | 8ec7126 | 2011-07-28 08:12:46 | [diff] [blame] | 94 | #endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HOST_METRICS_H_ |