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