| 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 CreateFileStream(); | 503 CreateFileStream(); |
| 504 file_stream_->EnableErrorStatistics(); | 504 file_stream_->EnableErrorStatistics(); |
| 505 int open_result = file_stream_->OpenSync( | 505 int open_result = file_stream_->OpenSync( |
| 506 full_path_, | 506 full_path_, |
| 507 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE); | 507 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE); |
| 508 if (open_result != net::OK) | 508 if (open_result != net::OK) |
| 509 return ClearStream(LOG_ERROR("Open", open_result)); | 509 return ClearStream(LOG_ERROR("Open", open_result)); |
| 510 | 510 |
| 511 // We may be re-opening the file after rename. Always make sure we're | 511 // We may be re-opening the file after rename. Always make sure we're |
| 512 // writing at the end of the file. | 512 // writing at the end of the file. |
| 513 int64 seek_result = file_stream_->Seek(net::FROM_END, 0); | 513 int64 seek_result = file_stream_->SeekSync(net::FROM_END, 0); |
| 514 if (seek_result < 0) | 514 if (seek_result < 0) |
| 515 return ClearStream(LOG_ERROR("Seek", seek_result)); | 515 return ClearStream(LOG_ERROR("Seek", seek_result)); |
| 516 } else { | 516 } else { |
| 517 file_stream_->SetBoundNetLogSource(bound_net_log_); | 517 file_stream_->SetBoundNetLogSource(bound_net_log_); |
| 518 } | 518 } |
| 519 | 519 |
| 520 #if defined(OS_WIN) | 520 #if defined(OS_WIN) |
| 521 AnnotateWithSourceInformation(); | 521 AnnotateWithSourceInformation(); |
| 522 #endif | 522 #endif |
| 523 | 523 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { | 562 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { |
| 563 base::TimeDelta diff = current_time - start_tick_; | 563 base::TimeDelta diff = current_time - start_tick_; |
| 564 int64 diff_ms = diff.InMilliseconds(); | 564 int64 diff_ms = diff.InMilliseconds(); |
| 565 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; | 565 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; |
| 566 } | 566 } |
| 567 | 567 |
| 568 int64 BaseFile::CurrentSpeed() const { | 568 int64 BaseFile::CurrentSpeed() const { |
| 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 570 return CurrentSpeedAtTime(base::TimeTicks::Now()); | 570 return CurrentSpeedAtTime(base::TimeTicks::Now()); |
| 571 } | 571 } |
| OLD | NEW |