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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary.cc

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/spellchecker/spellcheck_custom_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/important_file_writer.h" 10 #include "base/files/important_file_writer.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // is invalid too, then clears |custom_words|. Must be called on the file 89 // is invalid too, then clears |custom_words|. Must be called on the file
90 // thread. 90 // thread.
91 void LoadDictionaryFileReliably(WordList& custom_words, 91 void LoadDictionaryFileReliably(WordList& custom_words,
92 const base::FilePath& path) { 92 const base::FilePath& path) {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
94 // Load the contents and verify the checksum. 94 // Load the contents and verify the checksum.
95 if (LoadFile(path, custom_words) == VALID_CHECKSUM) 95 if (LoadFile(path, custom_words) == VALID_CHECKSUM)
96 return; 96 return;
97 // Checksum is not valid. See if there's a backup. 97 // Checksum is not valid. See if there's a backup.
98 base::FilePath backup = path.AddExtension(BACKUP_EXTENSION); 98 base::FilePath backup = path.AddExtension(BACKUP_EXTENSION);
99 if (!file_util::PathExists(backup)) 99 if (!base::PathExists(backup))
100 return; 100 return;
101 // Load the backup and verify its checksum. 101 // Load the backup and verify its checksum.
102 if (LoadFile(backup, custom_words) != VALID_CHECKSUM) 102 if (LoadFile(backup, custom_words) != VALID_CHECKSUM)
103 return; 103 return;
104 // Backup checksum is valid. Restore the backup. 104 // Backup checksum is valid. Restore the backup.
105 base::CopyFile(backup, path); 105 base::CopyFile(backup, path);
106 } 106 }
107 107
108 // Backs up the original dictionary, saves |custom_words| and its checksum into 108 // Backs up the original dictionary, saves |custom_words| and its checksum into
109 // the custom spellcheck dictionary at |path|. 109 // the custom spellcheck dictionary at |path|.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 542
543 void SpellcheckCustomDictionary::Notify( 543 void SpellcheckCustomDictionary::Notify(
544 const SpellcheckCustomDictionary::Change& dictionary_change) { 544 const SpellcheckCustomDictionary::Change& dictionary_change) {
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
546 if (!IsLoaded() || dictionary_change.empty()) 546 if (!IsLoaded() || dictionary_change.empty())
547 return; 547 return;
548 FOR_EACH_OBSERVER(Observer, 548 FOR_EACH_OBSERVER(Observer,
549 observers_, 549 observers_,
550 OnCustomDictionaryChanged(dictionary_change)); 550 OnCustomDictionaryChanged(dictionary_change));
551 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_win.cc ('k') | chrome/browser/spellchecker/spellcheck_hunspell_dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698