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

Unified Diff: base/files/file_util_proxy.cc

Issue 183003009: Handle errors properly in FileUtilProxy::CreateTemporary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_proxy.cc
diff --git a/base/files/file_util_proxy.cc b/base/files/file_util_proxy.cc
index 141e4e10606189969d8c27e5eac6d915d8e1e0fc..447552ddaf0384e21f97ab72e55ffaea79bbe56b 100644
--- a/base/files/file_util_proxy.cc
+++ b/base/files/file_util_proxy.cc
@@ -77,7 +77,12 @@ class CreateTemporaryHelper {
void RunWork(int additional_file_flags) {
// TODO(darin): file_util should have a variant of CreateTemporaryFile
// that returns a FilePath and a PlatformFile.
- base::CreateTemporaryFile(&file_path_);
+ if (!base::CreateTemporaryFile(&file_path_)) {
+ // TODO(davidben): base::CreateTemporaryFile should preserve the error
+ // code.
+ error_ = File::FILE_ERROR_FAILED;
+ return;
+ }
int file_flags =
PLATFORM_FILE_WRITE |
@@ -90,6 +95,10 @@ class CreateTemporaryHelper {
file_handle_ =
CreatePlatformFile(file_path_, file_flags, NULL,
reinterpret_cast<PlatformFileError*>(&error_));
+ if (error_ != File::FILE_OK) {
+ base::DeleteFile(file_path_, false);
+ file_path_.clear();
+ }
}
void Reply(const FileUtilProxy::CreateTemporaryCallback& callback) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698