| 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/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/profiler/scoped_profile.h" |
| 9 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 10 #include "base/task_runner_util.h" | 11 #include "base/task_runner_util.h" |
| 11 #include "net/base/file_stream.h" | 12 #include "net/base/file_stream.h" |
| 12 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 13 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 URLFetcherStringWriter* URLFetcherResponseWriter::AsStringWriter() { | 18 URLFetcherStringWriter* URLFetcherResponseWriter::AsStringWriter() { |
| 18 return NULL; | 19 return NULL; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 base::File::FLAG_OPEN, | 167 base::File::FLAG_OPEN, |
| 167 base::Bind(&URLFetcherFileWriter::DidOpenFile, | 168 base::Bind(&URLFetcherFileWriter::DidOpenFile, |
| 168 weak_factory_.GetWeakPtr(), | 169 weak_factory_.GetWeakPtr(), |
| 169 callback)); | 170 callback)); |
| 170 if (result != ERR_IO_PENDING) | 171 if (result != ERR_IO_PENDING) |
| 171 DidOpenFile(callback, result); | 172 DidOpenFile(callback, result); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void URLFetcherFileWriter::DidOpenFile(const CompletionCallback& callback, | 175 void URLFetcherFileWriter::DidOpenFile(const CompletionCallback& callback, |
| 175 int result) { | 176 int result) { |
| 177 // TODO(vadimt): Remove ScopedProfile below once crbug.com/423948 is fixed. |
| 178 tracked_objects::ScopedProfile tracking_profile( |
| 179 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 180 "423948 URLFetcherFileWriter::DidOpenFile")); |
| 181 |
| 176 if (result == OK) | 182 if (result == OK) |
| 177 owns_file_ = true; | 183 owns_file_ = true; |
| 178 else | 184 else |
| 179 CloseAndDeleteFile(); | 185 CloseAndDeleteFile(); |
| 180 | 186 |
| 181 callback.Run(result); | 187 callback.Run(result); |
| 182 } | 188 } |
| 183 | 189 |
| 184 void URLFetcherFileWriter::CloseComplete(const CompletionCallback& callback, | 190 void URLFetcherFileWriter::CloseComplete(const CompletionCallback& callback, |
| 185 int result) { | 191 int result) { |
| 186 // Destroy |file_stream_| whether or not the close succeeded. | 192 // Destroy |file_stream_| whether or not the close succeeded. |
| 187 file_stream_.reset(); | 193 file_stream_.reset(); |
| 188 callback.Run(result); | 194 callback.Run(result); |
| 189 } | 195 } |
| 190 | 196 |
| 191 } // namespace net | 197 } // namespace net |
| OLD | NEW |