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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // |net_log| is constructed externally for our use. | 53 // |net_log| is constructed externally for our use. |
54 DownloadItemImpl(DownloadItemImplDelegate* delegate, | 54 DownloadItemImpl( |
55 const std::string& guid, | 55 DownloadItemImplDelegate* delegate, |
56 uint32_t id, | 56 const std::string& guid, |
57 const base::FilePath& current_path, | 57 uint32_t id, |
58 const base::FilePath& target_path, | 58 const base::FilePath& current_path, |
59 const std::vector<GURL>& url_chain, | 59 const base::FilePath& target_path, |
60 const GURL& referrer_url, | 60 const std::vector<GURL>& url_chain, |
61 const GURL& site_url, | 61 const GURL& referrer_url, |
62 const GURL& tab_url, | 62 const GURL& site_url, |
63 const GURL& tab_referrer_url, | 63 const GURL& tab_url, |
64 const std::string& mime_type, | 64 const GURL& tab_referrer_url, |
65 const std::string& original_mime_type, | 65 const std::string& mime_type, |
66 const base::Time& start_time, | 66 const std::string& original_mime_type, |
67 const base::Time& end_time, | 67 const base::Time& start_time, |
68 const std::string& etag, | 68 const base::Time& end_time, |
69 const std::string& last_modified, | 69 const std::string& etag, |
70 int64_t received_bytes, | 70 const std::string& last_modified, |
71 int64_t total_bytes, | 71 int64_t received_bytes, |
72 const std::string& hash, | 72 int64_t total_bytes, |
73 DownloadItem::DownloadState state, | 73 const std::string& hash, |
74 DownloadDangerType danger_type, | 74 DownloadItem::DownloadState state, |
75 DownloadInterruptReason interrupt_reason, | 75 DownloadDangerType danger_type, |
76 bool opened, | 76 DownloadInterruptReason interrupt_reason, |
77 const net::NetLogWithSource& net_log); | 77 bool opened, |
| 78 const std::vector<DownloadItem::ReceivedSlice>& received_slices, |
| 79 const net::NetLogWithSource& net_log); |
78 | 80 |
79 // Constructing for a regular download. | 81 // Constructing for a regular download. |
80 // |net_log| is constructed externally for our use. | 82 // |net_log| is constructed externally for our use. |
81 DownloadItemImpl(DownloadItemImplDelegate* delegate, | 83 DownloadItemImpl(DownloadItemImplDelegate* delegate, |
82 uint32_t id, | 84 uint32_t id, |
83 const DownloadCreateInfo& info, | 85 const DownloadCreateInfo& info, |
84 const net::NetLogWithSource& net_log); | 86 const net::NetLogWithSource& net_log); |
85 | 87 |
86 // Constructing for the "Save Page As..." feature: | 88 // Constructing for the "Save Page As..." feature: |
87 // |net_log| is constructed externally for our use. | 89 // |net_log| is constructed externally for our use. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 bool GetFileExternallyRemoved() const override; | 145 bool GetFileExternallyRemoved() const override; |
144 void DeleteFile(const base::Callback<void(bool)>& callback) override; | 146 void DeleteFile(const base::Callback<void(bool)>& callback) override; |
145 bool IsDangerous() const override; | 147 bool IsDangerous() const override; |
146 DownloadDangerType GetDangerType() const override; | 148 DownloadDangerType GetDangerType() const override; |
147 bool TimeRemaining(base::TimeDelta* remaining) const override; | 149 bool TimeRemaining(base::TimeDelta* remaining) const override; |
148 int64_t CurrentSpeed() const override; | 150 int64_t CurrentSpeed() const override; |
149 int PercentComplete() const override; | 151 int PercentComplete() const override; |
150 bool AllDataSaved() const override; | 152 bool AllDataSaved() const override; |
151 int64_t GetTotalBytes() const override; | 153 int64_t GetTotalBytes() const override; |
152 int64_t GetReceivedBytes() const override; | 154 int64_t GetReceivedBytes() const override; |
| 155 const std::vector<DownloadItem::ReceivedSlice>& GetReceivedSlices() |
| 156 const override; |
153 base::Time GetStartTime() const override; | 157 base::Time GetStartTime() const override; |
154 base::Time GetEndTime() const override; | 158 base::Time GetEndTime() const override; |
155 bool CanShowInFolder() override; | 159 bool CanShowInFolder() override; |
156 bool CanOpenDownload() override; | 160 bool CanOpenDownload() override; |
157 bool ShouldOpenFileBasedOnExtension() override; | 161 bool ShouldOpenFileBasedOnExtension() override; |
158 bool GetOpenWhenComplete() const override; | 162 bool GetOpenWhenComplete() const override; |
159 bool GetAutoOpened() override; | 163 bool GetAutoOpened() override; |
160 bool GetOpened() const override; | 164 bool GetOpened() const override; |
161 BrowserContext* GetBrowserContext() const override; | 165 BrowserContext* GetBrowserContext() const override; |
162 WebContents* GetWebContents() const override; | 166 WebContents* GetWebContents() const override; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // exposes the partial hash state. This state can be held by the download item | 671 // exposes the partial hash state. This state can be held by the download item |
668 // in case it's needed for resumption. | 672 // in case it's needed for resumption. |
669 std::unique_ptr<crypto::SecureHash> hash_state_; | 673 std::unique_ptr<crypto::SecureHash> hash_state_; |
670 | 674 |
671 // Contents of the Last-Modified header for the most recent server response. | 675 // Contents of the Last-Modified header for the most recent server response. |
672 std::string last_modified_time_; | 676 std::string last_modified_time_; |
673 | 677 |
674 // Server's ETAG for the file. | 678 // Server's ETAG for the file. |
675 std::string etag_; | 679 std::string etag_; |
676 | 680 |
| 681 // The data slices that have been received so far. |
| 682 std::vector<DownloadItem::ReceivedSlice> received_slices_; |
| 683 |
677 // Net log to use for this download. | 684 // Net log to use for this download. |
678 const net::NetLogWithSource net_log_; | 685 const net::NetLogWithSource net_log_; |
679 | 686 |
680 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 687 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
681 | 688 |
682 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 689 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
683 }; | 690 }; |
684 | 691 |
685 } // namespace content | 692 } // namespace content |
686 | 693 |
687 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 694 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |