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