| 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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/download/download_file.h" | 9 #include "content/browser/download/download_file.h" |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/timer.h" | 15 #include "base/timer.h" |
| 16 #include "content/browser/download/base_file.h" | 16 #include "content/browser/download/base_file.h" |
| 17 #include "content/browser/download/byte_stream.h" | 17 #include "content/browser/download/byte_stream.h" |
| 18 #include "content/browser/download/download_request_handle.h" | 18 #include "content/browser/download/download_request_handle.h" |
| 19 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
| 20 | 20 |
| 21 class PowerSaveBlocker; | |
| 22 | |
| 23 struct DownloadCreateInfo; | 21 struct DownloadCreateInfo; |
| 24 | 22 |
| 25 namespace content { | 23 namespace content { |
| 26 class ByteStreamReader; | 24 class ByteStreamReader; |
| 27 class DownloadManager; | 25 class DownloadManager; |
| 26 class PowerSaveBlocker; |
| 28 } | 27 } |
| 29 | 28 |
| 30 class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile { | 29 class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile { |
| 31 public: | 30 public: |
| 32 // Takes ownership of the object pointed to by |request_handle|. | 31 // Takes ownership of the object pointed to by |request_handle|. |
| 33 // |bound_net_log| will be used for logging the download file's events. | 32 // |bound_net_log| will be used for logging the download file's events. |
| 34 DownloadFileImpl(const DownloadCreateInfo* info, | 33 DownloadFileImpl(const DownloadCreateInfo* info, |
| 35 scoped_ptr<content::ByteStreamReader> stream, | 34 scoped_ptr<content::ByteStreamReader> stream, |
| 36 DownloadRequestHandleInterface* request_handle, | 35 DownloadRequestHandleInterface* request_handle, |
| 37 content::DownloadManager* download_manager, | 36 content::DownloadManager* download_manager, |
| 38 bool calculate_hash, | 37 bool calculate_hash, |
| 39 scoped_ptr<PowerSaveBlocker> power_save_blocker, | 38 scoped_ptr<content::PowerSaveBlocker> power_save_blocker, |
| 40 const net::BoundNetLog& bound_net_log); | 39 const net::BoundNetLog& bound_net_log); |
| 41 virtual ~DownloadFileImpl(); | 40 virtual ~DownloadFileImpl(); |
| 42 | 41 |
| 43 // DownloadFile functions. | 42 // DownloadFile functions. |
| 44 virtual net::Error Initialize() OVERRIDE; | 43 virtual net::Error Initialize() OVERRIDE; |
| 45 virtual net::Error Rename(const FilePath& full_path) OVERRIDE; | 44 virtual net::Error Rename(const FilePath& full_path) OVERRIDE; |
| 46 virtual void Detach() OVERRIDE; | 45 virtual void Detach() OVERRIDE; |
| 47 virtual void Cancel() OVERRIDE; | 46 virtual void Cancel() OVERRIDE; |
| 48 virtual void AnnotateWithSourceInformation() OVERRIDE; | 47 virtual void AnnotateWithSourceInformation() OVERRIDE; |
| 49 virtual FilePath FullPath() const OVERRIDE; | 48 virtual FilePath FullPath() const OVERRIDE; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Statistics | 96 // Statistics |
| 98 size_t bytes_seen_; | 97 size_t bytes_seen_; |
| 99 base::TimeDelta disk_writes_time_; | 98 base::TimeDelta disk_writes_time_; |
| 100 base::TimeTicks download_start_; | 99 base::TimeTicks download_start_; |
| 101 | 100 |
| 102 net::BoundNetLog bound_net_log_; | 101 net::BoundNetLog bound_net_log_; |
| 103 | 102 |
| 104 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; | 103 base::WeakPtrFactory<DownloadFileImpl> weak_factory_; |
| 105 | 104 |
| 106 // RAII handle to keep the system from sleeping while we're downloading. | 105 // RAII handle to keep the system from sleeping while we're downloading. |
| 107 scoped_ptr<PowerSaveBlocker> power_save_blocker_; | 106 scoped_ptr<content::PowerSaveBlocker> power_save_blocker_; |
| 108 | 107 |
| 109 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); | 108 DISALLOW_COPY_AND_ASSIGN(DownloadFileImpl); |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ | 111 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_IMPL_H_ |
| OLD | NEW |