Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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_. | |
|
groby-ooo-7-16
2013/12/27 19:52:26
If you want to address the TODO: file_, bdict_file
| |
| 66 if (bdict_file_->Initialize(base::File(file_))) { | |
|
groby-ooo-7-16
2013/12/27 19:52:26
Probably want file_ to be base::File, for clearer
rvargas (doing something else)
2013/12/27 23:54:39
That sounds correct. I didn't do it because it pro
| |
| 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 Loading... | |
| 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 } |
| OLD | NEW |