| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/url_request/url_fetcher_response_writer.h" | 5 #include "net/url_request/url_fetcher_response_writer.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/task_runner.h" | 9 #include "base/task_runner.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 owns_file_ = false; | 123 owns_file_ = false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void URLFetcherFileWriter::CloseAndDeleteFile() { | 126 void URLFetcherFileWriter::CloseAndDeleteFile() { |
| 127 if (!owns_file_) | 127 if (!owns_file_) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 file_stream_.reset(); | 130 file_stream_.reset(); |
| 131 DisownFile(); | 131 DisownFile(); |
| 132 file_task_runner_->PostTask(FROM_HERE, | 132 file_task_runner_->PostTask(FROM_HERE, |
| 133 base::Bind(base::IgnoreResult(&base::Delete), | 133 base::Bind(base::IgnoreResult(&base::DeleteFile), |
| 134 file_path_, | 134 file_path_, |
| 135 false /* recursive */)); | 135 false /* recursive */)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void URLFetcherFileWriter::DidCreateTempFile(const CompletionCallback& callback, | 138 void URLFetcherFileWriter::DidCreateTempFile(const CompletionCallback& callback, |
| 139 base::FilePath* temp_file_path, | 139 base::FilePath* temp_file_path, |
| 140 bool success) { | 140 bool success) { |
| 141 if (!success) { | 141 if (!success) { |
| 142 error_code_ = ERR_FILE_NOT_FOUND; | 142 error_code_ = ERR_FILE_NOT_FOUND; |
| 143 callback.Run(error_code_); | 143 callback.Run(error_code_); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 162 total_bytes_written_ = 0; | 162 total_bytes_written_ = 0; |
| 163 owns_file_ = true; | 163 owns_file_ = true; |
| 164 } else { | 164 } else { |
| 165 error_code_ = result; | 165 error_code_ = result; |
| 166 CloseAndDeleteFile(); | 166 CloseAndDeleteFile(); |
| 167 } | 167 } |
| 168 callback.Run(result); | 168 callback.Run(result); |
| 169 } | 169 } |
| 170 | 170 |
| 171 } // namespace net | 171 } // namespace net |
| OLD | NEW |