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_ITEM_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 virtual void DangerousDownloadValidated() OVERRIDE; | 121 virtual void DangerousDownloadValidated() OVERRIDE; |
122 virtual void UpdateProgress(int64 bytes_so_far, | 122 virtual void UpdateProgress(int64 bytes_so_far, |
123 int64 bytes_per_sec, | 123 int64 bytes_per_sec, |
124 const std::string& hash_state) OVERRIDE; | 124 const std::string& hash_state) OVERRIDE; |
125 virtual void Cancel(bool user_cancel) OVERRIDE; | 125 virtual void Cancel(bool user_cancel) OVERRIDE; |
126 virtual void MarkAsComplete() OVERRIDE; | 126 virtual void MarkAsComplete() OVERRIDE; |
127 virtual void DelayedDownloadOpened() OVERRIDE; | 127 virtual void DelayedDownloadOpened() OVERRIDE; |
128 virtual void OnAllDataSaved( | 128 virtual void OnAllDataSaved( |
129 int64 size, const std::string& final_hash) OVERRIDE; | 129 int64 size, const std::string& final_hash) OVERRIDE; |
130 virtual void OnDownloadedFileRemoved() OVERRIDE; | 130 virtual void OnDownloadedFileRemoved() OVERRIDE; |
131 virtual void MaybeCompleteDownload() OVERRIDE; | |
132 virtual void Interrupted(int64 size, | 131 virtual void Interrupted(int64 size, |
133 const std::string& hash_state, | 132 const std::string& hash_state, |
134 content::DownloadInterruptReason reason) OVERRIDE; | 133 content::DownloadInterruptReason reason) OVERRIDE; |
135 virtual void Delete(DeleteReason reason) OVERRIDE; | 134 virtual void Delete(DeleteReason reason) OVERRIDE; |
136 virtual void Remove() OVERRIDE; | 135 virtual void Remove() OVERRIDE; |
137 virtual bool TimeRemaining(base::TimeDelta* remaining) const OVERRIDE; | 136 virtual bool TimeRemaining(base::TimeDelta* remaining) const OVERRIDE; |
138 virtual int64 CurrentSpeed() const OVERRIDE; | 137 virtual int64 CurrentSpeed() const OVERRIDE; |
139 virtual int PercentComplete() const OVERRIDE; | 138 virtual int PercentComplete() const OVERRIDE; |
140 virtual void OnPathDetermined(const FilePath& path) OVERRIDE; | 139 virtual void OnPathDetermined(const FilePath& path) OVERRIDE; |
141 virtual bool AllDataSaved() const OVERRIDE; | 140 virtual bool AllDataSaved() const OVERRIDE; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Construction common to all constructors. |active| should be true for new | 216 // Construction common to all constructors. |active| should be true for new |
218 // downloads and false for downloads from the history. | 217 // downloads and false for downloads from the history. |
219 // |download_type| indicates to the net log system what kind of download | 218 // |download_type| indicates to the net log system what kind of download |
220 // this is. | 219 // this is. |
221 void Init(bool active, download_net_logs::DownloadType download_type); | 220 void Init(bool active, download_net_logs::DownloadType download_type); |
222 | 221 |
223 // Internal helper for maintaining consistent received and total sizes, and | 222 // Internal helper for maintaining consistent received and total sizes, and |
224 // hash state. | 223 // hash state. |
225 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state); | 224 void UpdateProgress(int64 bytes_so_far, const std::string& hash_state); |
226 | 225 |
| 226 // If all pre-requisites have been met, complete download processing, i.e. do |
| 227 // internal cleanup, file rename, and potentially auto-open. (Dangerous |
| 228 // downloads still may block on user acceptance after this point.) |
| 229 void MaybeCompleteDownload(); |
| 230 |
227 // Internal helper for maintaining consistent received and total sizes, and | 231 // Internal helper for maintaining consistent received and total sizes, and |
228 // setting the final hash. | 232 // setting the final hash. |
229 // Should only be called from |OnAllDataSaved|. | 233 // Should only be called from |OnAllDataSaved|. |
230 void ProgressComplete(int64 bytes_so_far, | 234 void ProgressComplete(int64 bytes_so_far, |
231 const std::string& final_hash); | 235 const std::string& final_hash); |
232 | 236 |
233 // Called when the entire download operation (including renaming etc) | 237 // Called when the entire download operation (including renaming etc) |
234 // is completed. | 238 // is completed. |
235 void Completed(); | 239 void Completed(); |
236 | 240 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // are owned by the DownloadItemImpl. | 390 // are owned by the DownloadItemImpl. |
387 std::map<const void*, ExternalData*> external_data_map_; | 391 std::map<const void*, ExternalData*> external_data_map_; |
388 | 392 |
389 // Net log to use for this download. | 393 // Net log to use for this download. |
390 const net::BoundNetLog bound_net_log_; | 394 const net::BoundNetLog bound_net_log_; |
391 | 395 |
392 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 396 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
393 }; | 397 }; |
394 | 398 |
395 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 399 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |