| 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/download_file_impl.h" | 5 #include "content/browser/download/download_file_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "content/browser/byte_stream.h" | 15 #include "content/browser/byte_stream.h" |
| 15 #include "content/browser/download/download_create_info.h" | 16 #include "content/browser/download/download_create_info.h" |
| 16 #include "content/browser/download/download_interrupt_reasons_impl.h" | 17 #include "content/browser/download/download_interrupt_reasons_impl.h" |
| 17 #include "content/browser/download/download_net_log_parameters.h" | 18 #include "content/browser/download/download_net_log_parameters.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 41 bool calculate_hash, | 42 bool calculate_hash, |
| 42 scoped_ptr<ByteStreamReader> stream, | 43 scoped_ptr<ByteStreamReader> stream, |
| 43 const net::BoundNetLog& bound_net_log, | 44 const net::BoundNetLog& bound_net_log, |
| 44 base::WeakPtr<DownloadDestinationObserver> observer) | 45 base::WeakPtr<DownloadDestinationObserver> observer) |
| 45 : file_(save_info->file_path, | 46 : file_(save_info->file_path, |
| 46 url, | 47 url, |
| 47 referrer_url, | 48 referrer_url, |
| 48 save_info->offset, | 49 save_info->offset, |
| 49 calculate_hash, | 50 calculate_hash, |
| 50 save_info->hash_state, | 51 save_info->hash_state, |
| 51 save_info->file.Pass(), | 52 std::move(save_info->file), |
| 52 bound_net_log), | 53 bound_net_log), |
| 53 default_download_directory_(default_download_directory), | 54 default_download_directory_(default_download_directory), |
| 54 stream_reader_(stream.Pass()), | 55 stream_reader_(std::move(stream)), |
| 55 bytes_seen_(0), | 56 bytes_seen_(0), |
| 56 bound_net_log_(bound_net_log), | 57 bound_net_log_(bound_net_log), |
| 57 observer_(observer), | 58 observer_(observer), |
| 58 weak_factory_(this) { | 59 weak_factory_(this) {} |
| 59 } | |
| 60 | 60 |
| 61 DownloadFileImpl::~DownloadFileImpl() { | 61 DownloadFileImpl::~DownloadFileImpl() { |
| 62 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 62 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 63 --number_active_objects_; | 63 --number_active_objects_; |
| 64 } | 64 } |
| 65 | 65 |
| 66 void DownloadFileImpl::Initialize(const InitializeCallback& callback) { | 66 void DownloadFileImpl::Initialize(const InitializeCallback& callback) { |
| 67 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 67 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 68 | 68 |
| 69 update_timer_.reset(new base::RepeatingTimer()); | 69 update_timer_.reset(new base::RepeatingTimer()); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 observer_, file_.bytes_so_far(), CurrentSpeed(), | 352 observer_, file_.bytes_so_far(), CurrentSpeed(), |
| 353 GetHashState())); | 353 GetHashState())); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // static | 356 // static |
| 357 int DownloadFile::GetNumberOfDownloadFiles() { | 357 int DownloadFile::GetNumberOfDownloadFiles() { |
| 358 return number_active_objects_; | 358 return number_active_objects_; |
| 359 } | 359 } |
| 360 | 360 |
| 361 } // namespace content | 361 } // namespace content |
| OLD | NEW |