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

Side by Side Diff: chrome/renderer/spellchecker/hunspell_engine.cc

Issue 484603006: Add LOCAL_ prefix to non-UMA histogram macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/spellchecker/hunspell_engine.h" 5 #include "chrome/renderer/spellchecker/hunspell_engine.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/files/memory_mapped_file.h" 10 #include "base/files/memory_mapped_file.h"
11 #include "base/metrics/histogram.h"
12 #include "base/time/time.h" 11 #include "base/time/time.h"
13 #include "chrome/common/spellcheck_common.h" 12 #include "chrome/common/spellcheck_common.h"
14 #include "chrome/common/spellcheck_messages.h" 13 #include "chrome/common/spellcheck_messages.h"
15 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
16 #include "third_party/hunspell/src/hunspell/hunspell.hxx" 15 #include "third_party/hunspell/src/hunspell/hunspell.hxx"
17 16
18 using base::TimeTicks;
19 using content::RenderThread; 17 using content::RenderThread;
20 18
21 namespace { 19 namespace {
22 // Maximum length of words we actually check. 20 // Maximum length of words we actually check.
23 // 64 is the observed limits for OSX system checker. 21 // 64 is the observed limits for OSX system checker.
24 const size_t kMaxCheckedLen = 64; 22 const size_t kMaxCheckedLen = 64;
25 23
26 // Maximum length of words we provide suggestions for. 24 // Maximum length of words we provide suggestions for.
27 // 24 is the observed limits for OSX system checker. 25 // 24 is the observed limits for OSX system checker.
28 const size_t kMaxSuggestLen = 24; 26 const size_t kMaxSuggestLen = 24;
(...skipping 27 matching lines...) Expand all
56 // Delay the actual initialization of hunspell until it is needed. 54 // Delay the actual initialization of hunspell until it is needed.
57 } 55 }
58 56
59 void HunspellEngine::InitializeHunspell() { 57 void HunspellEngine::InitializeHunspell() {
60 if (hunspell_.get()) 58 if (hunspell_.get())
61 return; 59 return;
62 60
63 bdict_file_.reset(new base::MemoryMappedFile); 61 bdict_file_.reset(new base::MemoryMappedFile);
64 62
65 if (bdict_file_->Initialize(file_.Pass())) { 63 if (bdict_file_->Initialize(file_.Pass())) {
66 TimeTicks debug_start_time = base::Histogram::DebugNow();
67
68 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length())); 64 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length()));
69
70 DHISTOGRAM_TIMES("Spellcheck.InitTime",
71 base::Histogram::DebugNow() - debug_start_time);
72 } else { 65 } else {
73 NOTREACHED() << "Could not mmap spellchecker dictionary."; 66 NOTREACHED() << "Could not mmap spellchecker dictionary.";
74 } 67 }
75 } 68 }
76 69
77 bool HunspellEngine::CheckSpelling(const base::string16& word_to_check, 70 bool HunspellEngine::CheckSpelling(const base::string16& word_to_check,
78 int tag) { 71 int tag) {
79 // Assume all words that cannot be checked are valid. Since Chrome can't 72 // Assume all words that cannot be checked are valid. Since Chrome can't
80 // offer suggestions on them, either, there's no point in flagging them to 73 // offer suggestions on them, either, there's no point in flagging them to
81 // the user. 74 // the user.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Don't initialize if hunspell is disabled. 127 // Don't initialize if hunspell is disabled.
135 if (file_.IsValid()) 128 if (file_.IsValid())
136 InitializeHunspell(); 129 InitializeHunspell();
137 130
138 return !initialized_; 131 return !initialized_;
139 } 132 }
140 133
141 bool HunspellEngine::IsEnabled() { 134 bool HunspellEngine::IsEnabled() {
142 return hunspell_enabled_; 135 return hunspell_enabled_;
143 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/new_tab_page_handler.cc ('k') | components/startup_metric_utils/startup_metric_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698