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

Unified Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary.h

Issue 11414282: Improve reliability of custom spelling dictionary file. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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
Index: chrome/browser/spellchecker/spellcheck_custom_dictionary.h
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.h b/chrome/browser/spellchecker/spellcheck_custom_dictionary.h
index b1d6045f1db0231c841c7e57c7738cf5b490a0c7..264ef8df6979eda1767cfe9e98da2d4c835cdeec 100644
--- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.h
+++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.h
@@ -11,6 +11,7 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/observer_list.h"
#include "chrome/browser/spellchecker/spellcheck_dictionary.h"
#include "chrome/common/spellcheck_common.h"
@@ -75,6 +76,19 @@ class SpellcheckCustomDictionary : public SpellcheckDictionary {
void SetCustomWordListAndDelete(
chrome::spellcheck_common::WordList* custom_words);
+ // Loads the dictionary file into |contents|. If the dictionary checksum is
+ // not valid, but backup checksum is valid, then restores the backup and loads
+ // that into |contents| instead.
+ void LoadDictionaryContentsReliably(std::string* contents);
groby-ooo-7-16 2012/12/04 00:16:30 We should probably document somewhere that we expe
please use gerrit instead 2012/12/04 05:46:40 Where is the best place to document this? Class co
+
+ // Backs up the original dictionary and checksum files, saves |contents| into
+ // the dictionary file, and saves the checksum of |contents| into the checksum
+ // file.
groby-ooo-7-16 2012/12/04 00:16:30 I'd feel more comfortable having the checksum in t
please use gerrit instead 2012/12/04 05:46:40 Done.
+ void SaveDictionryContentsReliably(const std::string& contents);
groby-ooo-7-16 2012/12/04 00:16:30 Spelling: Diction_a_ry (Hey, y u no spellcheck! ;)
please use gerrit instead 2012/12/04 05:46:40 Done.
+
+ // Extract the |checksum| out of |contents|.
+ std::string GetChecksum(std::string* contents);
groby-ooo-7-16 2012/12/04 00:16:30 const std::string& contents - it's not an out para
please use gerrit instead 2012/12/04 05:46:40 Added a comment to clarify: "If this method return
+
// In-memory cache of the custom words file.
chrome::spellcheck_common::WordList words_;
@@ -83,7 +97,10 @@ class SpellcheckCustomDictionary : public SpellcheckDictionary {
base::WeakPtrFactory<SpellcheckCustomDictionary> weak_ptr_factory_;
- std::vector<Observer*> observers_;
+ ObserverList<Observer> observers_;
+
+ const FilePath::StringType backup_extension_;
+ const std::string checksum_prefix_;
DISALLOW_COPY_AND_ASSIGN(SpellcheckCustomDictionary);
};

Powered by Google App Engine
This is Rietveld 408576698