OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <io.h> | 5 #include <io.h> |
6 | 6 |
7 #include "chrome/browser/spellchecker.h" | 7 #include "chrome/browser/spellchecker.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 | 423 |
424 if (!dic_exists && !tried_to_download_) { | 424 if (!dic_exists && !tried_to_download_) { |
425 tried_to_download_ = true; | 425 tried_to_download_ = true; |
426 return false; | 426 return false; |
427 } | 427 } |
428 | 428 |
429 // Control has come so far - both files probably exist. | 429 // Control has come so far - both files probably exist. |
430 TimeTicks begin_time = TimeTicks::Now(); | 430 TimeTicks begin_time = TimeTicks::Now(); |
431 bdict_file_.reset(new file_util::MemoryMappedFile()); | 431 bdict_file_.reset(new file_util::MemoryMappedFile()); |
432 if (bdict_file_->Initialize(FilePath::FromWStringHack(bdict_file_name_))) { | 432 if (bdict_file_->Initialize(FilePath::FromWStringHack(bdict_file_name_))) { |
433 hunspell_.reset(new Hunspell(bdict_file_->Data(), bdict_file_->Length())); | 433 hunspell_.reset(new Hunspell(bdict_file_->data(), bdict_file_->length())); |
434 AddCustomWordsToHunspell(); | 434 AddCustomWordsToHunspell(); |
435 } | 435 } |
436 DHISTOGRAM_TIMES(L"Spellcheck.InitTime", TimeTicks::Now() - begin_time); | 436 DHISTOGRAM_TIMES(L"Spellcheck.InitTime", TimeTicks::Now() - begin_time); |
437 | 437 |
438 tried_to_init_ = true; | 438 tried_to_init_ = true; |
439 return false; | 439 return false; |
440 } | 440 } |
441 | 441 |
442 void SpellChecker::AddCustomWordsToHunspell() { | 442 void SpellChecker::AddCustomWordsToHunspell() { |
443 // Add custom words to Hunspell. | 443 // Add custom words to Hunspell. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 hunspell_->put_word(word_to_add.c_str()); | 589 hunspell_->put_word(word_to_add.c_str()); |
590 | 590 |
591 // Now add the word to the custom dictionary file. | 591 // Now add the word to the custom dictionary file. |
592 Task* write_word_task = | 592 Task* write_word_task = |
593 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); | 593 new AddWordToCustomDictionaryTask(custom_dictionary_file_name_, word); |
594 if (file_loop_) | 594 if (file_loop_) |
595 file_loop_->PostTask(FROM_HERE, write_word_task); | 595 file_loop_->PostTask(FROM_HERE, write_word_task); |
596 else | 596 else |
597 write_word_task->Run(); | 597 write_word_task->Run(); |
598 } | 598 } |
OLD | NEW |