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

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

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DETECTED_MISSING_WORDS = 4, 53 DETECTED_MISSING_WORDS = 4,
54 }; 54 };
55 55
56 // Loads the file at |file_path| into the |words| container. If the file has a 56 // Loads the file at |file_path| into the |words| container. If the file has a
57 // valid checksum, then returns ChecksumStatus::VALID. If the file has an 57 // valid checksum, then returns ChecksumStatus::VALID. If the file has an
58 // invalid checksum, then returns ChecksumStatus::INVALID and clears |words|. 58 // invalid checksum, then returns ChecksumStatus::INVALID and clears |words|.
59 ChecksumStatus LoadFile(const base::FilePath& file_path, WordList& words) { 59 ChecksumStatus LoadFile(const base::FilePath& file_path, WordList& words) {
60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
61 words.clear(); 61 words.clear();
62 std::string contents; 62 std::string contents;
63 file_util::ReadFileToString(file_path, &contents); 63 base::ReadFileToString(file_path, &contents);
64 size_t pos = contents.rfind(CHECKSUM_PREFIX); 64 size_t pos = contents.rfind(CHECKSUM_PREFIX);
65 if (pos != std::string::npos) { 65 if (pos != std::string::npos) {
66 std::string checksum = contents.substr(pos + strlen(CHECKSUM_PREFIX)); 66 std::string checksum = contents.substr(pos + strlen(CHECKSUM_PREFIX));
67 contents = contents.substr(0, pos); 67 contents = contents.substr(0, pos);
68 if (checksum != base::MD5String(contents)) 68 if (checksum != base::MD5String(contents))
69 return INVALID_CHECKSUM; 69 return INVALID_CHECKSUM;
70 } 70 }
71 TrimWhitespaceASCII(contents, TRIM_ALL, &contents); 71 TrimWhitespaceASCII(contents, TRIM_ALL, &contents);
72 base::SplitString(contents, '\n', &words); 72 base::SplitString(contents, '\n', &words);
73 return VALID_CHECKSUM; 73 return VALID_CHECKSUM;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 void SpellcheckCustomDictionary::Notify( 531 void SpellcheckCustomDictionary::Notify(
532 const SpellcheckCustomDictionary::Change& dictionary_change) { 532 const SpellcheckCustomDictionary::Change& dictionary_change) {
533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 533 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
534 if (!IsLoaded() || dictionary_change.empty()) 534 if (!IsLoaded() || dictionary_change.empty())
535 return; 535 return;
536 FOR_EACH_OBSERVER(Observer, 536 FOR_EACH_OBSERVER(Observer,
537 observers_, 537 observers_,
538 OnCustomDictionaryChanged(dictionary_change)); 538 OnCustomDictionaryChanged(dictionary_change));
539 } 539 }
OLDNEW
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698