summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 08:33:26 +0000
committermorrita@chromium.org <morrita@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-08 08:33:26 +0000
commit71ab4df89ad854f62492c99b6964e6e94ebf8b9c (patch)
tree7bdf39cd5d93cbd73be5b7aae79418b88d67c49a
parent8d6ed15f3f74d3c8c9ce29d220cb65af7670eb00 (diff)
downloadchromium_src-71ab4df89ad854f62492c99b6964e6e94ebf8b9c.zip
chromium_src-71ab4df89ad854f62492c99b6964e6e94ebf8b9c.tar.gz
chromium_src-71ab4df89ad854f62492c99b6964e6e94ebf8b9c.tar.bz2
Introduced additional spellcheck related histograms.
This change added: - "SpellCheck.SuggestionHitRatio" (percentage) - "SpellCheck.SuggestionHitRatio" (boolean) TEST=manual TBR=darin BUG=none Review URL: http://codereview.chromium.org/7121006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88309 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/spellcheck_host.h4
-rw-r--r--chrome/browser/spellcheck_host_impl.cc31
-rw-r--r--chrome/browser/spellcheck_host_impl.h10
-rw-r--r--content/browser/renderer_host/render_view_host.cc7
4 files changed, 45 insertions, 7 deletions
diff --git a/chrome/browser/spellcheck_host.h b/chrome/browser/spellcheck_host.h
index 27ccbc2..d14a849 100644
--- a/chrome/browser/spellcheck_host.h
+++ b/chrome/browser/spellcheck_host.h
@@ -88,6 +88,10 @@ class SpellCheckHost
// to be uploaded via UMA
virtual void RecordCheckedWordStats(bool misspell) = 0;
+ // Collects a histogram for context menu showing as a spell correction
+ // attempt to be uploaded via UMA
+ virtual void RecordSuggestionStats(int delta) = 0;
+
// Collects a histogram for misspelled word replacement
// to be uploaded via UMA
virtual void RecordReplacedWordStats(int delta) = 0;
diff --git a/chrome/browser/spellcheck_host_impl.cc b/chrome/browser/spellcheck_host_impl.cc
index d87d000..b825b98 100644
--- a/chrome/browser/spellcheck_host_impl.cc
+++ b/chrome/browser/spellcheck_host_impl.cc
@@ -91,6 +91,7 @@ SpellCheckHostImpl::SpellCheckHostImpl(
request_context_getter_(request_context_getter),
misspelled_word_count_(0),
spellchecked_word_count_(0),
+ suggestion_count_(0),
replaced_word_count_(0) {
DCHECK(observer_);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -315,16 +316,30 @@ void SpellCheckHostImpl::RecordCheckedWordStats(bool misspell) {
UMA_HISTOGRAM_PERCENTAGE("SpellCheck.MisspellRatio", percentage);
}
+void SpellCheckHostImpl::RecordDictionaryCorruptionStats(bool corrupted) {
+ UMA_HISTOGRAM_BOOLEAN("SpellCheck.DictionaryCorrupted", corrupted);
+}
+
+void SpellCheckHostImpl::RecordSuggestionStats(int delta) {
+ suggestion_count_ += delta;
+ RecordReplacedWordStats(0);
+}
+
void SpellCheckHostImpl::RecordReplacedWordStats(int delta) {
replaced_word_count_ += delta;
- if (!misspelled_word_count_) {
- // This is possible when an extension gives the misspelling,
- // which is not recorded as a part of this metrics.
- return;
+
+ if (misspelled_word_count_) {
+ // zero |misspelled_word_count_| is possible when an extension
+ // gives the misspelling, which is not recorded as a part of this
+ // metrics.
+ int percentage = (100 * replaced_word_count_) / misspelled_word_count_;
+ UMA_HISTOGRAM_PERCENTAGE("SpellCheck.ReplaceRatio", percentage);
}
- int percentage = (100 * replaced_word_count_) / misspelled_word_count_;
- UMA_HISTOGRAM_PERCENTAGE("SpellCheck.ReplaceRatio", percentage);
+ if (suggestion_count_) {
+ int percentage = (100 * replaced_word_count_) / suggestion_count_;
+ UMA_HISTOGRAM_PERCENTAGE("SpellCheck.SuggestionHitRatio", percentage);
+ }
}
void SpellCheckHostImpl::OnURLFetchComplete(const URLFetcher* source,
@@ -372,7 +387,9 @@ void SpellCheckHostImpl::SaveDictionaryData() {
// To prevent corrupted dictionary data from causing a renderer crash, scan
// the dictionary data and verify it is sane before save it to a file.
- if (!hunspell::BDict::Verify(data_.data(), data_.size())) {
+ bool verified = hunspell::BDict::Verify(data_.data(), data_.size());
+ RecordDictionaryCorruptionStats(!verified);
+ if (!verified) {
LOG(ERROR) << "Failure to verify the downloaded dictionary.";
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this,
diff --git a/chrome/browser/spellcheck_host_impl.h b/chrome/browser/spellcheck_host_impl.h
index dea73bc..03e5800 100644
--- a/chrome/browser/spellcheck_host_impl.h
+++ b/chrome/browser/spellcheck_host_impl.h
@@ -87,6 +87,10 @@ class SpellCheckHostImpl : public SpellCheckHost,
// Write a custom dictionary addition to disk.
void WriteWordToCustomDictionary(const std::string& word);
+ // Collects a histogram for dictionary corruption rate
+ // to be uploaded via UMA
+ void RecordDictionaryCorruptionStats(bool corrupted);
+
// Collects status of spellchecking enabling state, which is
// to be uploaded via UMA
virtual void RecordCheckedWordStats(bool misspell);
@@ -95,6 +99,10 @@ class SpellCheckHostImpl : public SpellCheckHost,
// to be uploaded via UMA
virtual void RecordReplacedWordStats(int delta);
+ // Collects a histogram for context menu showing as a spell correction
+ // attempt to be uploaded via UMA
+ virtual void RecordSuggestionStats(int delta);
+
// URLFetcher::Delegate implementation. Called when we finish downloading the
// spellcheck dictionary; saves the dictionary to |data_|.
virtual void OnURLFetchComplete(const URLFetcher* source,
@@ -153,6 +161,8 @@ class SpellCheckHostImpl : public SpellCheckHost,
int misspelled_word_count_;
// Number of checked words.
int spellchecked_word_count_;
+ // Number of suggestion list showings.
+ int suggestion_count_;
// Number of misspelled words replaced by a user.
int replaced_word_count_;
};
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index 1e91447..45838fe 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -16,6 +16,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/spellcheck_host.h"
#include "content/browser/browser_message_filter.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/content_browser_client.h"
@@ -960,6 +961,12 @@ void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) {
FilterURL(policy, renderer_id, &validated_params.frame_url);
view->ShowContextMenu(validated_params);
+
+ Profile* profile = process()->profile();
+ DCHECK(profile);
+ if (!validated_params.dictionary_suggestions.empty() &&
+ profile->GetSpellCheckHost())
+ profile->GetSpellCheckHost()->RecordSuggestionStats(1);
}
void RenderViewHost::OnMsgOpenURL(const GURL& url,