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

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

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Posix GetSize Created 6 years, 12 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 "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"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 file_ = file; 54 file_ = file;
55 // Delay the actual initialization of hunspell until it is needed. 55 // Delay the actual initialization of hunspell until it is needed.
56 } 56 }
57 57
58 void HunspellEngine::InitializeHunspell() { 58 void HunspellEngine::InitializeHunspell() {
59 if (hunspell_.get()) 59 if (hunspell_.get())
60 return; 60 return;
61 61
62 bdict_file_.reset(new base::MemoryMappedFile); 62 bdict_file_.reset(new base::MemoryMappedFile);
63 63
64 if (bdict_file_->Initialize(file_)) { 64 // TODO(rvargas): This object should not keep file_ after passing it to
65 // bdict_file_.
66 if (bdict_file_->Initialize(base::File(file_))) {
65 TimeTicks debug_start_time = base::Histogram::DebugNow(); 67 TimeTicks debug_start_time = base::Histogram::DebugNow();
66 68
67 hunspell_.reset( 69 hunspell_.reset(
68 new Hunspell(bdict_file_->data(), bdict_file_->length())); 70 new Hunspell(bdict_file_->data(), bdict_file_->length()));
69 71
70 DHISTOGRAM_TIMES("Spellcheck.InitTime", 72 DHISTOGRAM_TIMES("Spellcheck.InitTime",
71 base::Histogram::DebugNow() - debug_start_time); 73 base::Histogram::DebugNow() - debug_start_time);
72 } else { 74 } else {
73 NOTREACHED() << "Could not mmap spellchecker dictionary."; 75 NOTREACHED() << "Could not mmap spellchecker dictionary.";
74 } 76 }
(...skipping 59 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_ != base::kInvalidPlatformFileValue) 137 if (file_ != base::kInvalidPlatformFileValue)
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 file_ != base::kInvalidPlatformFileValue; 144 return file_ != base::kInvalidPlatformFileValue;
143 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698