OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/download/base_file.h" | 5 #include "content/browser/download/base_file.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
304 | 304 |
305 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED); | 305 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_CLOSED); |
306 | 306 |
307 if (file_stream_.get()) { | 307 if (file_stream_.get()) { |
308 #if defined(OS_CHROMEOS) | 308 #if defined(OS_CHROMEOS) |
309 // Currently we don't really care about the return value, since if it fails | 309 // Currently we don't really care about the return value, since if it fails |
310 // theres not much we can do. But we might in the future. | 310 // theres not much we can do. But we might in the future. |
311 file_stream_->FlushSync(); | 311 file_stream_->FlushSync(); |
312 #endif | 312 #endif |
313 file_stream_->CloseSync(); | |
314 ClearStream(); | 313 ClearStream(); |
315 } | 314 } |
316 } | 315 } |
317 | 316 |
318 void BaseFile::ClearStream() { | 317 void BaseFile::ClearStream() { |
319 // This should only be called when we have a stream. | 318 // This should only be called when we have a stream. |
320 DCHECK(file_stream_.get() != NULL); | 319 DCHECK(file_stream_.get() != NULL); |
321 file_stream_.reset(); | 320 file_stream_.reset(); |
322 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_OPENED); | 321 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_FILE_OPENED); |
323 } | 322 } |
(...skipping 28 matching lines...) Expand all Loading... |
352 const char* operation, | 351 const char* operation, |
353 int os_error, | 352 int os_error, |
354 DownloadInterruptReason reason) { | 353 DownloadInterruptReason reason) { |
355 bound_net_log_.AddEvent( | 354 bound_net_log_.AddEvent( |
356 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 355 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, |
357 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 356 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); |
358 return reason; | 357 return reason; |
359 } | 358 } |
360 | 359 |
361 } // namespace content | 360 } // namespace content |
OLD | NEW |