Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: chrome/browser/spellcheck_host_impl.cc

Issue 6995099: Revert 88309 - Introduced additional spellcheck related histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/spellcheck_host_impl.h" 5 #include "chrome/browser/spellcheck_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const std::string& language, 84 const std::string& language,
85 net::URLRequestContextGetter* request_context_getter) 85 net::URLRequestContextGetter* request_context_getter)
86 : observer_(observer), 86 : observer_(observer),
87 language_(language), 87 language_(language),
88 file_(base::kInvalidPlatformFileValue), 88 file_(base::kInvalidPlatformFileValue),
89 tried_to_download_(false), 89 tried_to_download_(false),
90 use_platform_spellchecker_(false), 90 use_platform_spellchecker_(false),
91 request_context_getter_(request_context_getter), 91 request_context_getter_(request_context_getter),
92 misspelled_word_count_(0), 92 misspelled_word_count_(0),
93 spellchecked_word_count_(0), 93 spellchecked_word_count_(0),
94 suggestion_count_(0),
95 replaced_word_count_(0) { 94 replaced_word_count_(0) {
96 DCHECK(observer_); 95 DCHECK(observer_);
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98 97
99 FilePath personal_file_directory; 98 FilePath personal_file_directory;
100 PathService::Get(chrome::DIR_USER_DATA, &personal_file_directory); 99 PathService::Get(chrome::DIR_USER_DATA, &personal_file_directory);
101 custom_dictionary_file_ = 100 custom_dictionary_file_ =
102 personal_file_directory.Append(chrome::kCustomDictionaryFileName); 101 personal_file_directory.Append(chrome::kCustomDictionaryFileName);
103 102
104 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CREATED, 103 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CREATED,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // the population. So we ensure to instantiate the histogram 308 // the population. So we ensure to instantiate the histogram
310 // entries here at the first time. 309 // entries here at the first time.
311 if (misspelled_word_count_ == 1) 310 if (misspelled_word_count_ == 1)
312 RecordReplacedWordStats(0); 311 RecordReplacedWordStats(0);
313 } 312 }
314 313
315 int percentage = (100 * misspelled_word_count_) / spellchecked_word_count_; 314 int percentage = (100 * misspelled_word_count_) / spellchecked_word_count_;
316 UMA_HISTOGRAM_PERCENTAGE("SpellCheck.MisspellRatio", percentage); 315 UMA_HISTOGRAM_PERCENTAGE("SpellCheck.MisspellRatio", percentage);
317 } 316 }
318 317
319 void SpellCheckHostImpl::RecordDictionaryCorruptionStats(bool corrupted) {
320 UMA_HISTOGRAM_BOOLEAN("SpellCheck.DictionaryCorrupted", corrupted);
321 }
322
323 void SpellCheckHostImpl::RecordSuggestionStats(int delta) {
324 suggestion_count_ += delta;
325 RecordReplacedWordStats(0);
326 }
327
328 void SpellCheckHostImpl::RecordReplacedWordStats(int delta) { 318 void SpellCheckHostImpl::RecordReplacedWordStats(int delta) {
329 replaced_word_count_ += delta; 319 replaced_word_count_ += delta;
330 320 if (!misspelled_word_count_) {
331 if (misspelled_word_count_) { 321 // This is possible when an extension gives the misspelling,
332 // zero |misspelled_word_count_| is possible when an extension 322 // which is not recorded as a part of this metrics.
333 // gives the misspelling, which is not recorded as a part of this 323 return;
334 // metrics.
335 int percentage = (100 * replaced_word_count_) / misspelled_word_count_;
336 UMA_HISTOGRAM_PERCENTAGE("SpellCheck.ReplaceRatio", percentage);
337 } 324 }
338 325
339 if (suggestion_count_) { 326 int percentage = (100 * replaced_word_count_) / misspelled_word_count_;
340 int percentage = (100 * replaced_word_count_) / suggestion_count_; 327 UMA_HISTOGRAM_PERCENTAGE("SpellCheck.ReplaceRatio", percentage);
341 UMA_HISTOGRAM_PERCENTAGE("SpellCheck.SuggestionHitRatio", percentage);
342 }
343 } 328 }
344 329
345 void SpellCheckHostImpl::OnURLFetchComplete(const URLFetcher* source, 330 void SpellCheckHostImpl::OnURLFetchComplete(const URLFetcher* source,
346 const GURL& url, 331 const GURL& url,
347 const net::URLRequestStatus& status, 332 const net::URLRequestStatus& status,
348 int response_code, 333 int response_code,
349 const net::ResponseCookies& cookies, 334 const net::ResponseCookies& cookies,
350 const std::string& data) { 335 const std::string& data) {
351 DCHECK(source); 336 DCHECK(source);
352 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
(...skipping 27 matching lines...) Expand all
380 DCHECK(type == NotificationType::RENDERER_PROCESS_CREATED); 365 DCHECK(type == NotificationType::RENDERER_PROCESS_CREATED);
381 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); 366 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
382 InitForRenderer(process); 367 InitForRenderer(process);
383 } 368 }
384 369
385 void SpellCheckHostImpl::SaveDictionaryData() { 370 void SpellCheckHostImpl::SaveDictionaryData() {
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
387 372
388 // To prevent corrupted dictionary data from causing a renderer crash, scan 373 // To prevent corrupted dictionary data from causing a renderer crash, scan
389 // the dictionary data and verify it is sane before save it to a file. 374 // the dictionary data and verify it is sane before save it to a file.
390 bool verified = hunspell::BDict::Verify(data_.data(), data_.size()); 375 if (!hunspell::BDict::Verify(data_.data(), data_.size())) {
391 RecordDictionaryCorruptionStats(!verified);
392 if (!verified) {
393 LOG(ERROR) << "Failure to verify the downloaded dictionary."; 376 LOG(ERROR) << "Failure to verify the downloaded dictionary.";
394 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 377 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
395 NewRunnableMethod(this, 378 NewRunnableMethod(this,
396 &SpellCheckHostImpl::InformObserverOfInitialization)); 379 &SpellCheckHostImpl::InformObserverOfInitialization));
397 return; 380 return;
398 } 381 }
399 382
400 size_t bytes_written = 383 size_t bytes_written =
401 file_util::WriteFile(bdict_file_path_, data_.data(), data_.length()); 384 file_util::WriteFile(bdict_file_path_, data_.data(), data_.length());
402 if (bytes_written != data_.length()) { 385 if (bytes_written != data_.length()) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 return custom_words_.back(); 422 return custom_words_.back();
440 } 423 }
441 424
442 const std::string& SpellCheckHostImpl::GetLanguage() const { 425 const std::string& SpellCheckHostImpl::GetLanguage() const {
443 return language_; 426 return language_;
444 } 427 }
445 428
446 bool SpellCheckHostImpl::IsUsingPlatformChecker() const { 429 bool SpellCheckHostImpl::IsUsingPlatformChecker() const {
447 return use_platform_spellchecker_; 430 return use_platform_spellchecker_;
448 } 431 }
OLDNEW
« no previous file with comments | « chrome/browser/spellcheck_host_impl.h ('k') | content/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698