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

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

Issue 12321062: base: Move MemoryMappedFile out of file_util.h and into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_frame again Created 7 years, 10 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) 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 "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/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/time.h" 12 #include "base/time.h"
12 #include "chrome/common/spellcheck_common.h" 13 #include "chrome/common/spellcheck_common.h"
13 #include "chrome/common/spellcheck_messages.h" 14 #include "chrome/common/spellcheck_messages.h"
14 #include "content/public/renderer/render_thread.h" 15 #include "content/public/renderer/render_thread.h"
15 #include "third_party/hunspell/src/hunspell/hunspell.hxx" 16 #include "third_party/hunspell/src/hunspell/hunspell.hxx"
16 17
17 using base::TimeTicks; 18 using base::TimeTicks;
18 using content::RenderThread; 19 using content::RenderThread;
19 20
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 hunspell_.reset(); 52 hunspell_.reset();
52 bdict_file_.reset(); 53 bdict_file_.reset();
53 file_ = file; 54 file_ = file;
54 // Delay the actual initialization of hunspell until it is needed. 55 // Delay the actual initialization of hunspell until it is needed.
55 } 56 }
56 57
57 void HunspellEngine::InitializeHunspell() { 58 void HunspellEngine::InitializeHunspell() {
58 if (hunspell_.get()) 59 if (hunspell_.get())
59 return; 60 return;
60 61
61 bdict_file_.reset(new file_util::MemoryMappedFile); 62 bdict_file_.reset(new base::MemoryMappedFile);
62 63
63 if (bdict_file_->Initialize(file_)) { 64 if (bdict_file_->Initialize(file_)) {
64 TimeTicks debug_start_time = base::Histogram::DebugNow(); 65 TimeTicks debug_start_time = base::Histogram::DebugNow();
65 66
66 hunspell_.reset( 67 hunspell_.reset(
67 new Hunspell(bdict_file_->data(), bdict_file_->length())); 68 new Hunspell(bdict_file_->data(), bdict_file_->length()));
68 69
69 DHISTOGRAM_TIMES("Spellcheck.InitTime", 70 DHISTOGRAM_TIMES("Spellcheck.InitTime",
70 base::Histogram::DebugNow() - debug_start_time); 71 base::Histogram::DebugNow() - debug_start_time);
71 } else { 72 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Don't initialize if hunspell is disabled. 133 // Don't initialize if hunspell is disabled.
133 if (file_ != base::kInvalidPlatformFileValue) 134 if (file_ != base::kInvalidPlatformFileValue)
134 InitializeHunspell(); 135 InitializeHunspell();
135 136
136 return !initialized_; 137 return !initialized_;
137 } 138 }
138 139
139 bool HunspellEngine::IsEnabled() { 140 bool HunspellEngine::IsEnabled() {
140 return file_ != base::kInvalidPlatformFileValue; 141 return file_ != base::kInvalidPlatformFileValue;
141 } 142 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | chrome/renderer/spellchecker/spellcheck.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698