| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "net/base/io_buffer.h" | 22 #include "net/base/io_buffer.h" |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 const int kUpdatePeriodMs = 500; | 26 const int kUpdatePeriodMs = 500; |
| 27 const int kMaxTimeBlockingFileThreadMs = 1000; | 27 const int kMaxTimeBlockingFileThreadMs = 1000; |
| 28 | 28 |
| 29 int DownloadFile::number_active_objects_ = 0; | 29 int DownloadFile::number_active_objects_ = 0; |
| 30 | 30 |
| 31 DownloadFileImpl::DownloadFileImpl( | 31 DownloadFileImpl::DownloadFileImpl( |
| 32 scoped_ptr<DownloadSaveInfo> save_info, | 32 const DownloadSaveInfo& save_info, |
| 33 const base::FilePath& default_download_directory, | 33 const base::FilePath& default_download_directory, |
| 34 const GURL& url, | 34 const GURL& url, |
| 35 const GURL& referrer_url, | 35 const GURL& referrer_url, |
| 36 bool calculate_hash, | 36 bool calculate_hash, |
| 37 scoped_ptr<ByteStreamReader> stream, | 37 scoped_ptr<net::FileStream> file_stream, |
| 38 scoped_ptr<ByteStreamReader> byte_stream, |
| 38 const net::BoundNetLog& bound_net_log, | 39 const net::BoundNetLog& bound_net_log, |
| 39 scoped_ptr<PowerSaveBlocker> power_save_blocker, | 40 scoped_ptr<PowerSaveBlocker> power_save_blocker, |
| 40 base::WeakPtr<DownloadDestinationObserver> observer) | 41 base::WeakPtr<DownloadDestinationObserver> observer) |
| 41 : file_(save_info->file_path, | 42 : file_(save_info.file_path, |
| 42 url, | 43 url, |
| 43 referrer_url, | 44 referrer_url, |
| 44 save_info->offset, | 45 save_info.offset, |
| 45 calculate_hash, | 46 calculate_hash, |
| 46 save_info->hash_state, | 47 save_info.hash_state, |
| 47 save_info->file_stream.Pass(), | 48 file_stream.Pass(), |
| 48 bound_net_log), | 49 bound_net_log), |
| 49 default_download_directory_(default_download_directory), | 50 default_download_directory_(default_download_directory), |
| 50 stream_reader_(stream.Pass()), | 51 stream_reader_(byte_stream.Pass()), |
| 51 bytes_seen_(0), | 52 bytes_seen_(0), |
| 52 bound_net_log_(bound_net_log), | 53 bound_net_log_(bound_net_log), |
| 53 observer_(observer), | 54 observer_(observer), |
| 54 weak_factory_(this), | 55 weak_factory_(this), |
| 55 power_save_blocker_(power_save_blocker.Pass()) { | 56 power_save_blocker_(power_save_blocker.Pass()) { |
| 56 } | 57 } |
| 57 | 58 |
| 58 DownloadFileImpl::~DownloadFileImpl() { | 59 DownloadFileImpl::~DownloadFileImpl() { |
| 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 60 --number_active_objects_; | 61 --number_active_objects_; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 observer_, file_.bytes_so_far(), CurrentSpeed(), | 313 observer_, file_.bytes_so_far(), CurrentSpeed(), |
| 313 GetHashState())); | 314 GetHashState())); |
| 314 } | 315 } |
| 315 | 316 |
| 316 // static | 317 // static |
| 317 int DownloadFile::GetNumberOfDownloadFiles() { | 318 int DownloadFile::GetNumberOfDownloadFiles() { |
| 318 return number_active_objects_; | 319 return number_active_objects_; |
| 319 } | 320 } |
| 320 | 321 |
| 321 } // namespace content | 322 } // namespace content |
| OLD | NEW |