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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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_hunspell_dictionary.h" 5 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/memory_mapped_file.h" 8 #include "base/files/memory_mapped_file.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return OpenDictionaryFile(file.Pass()); 126 return OpenDictionaryFile(file.Pass());
127 } 127 }
128 128
129 // Saves |data| to file at |path|. Returns true on successful save, otherwise 129 // Saves |data| to file at |path|. Returns true on successful save, otherwise
130 // returns false. 130 // returns false.
131 bool SaveDictionaryData(scoped_ptr<std::string> data, 131 bool SaveDictionaryData(scoped_ptr<std::string> data,
132 const base::FilePath& path) { 132 const base::FilePath& path) {
133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 133 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
134 134
135 size_t bytes_written = 135 size_t bytes_written =
136 file_util::WriteFile(path, data->data(), data->length()); 136 base::WriteFile(path, data->data(), data->length());
137 if (bytes_written != data->length()) { 137 if (bytes_written != data->length()) {
138 bool success = false; 138 bool success = false;
139 #if defined(OS_WIN) 139 #if defined(OS_WIN)
140 base::FilePath dict_dir; 140 base::FilePath dict_dir;
141 PathService::Get(chrome::DIR_USER_DATA, &dict_dir); 141 PathService::Get(chrome::DIR_USER_DATA, &dict_dir);
142 base::FilePath fallback_file_path = 142 base::FilePath fallback_file_path =
143 dict_dir.Append(path.BaseName()); 143 dict_dir.Append(path.BaseName());
144 bytes_written = 144 bytes_written =
145 file_util::WriteFile(fallback_file_path, data->data(), data->length()); 145 base::WriteFile(fallback_file_path, data->data(), data->length());
146 if (bytes_written == data->length()) 146 if (bytes_written == data->length())
147 success = true; 147 success = true;
148 #endif 148 #endif
149 149
150 if (!success) { 150 if (!success) {
151 base::DeleteFile(path, false); 151 base::DeleteFile(path, false);
152 return false; 152 return false;
153 } 153 }
154 } 154 }
155 155
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void SpellcheckHunspellDictionary::InformListenersOfInitialization() { 355 void SpellcheckHunspellDictionary::InformListenersOfInitialization() {
356 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized()); 356 FOR_EACH_OBSERVER(Observer, observers_, OnHunspellDictionaryInitialized());
357 } 357 }
358 358
359 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() { 359 void SpellcheckHunspellDictionary::InformListenersOfDownloadFailure() {
360 download_status_ = DOWNLOAD_FAILED; 360 download_status_ = DOWNLOAD_FAILED;
361 FOR_EACH_OBSERVER(Observer, 361 FOR_EACH_OBSERVER(Observer,
362 observers_, 362 observers_,
363 OnHunspellDictionaryDownloadFailure()); 363 OnHunspellDictionaryDownloadFailure());
364 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698