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

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: 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" 11 #include "base/metrics/histogram.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/common/spellcheck_common.h" 13 #include "chrome/common/spellcheck_common.h"
14 #include "chrome/common/spellcheck_messages.h" 14 #include "chrome/common/spellcheck_messages.h"
15 #include "content/public/renderer/render_thread.h" 15 #include "content/public/renderer/render_thread.h"
16 #include "third_party/hunspell/src/hunspell/hunspell.hxx" 16 #include "third_party/hunspell/src/hunspell/hunspell.hxx"
17 17
18 using base::TimeTicks;
19 using content::RenderThread; 18 using content::RenderThread;
20 19
21 namespace { 20 namespace {
22 // Maximum length of words we actually check. 21 // Maximum length of words we actually check.
23 // 64 is the observed limits for OSX system checker. 22 // 64 is the observed limits for OSX system checker.
24 const size_t kMaxCheckedLen = 64; 23 const size_t kMaxCheckedLen = 64;
25 24
26 // Maximum length of words we provide suggestions for. 25 // Maximum length of words we provide suggestions for.
27 // 24 is the observed limits for OSX system checker. 26 // 24 is the observed limits for OSX system checker.
28 const size_t kMaxSuggestLen = 24; 27 const size_t kMaxSuggestLen = 24;
(...skipping 27 matching lines...) Expand all
56 // Delay the actual initialization of hunspell until it is needed. 55 // Delay the actual initialization of hunspell until it is needed.
57 } 56 }
58 57
59 void HunspellEngine::InitializeHunspell() { 58 void HunspellEngine::InitializeHunspell() {
60 if (hunspell_.get()) 59 if (hunspell_.get())
61 return; 60 return;
62 61
63 bdict_file_.reset(new base::MemoryMappedFile); 62 bdict_file_.reset(new base::MemoryMappedFile);
64 63
65 if (bdict_file_->Initialize(file_.Pass())) { 64 if (bdict_file_->Initialize(file_.Pass())) {
66 TimeTicks debug_start_time = base::Histogram::DebugNow(); 65 #ifndef NDEBUG
66 base::TimeTicks debug_start_time = base::TimeTicks::Now();
67 #endif
67 68
68 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length())); 69 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length()));
69 70 #ifndef NDEBUG
70 DHISTOGRAM_TIMES("Spellcheck.InitTime", 71 LOCAL_HISTOGRAM_TIMES("Spellcheck.InitTime",
71 base::Histogram::DebugNow() - debug_start_time); 72 base::TimeTicks::Now() - debug_start_time);
73 #endif
groby-ooo-7-16 2014/08/25 21:12:11 Feel free to remove this histogram.
Alexei Svitkine (slow) 2014/08/25 21:21:03 Done.
72 } else { 74 } else {
73 NOTREACHED() << "Could not mmap spellchecker dictionary."; 75 NOTREACHED() << "Could not mmap spellchecker dictionary.";
74 } 76 }
75 } 77 }
76 78
77 bool HunspellEngine::CheckSpelling(const base::string16& word_to_check, 79 bool HunspellEngine::CheckSpelling(const base::string16& word_to_check,
78 int tag) { 80 int tag) {
79 // Assume all words that cannot be checked are valid. Since Chrome can't 81 // 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 82 // offer suggestions on them, either, there's no point in flagging them to
81 // the user. 83 // the user.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Don't initialize if hunspell is disabled. 136 // Don't initialize if hunspell is disabled.
135 if (file_.IsValid()) 137 if (file_.IsValid())
136 InitializeHunspell(); 138 InitializeHunspell();
137 139
138 return !initialized_; 140 return !initialized_;
139 } 141 }
140 142
141 bool HunspellEngine::IsEnabled() { 143 bool HunspellEngine::IsEnabled() {
142 return hunspell_enabled_; 144 return hunspell_enabled_;
143 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698