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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Constructing for the "Save Page As..." feature: | 80 // Constructing for the "Save Page As..." feature: |
81 // |bound_net_log| is constructed externally for our use. | 81 // |bound_net_log| is constructed externally for our use. |
82 DownloadItemImpl(DownloadItemImplDelegate* delegate, | 82 DownloadItemImpl(DownloadItemImplDelegate* delegate, |
83 uint32 id, | 83 uint32 id, |
84 const base::FilePath& path, | 84 const base::FilePath& path, |
85 const GURL& url, | 85 const GURL& url, |
86 const std::string& mime_type, | 86 const std::string& mime_type, |
87 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 87 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
88 const net::BoundNetLog& bound_net_log); | 88 const net::BoundNetLog& bound_net_log); |
89 | 89 |
90 virtual ~DownloadItemImpl(); | 90 ~DownloadItemImpl() override; |
91 | 91 |
92 // DownloadItem | 92 // DownloadItem |
93 virtual void AddObserver(DownloadItem::Observer* observer) override; | 93 void AddObserver(DownloadItem::Observer* observer) override; |
94 virtual void RemoveObserver(DownloadItem::Observer* observer) override; | 94 void RemoveObserver(DownloadItem::Observer* observer) override; |
95 virtual void UpdateObservers() override; | 95 void UpdateObservers() override; |
96 virtual void ValidateDangerousDownload() override; | 96 void ValidateDangerousDownload() override; |
97 virtual void StealDangerousDownload(const AcquireFileCallback& callback) | 97 void StealDangerousDownload(const AcquireFileCallback& callback) override; |
98 override; | 98 void Pause() override; |
99 virtual void Pause() override; | 99 void Resume() override; |
100 virtual void Resume() override; | 100 void Cancel(bool user_cancel) override; |
101 virtual void Cancel(bool user_cancel) override; | 101 void Remove() override; |
102 virtual void Remove() override; | 102 void OpenDownload() override; |
103 virtual void OpenDownload() override; | 103 void ShowDownloadInShell() override; |
104 virtual void ShowDownloadInShell() override; | 104 uint32 GetId() const override; |
105 virtual uint32 GetId() const override; | 105 DownloadState GetState() const override; |
106 virtual DownloadState GetState() const override; | 106 DownloadInterruptReason GetLastReason() const override; |
107 virtual DownloadInterruptReason GetLastReason() const override; | 107 bool IsPaused() const override; |
108 virtual bool IsPaused() const override; | 108 bool IsTemporary() const override; |
109 virtual bool IsTemporary() const override; | 109 bool CanResume() const override; |
110 virtual bool CanResume() const override; | 110 bool IsDone() const override; |
111 virtual bool IsDone() const override; | 111 const GURL& GetURL() const override; |
112 virtual const GURL& GetURL() const override; | 112 const std::vector<GURL>& GetUrlChain() const override; |
113 virtual const std::vector<GURL>& GetUrlChain() const override; | 113 const GURL& GetOriginalUrl() const override; |
114 virtual const GURL& GetOriginalUrl() const override; | 114 const GURL& GetReferrerUrl() const override; |
115 virtual const GURL& GetReferrerUrl() const override; | 115 const GURL& GetTabUrl() const override; |
116 virtual const GURL& GetTabUrl() const override; | 116 const GURL& GetTabReferrerUrl() const override; |
117 virtual const GURL& GetTabReferrerUrl() const override; | 117 std::string GetSuggestedFilename() const override; |
118 virtual std::string GetSuggestedFilename() const override; | 118 std::string GetContentDisposition() const override; |
119 virtual std::string GetContentDisposition() const override; | 119 std::string GetMimeType() const override; |
120 virtual std::string GetMimeType() const override; | 120 std::string GetOriginalMimeType() const override; |
121 virtual std::string GetOriginalMimeType() const override; | 121 std::string GetRemoteAddress() const override; |
122 virtual std::string GetRemoteAddress() const override; | 122 bool HasUserGesture() const override; |
123 virtual bool HasUserGesture() const override; | 123 ui::PageTransition GetTransitionType() const override; |
124 virtual ui::PageTransition GetTransitionType() const override; | 124 const std::string& GetLastModifiedTime() const override; |
125 virtual const std::string& GetLastModifiedTime() const override; | 125 const std::string& GetETag() const override; |
126 virtual const std::string& GetETag() const override; | 126 bool IsSavePackageDownload() const override; |
127 virtual bool IsSavePackageDownload() const override; | 127 const base::FilePath& GetFullPath() const override; |
128 virtual const base::FilePath& GetFullPath() const override; | 128 const base::FilePath& GetTargetFilePath() const override; |
129 virtual const base::FilePath& GetTargetFilePath() const override; | 129 const base::FilePath& GetForcedFilePath() const override; |
130 virtual const base::FilePath& GetForcedFilePath() const override; | 130 base::FilePath GetFileNameToReportUser() const override; |
131 virtual base::FilePath GetFileNameToReportUser() const override; | 131 TargetDisposition GetTargetDisposition() const override; |
132 virtual TargetDisposition GetTargetDisposition() const override; | 132 const std::string& GetHash() const override; |
133 virtual const std::string& GetHash() const override; | 133 const std::string& GetHashState() const override; |
134 virtual const std::string& GetHashState() const override; | 134 bool GetFileExternallyRemoved() const override; |
135 virtual bool GetFileExternallyRemoved() const override; | 135 void DeleteFile(const base::Callback<void(bool)>& callback) override; |
136 virtual void DeleteFile(const base::Callback<void(bool)>& callback) override; | 136 bool IsDangerous() const override; |
137 virtual bool IsDangerous() const override; | 137 DownloadDangerType GetDangerType() const override; |
138 virtual DownloadDangerType GetDangerType() const override; | 138 bool TimeRemaining(base::TimeDelta* remaining) const override; |
139 virtual bool TimeRemaining(base::TimeDelta* remaining) const override; | 139 int64 CurrentSpeed() const override; |
140 virtual int64 CurrentSpeed() const override; | 140 int PercentComplete() const override; |
141 virtual int PercentComplete() const override; | 141 bool AllDataSaved() const override; |
142 virtual bool AllDataSaved() const override; | 142 int64 GetTotalBytes() const override; |
143 virtual int64 GetTotalBytes() const override; | 143 int64 GetReceivedBytes() const override; |
144 virtual int64 GetReceivedBytes() const override; | 144 base::Time GetStartTime() const override; |
145 virtual base::Time GetStartTime() const override; | 145 base::Time GetEndTime() const override; |
146 virtual base::Time GetEndTime() const override; | 146 bool CanShowInFolder() override; |
147 virtual bool CanShowInFolder() override; | 147 bool CanOpenDownload() override; |
148 virtual bool CanOpenDownload() override; | 148 bool ShouldOpenFileBasedOnExtension() override; |
149 virtual bool ShouldOpenFileBasedOnExtension() override; | 149 bool GetOpenWhenComplete() const override; |
150 virtual bool GetOpenWhenComplete() const override; | 150 bool GetAutoOpened() override; |
151 virtual bool GetAutoOpened() override; | 151 bool GetOpened() const override; |
152 virtual bool GetOpened() const override; | 152 BrowserContext* GetBrowserContext() const override; |
153 virtual BrowserContext* GetBrowserContext() const override; | 153 WebContents* GetWebContents() const override; |
154 virtual WebContents* GetWebContents() const override; | 154 void OnContentCheckCompleted(DownloadDangerType danger_type) override; |
155 virtual void OnContentCheckCompleted(DownloadDangerType danger_type) override; | 155 void SetOpenWhenComplete(bool open) override; |
156 virtual void SetOpenWhenComplete(bool open) override; | 156 void SetIsTemporary(bool temporary) override; |
157 virtual void SetIsTemporary(bool temporary) override; | 157 void SetOpened(bool opened) override; |
158 virtual void SetOpened(bool opened) override; | 158 void SetDisplayName(const base::FilePath& name) override; |
159 virtual void SetDisplayName(const base::FilePath& name) override; | 159 std::string DebugString(bool verbose) const override; |
160 virtual std::string DebugString(bool verbose) const override; | |
161 | 160 |
162 // All remaining public interfaces virtual to allow for DownloadItemImpl | 161 // All remaining public interfaces virtual to allow for DownloadItemImpl |
163 // mocks. | 162 // mocks. |
164 | 163 |
165 // Determines the resume mode for an interrupted download. Requires | 164 // Determines the resume mode for an interrupted download. Requires |
166 // last_reason_ to be set, but doesn't require the download to be in | 165 // last_reason_ to be set, but doesn't require the download to be in |
167 // INTERRUPTED state. | 166 // INTERRUPTED state. |
168 virtual ResumeMode GetResumeMode() const; | 167 virtual ResumeMode GetResumeMode() const; |
169 | 168 |
170 // Notify the download item that new origin information is available due to a | 169 // Notify the download item that new origin information is available due to a |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // Called by SavePackage to set the total number of bytes on the item. | 202 // Called by SavePackage to set the total number of bytes on the item. |
204 virtual void SetTotalBytes(int64 total_bytes); | 203 virtual void SetTotalBytes(int64 total_bytes); |
205 | 204 |
206 virtual void OnAllDataSaved(const std::string& final_hash); | 205 virtual void OnAllDataSaved(const std::string& final_hash); |
207 | 206 |
208 // Called by SavePackage to display progress when the DownloadItem | 207 // Called by SavePackage to display progress when the DownloadItem |
209 // should be considered complete. | 208 // should be considered complete. |
210 virtual void MarkAsComplete(); | 209 virtual void MarkAsComplete(); |
211 | 210 |
212 // DownloadDestinationObserver | 211 // DownloadDestinationObserver |
213 virtual void DestinationUpdate(int64 bytes_so_far, | 212 void DestinationUpdate(int64 bytes_so_far, |
214 int64 bytes_per_sec, | 213 int64 bytes_per_sec, |
215 const std::string& hash_state) override; | 214 const std::string& hash_state) override; |
216 virtual void DestinationError(DownloadInterruptReason reason) override; | 215 void DestinationError(DownloadInterruptReason reason) override; |
217 virtual void DestinationCompleted(const std::string& final_hash) override; | 216 void DestinationCompleted(const std::string& final_hash) override; |
218 | 217 |
219 private: | 218 private: |
220 // Fine grained states of a download. Note that active downloads are created | 219 // Fine grained states of a download. Note that active downloads are created |
221 // in IN_PROGRESS_INTERNAL state. However, downloads creates via history can | 220 // in IN_PROGRESS_INTERNAL state. However, downloads creates via history can |
222 // be created in COMPLETE_INTERNAL, CANCELLED_INTERNAL and | 221 // be created in COMPLETE_INTERNAL, CANCELLED_INTERNAL and |
223 // INTERRUPTED_INTERNAL. | 222 // INTERRUPTED_INTERNAL. |
224 | 223 |
225 enum DownloadInternalState { | 224 enum DownloadInternalState { |
226 // Includes both before and after file name determination, and paused | 225 // Includes both before and after file name determination, and paused |
227 // downloads. | 226 // downloads. |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 const net::BoundNetLog bound_net_log_; | 552 const net::BoundNetLog bound_net_log_; |
554 | 553 |
555 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; | 554 base::WeakPtrFactory<DownloadItemImpl> weak_ptr_factory_; |
556 | 555 |
557 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); | 556 DISALLOW_COPY_AND_ASSIGN(DownloadItemImpl); |
558 }; | 557 }; |
559 | 558 |
560 } // namespace content | 559 } // namespace content |
561 | 560 |
562 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ | 561 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_IMPL_H_ |
OLD | NEW |