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

Side by Side Diff: base/files/important_file_writer.cc

Issue 16950028: Move file_util::Delete to the 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
« no previous file with comments | « base/files/file_util_proxy_unittest.cc ('k') | base/files/scoped_temp_dir.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/files/important_file_writer.h" 5 #include "base/files/important_file_writer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 // If this happens in the wild something really bad is going on. 68 // If this happens in the wild something really bad is going on.
69 CHECK_LE(data.length(), static_cast<size_t>(kint32max)); 69 CHECK_LE(data.length(), static_cast<size_t>(kint32max));
70 int bytes_written = WritePlatformFile( 70 int bytes_written = WritePlatformFile(
71 tmp_file, 0, data.data(), static_cast<int>(data.length())); 71 tmp_file, 0, data.data(), static_cast<int>(data.length()));
72 FlushPlatformFile(tmp_file); // Ignore return value. 72 FlushPlatformFile(tmp_file); // Ignore return value.
73 73
74 if (!ClosePlatformFile(tmp_file)) { 74 if (!ClosePlatformFile(tmp_file)) {
75 LogFailure(path, FAILED_CLOSING, "failed to close temporary file"); 75 LogFailure(path, FAILED_CLOSING, "failed to close temporary file");
76 file_util::Delete(tmp_file_path, false); 76 base::Delete(tmp_file_path, false);
77 return false; 77 return false;
78 } 78 }
79 79
80 if (bytes_written < static_cast<int>(data.length())) { 80 if (bytes_written < static_cast<int>(data.length())) {
81 LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" + 81 LogFailure(path, FAILED_WRITING, "error writing, bytes_written=" +
82 IntToString(bytes_written)); 82 IntToString(bytes_written));
83 file_util::Delete(tmp_file_path, false); 83 base::Delete(tmp_file_path, false);
84 return false; 84 return false;
85 } 85 }
86 86
87 if (!file_util::ReplaceFile(tmp_file_path, path)) { 87 if (!file_util::ReplaceFile(tmp_file_path, path)) {
88 LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); 88 LogFailure(path, FAILED_RENAMING, "could not rename temporary file");
89 file_util::Delete(tmp_file_path, false); 89 base::Delete(tmp_file_path, false);
90 return false; 90 return false;
91 } 91 }
92 92
93 return true; 93 return true;
94 } 94 }
95 95
96 ImportantFileWriter::ImportantFileWriter( 96 ImportantFileWriter::ImportantFileWriter(
97 const FilePath& path, base::SequencedTaskRunner* task_runner) 97 const FilePath& path, base::SequencedTaskRunner* task_runner)
98 : path_(path), 98 : path_(path),
99 task_runner_(task_runner), 99 task_runner_(task_runner),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (serializer_->SerializeData(&data)) { 158 if (serializer_->SerializeData(&data)) {
159 WriteNow(data); 159 WriteNow(data);
160 } else { 160 } else {
161 DLOG(WARNING) << "failed to serialize data to be saved in " 161 DLOG(WARNING) << "failed to serialize data to be saved in "
162 << path_.value().c_str(); 162 << path_.value().c_str();
163 } 163 }
164 serializer_ = NULL; 164 serializer_ = NULL;
165 } 165 }
166 166
167 } // namespace base 167 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_proxy_unittest.cc ('k') | base/files/scoped_temp_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698