Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 weak_factory_.GetWeakPtr(), | 95 weak_factory_.GetWeakPtr(), |
| 96 callback)); | 96 callback)); |
| 97 if (result < 0 && result != ERR_IO_PENDING) { | 97 if (result < 0 && result != ERR_IO_PENDING) { |
| 98 error_code_ = result; | 98 error_code_ = result; |
| 99 CloseAndDeleteFile(); | 99 CloseAndDeleteFile(); |
| 100 } | 100 } |
| 101 return result; | 101 return result; |
| 102 } | 102 } |
| 103 | 103 |
| 104 int URLFetcherFileWriter::Finish(const CompletionCallback& callback) { | 104 int URLFetcherFileWriter::Finish(const CompletionCallback& callback) { |
| 105 int result = file_stream_->Close(base::Bind( | |
| 106 &URLFetcherFileWriter::CloseComplete, base::Unretained(this), callback)); | |
| 107 if (result != ERR_IO_PENDING) { | |
|
Sorin Jianu
2013/09/05 19:59:12
Remove the full bracing for the if statement, per
waffles
2013/09/05 20:31:52
Done.
| |
| 108 file_stream_.reset(); | |
| 109 } | |
| 110 return result; | |
| 111 } | |
| 112 | |
| 113 void URLFetcherFileWriter::CloseComplete(const CompletionCallback& callback, | |
| 114 int result) { | |
| 115 // Either we closed the file or we can't; either way destroy the file_stream. | |
| 105 file_stream_.reset(); | 116 file_stream_.reset(); |
| 106 return OK; | 117 callback.Run(result); |
| 107 } | 118 } |
| 108 | 119 |
| 109 void URLFetcherFileWriter::DidWrite(const CompletionCallback& callback, | 120 void URLFetcherFileWriter::DidWrite(const CompletionCallback& callback, |
| 110 int result) { | 121 int result) { |
| 111 if (result < 0) { | 122 if (result < 0) { |
| 112 error_code_ = result; | 123 error_code_ = result; |
| 113 CloseAndDeleteFile(); | 124 CloseAndDeleteFile(); |
| 114 } | 125 } |
| 115 callback.Run(result); | 126 callback.Run(result); |
| 116 } | 127 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 total_bytes_written_ = 0; | 173 total_bytes_written_ = 0; |
| 163 owns_file_ = true; | 174 owns_file_ = true; |
| 164 } else { | 175 } else { |
| 165 error_code_ = result; | 176 error_code_ = result; |
| 166 CloseAndDeleteFile(); | 177 CloseAndDeleteFile(); |
| 167 } | 178 } |
| 168 callback.Run(result); | 179 callback.Run(result); |
| 169 } | 180 } |
| 170 | 181 |
| 171 } // namespace net | 182 } // namespace net |
| OLD | NEW |