| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 hunspell_enabled_ = file_.IsValid(); | 55 hunspell_enabled_ = file_.IsValid(); |
| 56 // Delay the actual initialization of hunspell until it is needed. | 56 // Delay the actual initialization of hunspell until it is needed. |
| 57 } | 57 } |
| 58 | 58 |
| 59 void HunspellEngine::InitializeHunspell() { | 59 void HunspellEngine::InitializeHunspell() { |
| 60 if (hunspell_.get()) | 60 if (hunspell_.get()) |
| 61 return; | 61 return; |
| 62 | 62 |
| 63 bdict_file_.reset(new base::MemoryMappedFile); | 63 bdict_file_.reset(new base::MemoryMappedFile); |
| 64 | 64 |
| 65 if (bdict_file_->Initialize(file_.Pass())) { | 65 if (bdict_file_->Initialize(file_.Pass(), false)) { |
| 66 TimeTicks debug_start_time = base::Histogram::DebugNow(); | 66 TimeTicks debug_start_time = base::Histogram::DebugNow(); |
| 67 | 67 |
| 68 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length())); | 68 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length())); |
| 69 | 69 |
| 70 DHISTOGRAM_TIMES("Spellcheck.InitTime", | 70 DHISTOGRAM_TIMES("Spellcheck.InitTime", |
| 71 base::Histogram::DebugNow() - debug_start_time); | 71 base::Histogram::DebugNow() - debug_start_time); |
| 72 } else { | 72 } else { |
| 73 NOTREACHED() << "Could not mmap spellchecker dictionary."; | 73 NOTREACHED() << "Could not mmap spellchecker dictionary."; |
| 74 } | 74 } |
| 75 } | 75 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Don't initialize if hunspell is disabled. | 134 // Don't initialize if hunspell is disabled. |
| 135 if (file_.IsValid()) | 135 if (file_.IsValid()) |
| 136 InitializeHunspell(); | 136 InitializeHunspell(); |
| 137 | 137 |
| 138 return !initialized_; | 138 return !initialized_; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool HunspellEngine::IsEnabled() { | 141 bool HunspellEngine::IsEnabled() { |
| 142 return hunspell_enabled_; | 142 return hunspell_enabled_; |
| 143 } | 143 } |
| OLD | NEW |