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

Unified Diff: chrome/renderer/spellchecker/hunspell_engine.cc

Issue 209193002: Remove PlatformFile from spell checker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert IsEnabled behavior Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/spellchecker/hunspell_engine.h ('k') | chrome/renderer/spellchecker/spellcheck.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/hunspell_engine.cc
diff --git a/chrome/renderer/spellchecker/hunspell_engine.cc b/chrome/renderer/spellchecker/hunspell_engine.cc
index c2cdd29f560f2567965120a686c6fe39cb09900e..f8071efc69d4823d4c67a3a15086af8662771c10 100644
--- a/chrome/renderer/spellchecker/hunspell_engine.cc
+++ b/chrome/renderer/spellchecker/hunspell_engine.cc
@@ -29,7 +29,7 @@ namespace {
COMPILE_ASSERT(kMaxCheckedLen <= size_t(MAXWORDLEN), MaxCheckedLen_too_long);
COMPILE_ASSERT(kMaxSuggestLen <= kMaxCheckedLen, MaxSuggestLen_too_long);
-}
+} // namespace
#if !defined(OS_MACOSX)
SpellingEngine* CreateNativeSpellingEngine() {
@@ -38,7 +38,7 @@ SpellingEngine* CreateNativeSpellingEngine() {
#endif
HunspellEngine::HunspellEngine()
- : file_(base::kInvalidPlatformFileValue),
+ : hunspell_enabled_(false),
initialized_(false),
dictionary_requested_(false) {
// Wait till we check the first word before doing any initializing.
@@ -47,11 +47,12 @@ HunspellEngine::HunspellEngine()
HunspellEngine::~HunspellEngine() {
}
-void HunspellEngine::Init(base::PlatformFile file) {
+void HunspellEngine::Init(base::File file) {
initialized_ = true;
hunspell_.reset();
bdict_file_.reset();
- file_ = file;
+ file_ = file.Pass();
+ hunspell_enabled_ = file_.IsValid();
// Delay the actual initialization of hunspell until it is needed.
}
@@ -61,13 +62,10 @@ void HunspellEngine::InitializeHunspell() {
bdict_file_.reset(new base::MemoryMappedFile);
- // TODO(rvargas): This object should not keep file_ after passing it to
- // bdict_file_.
- if (bdict_file_->Initialize(base::File(file_))) {
+ if (bdict_file_->Initialize(file_.Pass())) {
TimeTicks debug_start_time = base::Histogram::DebugNow();
- hunspell_.reset(
- new Hunspell(bdict_file_->data(), bdict_file_->length()));
+ hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length()));
DHISTOGRAM_TIMES("Spellcheck.InitTime",
base::Histogram::DebugNow() - debug_start_time);
@@ -134,12 +132,12 @@ bool HunspellEngine::InitializeIfNeeded() {
}
// Don't initialize if hunspell is disabled.
- if (file_ != base::kInvalidPlatformFileValue)
+ if (file_.IsValid())
InitializeHunspell();
return !initialized_;
}
bool HunspellEngine::IsEnabled() {
- return file_ != base::kInvalidPlatformFileValue;
+ return hunspell_enabled_;
}
« 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