| OLD | NEW |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::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 (!base::ReplaceFile(tmp_file_path, path, NULL)) { |
| 88 LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); | 88 LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); |
| 89 base::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) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |