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 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 }; | 43 }; |
44 | 44 |
45 // The maximum number of attempts we will make to resume automatically. | 45 // The maximum number of attempts we will make to resume automatically. |
46 static const int kMaxAutoResumeAttempts; | 46 static const int kMaxAutoResumeAttempts; |
47 | 47 |
48 // Note that it is the responsibility of the caller to ensure that a | 48 // Note that it is the responsibility of the caller to ensure that a |
49 // DownloadItemImplDelegate passed to a DownloadItemImpl constructor | 49 // DownloadItemImplDelegate passed to a DownloadItemImpl constructor |
50 // outlives the DownloadItemImpl. | 50 // outlives the DownloadItemImpl. |
51 | 51 |
52 // Constructing from persistent store: | 52 // Constructing from persistent store: |
53 // |bound_net_log| is constructed externally for our use. | 53 // |net_log| is constructed externally for our use. |
54 DownloadItemImpl(DownloadItemImplDelegate* delegate, | 54 DownloadItemImpl(DownloadItemImplDelegate* delegate, |
55 const std::string& guid, | 55 const std::string& guid, |
56 uint32_t id, | 56 uint32_t id, |
57 const base::FilePath& current_path, | 57 const base::FilePath& current_path, |
58 const base::FilePath& target_path, | 58 const base::FilePath& target_path, |
59 const std::vector<GURL>& url_chain, | 59 const std::vector<GURL>& url_chain, |
60 const GURL& referrer_url, | 60 const GURL& referrer_url, |
61 const GURL& site_url, | 61 const GURL& site_url, |
62 const GURL& tab_url, | 62 const GURL& tab_url, |
63 const GURL& tab_referrer_url, | 63 const GURL& tab_referrer_url, |
64 const std::string& mime_type, | 64 const std::string& mime_type, |
65 const std::string& original_mime_type, | 65 const std::string& original_mime_type, |
66 const base::Time& start_time, | 66 const base::Time& start_time, |
67 const base::Time& end_time, | 67 const base::Time& end_time, |
68 const std::string& etag, | 68 const std::string& etag, |
69 const std::string& last_modified, | 69 const std::string& last_modified, |
70 int64_t received_bytes, | 70 int64_t received_bytes, |
71 int64_t total_bytes, | 71 int64_t total_bytes, |
72 const std::string& hash, | 72 const std::string& hash, |
73 DownloadItem::DownloadState state, | 73 DownloadItem::DownloadState state, |
74 DownloadDangerType danger_type, | 74 DownloadDangerType danger_type, |
75 DownloadInterruptReason interrupt_reason, | 75 DownloadInterruptReason interrupt_reason, |
76 bool opened, | 76 bool opened, |
77 const net::BoundNetLog& bound_net_log); | 77 const net::NetLogWithSource& net_log); |
78 | 78 |
79 // Constructing for a regular download. | 79 // Constructing for a regular download. |
80 // |bound_net_log| is constructed externally for our use. | 80 // |net_log| is constructed externally for our use. |
81 DownloadItemImpl(DownloadItemImplDelegate* delegate, | 81 DownloadItemImpl(DownloadItemImplDelegate* delegate, |
82 uint32_t id, | 82 uint32_t id, |
83 const DownloadCreateInfo& info, | 83 const DownloadCreateInfo& info, |
84 const net::BoundNetLog& bound_net_log); | 84 const net::NetLogWithSource& net_log); |
85 | 85 |
86 // Constructing for the "Save Page As..." feature: | 86 // Constructing for the "Save Page As..." feature: |
87 // |bound_net_log| is constructed externally for our use. | 87 // |net_log| is constructed externally for our use. |
88 DownloadItemImpl( | 88 DownloadItemImpl( |
89 DownloadItemImplDelegate* delegate, | 89 DownloadItemImplDelegate* delegate, |
90 uint32_t id, | 90 uint32_t id, |
91 const base::FilePath& path, | 91 const base::FilePath& path, |
92 const GURL& url, | 92 const GURL& url, |
93 const std::string& mime_type, | 93 const std::string& mime_type, |
94 std::unique_ptr<DownloadRequestHandleInterface> request_handle, | 94 std::unique_ptr<DownloadRequestHandleInterface> request_handle, |
95 const net::BoundNetLog& bound_net_log); | 95 const net::NetLogWithSource& net_log); |
96 | 96 |
97 ~DownloadItemImpl() override; | 97 ~DownloadItemImpl() override; |
98 | 98 |
99 // DownloadItem | 99 // DownloadItem |
100 void AddObserver(DownloadItem::Observer* observer) override; | 100 void AddObserver(DownloadItem::Observer* observer) override; |
101 void RemoveObserver(DownloadItem::Observer* observer) override; | 101 void RemoveObserver(DownloadItem::Observer* observer) override; |
102 void UpdateObservers() override; | 102 void UpdateObservers() override; |
103 void ValidateDangerousDownload() override; | 103 void ValidateDangerousDownload() override; |
104 void StealDangerousDownload(const AcquireFileCallback& callback) override; | 104 void StealDangerousDownload(const AcquireFileCallback& callback) override; |
105 void Pause() override; | 105 void Pause() override; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // Notify observers that this item is being removed by the user. | 194 // Notify observers that this item is being removed by the user. |
195 virtual void NotifyRemoved(); | 195 virtual void NotifyRemoved(); |
196 | 196 |
197 virtual void OnDownloadedFileRemoved(); | 197 virtual void OnDownloadedFileRemoved(); |
198 | 198 |
199 // Provide a weak pointer reference to a DownloadDestinationObserver | 199 // Provide a weak pointer reference to a DownloadDestinationObserver |
200 // for use by download destinations. | 200 // for use by download destinations. |
201 virtual base::WeakPtr<DownloadDestinationObserver> | 201 virtual base::WeakPtr<DownloadDestinationObserver> |
202 DestinationObserverAsWeakPtr(); | 202 DestinationObserverAsWeakPtr(); |
203 | 203 |
204 // Get the download's BoundNetLog. | 204 // Get the download's NetLogWithSource. |
205 virtual const net::BoundNetLog& GetBoundNetLog() const; | 205 virtual const net::NetLogWithSource& GetNetLogWithSource() const; |
206 | 206 |
207 // DownloadItemImpl routines only needed by SavePackage ---------------------- | 207 // DownloadItemImpl routines only needed by SavePackage ---------------------- |
208 | 208 |
209 // Called by SavePackage to set the total number of bytes on the item. | 209 // Called by SavePackage to set the total number of bytes on the item. |
210 virtual void SetTotalBytes(int64_t total_bytes); | 210 virtual void SetTotalBytes(int64_t total_bytes); |
211 | 211 |
212 virtual void OnAllDataSaved(int64_t total_bytes, | 212 virtual void OnAllDataSaved(int64_t total_bytes, |
213 std::unique_ptr<crypto::SecureHash> hash_state); | 213 std::unique_ptr<crypto::SecureHash> hash_state); |
214 | 214 |
215 // Called by SavePackage to display progress when the DownloadItem | 215 // Called by SavePackage to display progress when the DownloadItem |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // in case it's needed for resumption. | 667 // in case it's needed for resumption. |
668 std::unique_ptr<crypto::SecureHash> hash_state_; | 668 std::unique_ptr<crypto::SecureHash> hash_state_; |
669 | 669 |
670 // Contents of the Last-Modified header for the most recent server response. | 670 // Contents of the Last-Modified header for the most recent server response. |
671 std::string last_modified_time_; | 671 std::string last_modified_time_; |
672 | 672 |
673 // Server's ETAG for the file. | 673 // Server's ETAG for the file. |
674 std::string etag_; | 674 std::string etag_; |
675 | 675 |
676 // Net log to use for this download. | 676 // Net log to use for this download. |
677 const net::BoundNetLog bound_net_log_; | 677 const net::NetLogWithSource net_log_; |
678 | 678 |
679 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 679 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
680 | 680 |
681 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 681 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
682 }; | 682 }; |
683 | 683 |
684 } // namespace content | 684 } // namespace content |
685 | 685 |
686 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 686 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |