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