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_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 virtual void DownloadUrl( | 79 virtual void DownloadUrl( |
80 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; | 80 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; |
81 virtual void AddObserver(Observer* observer) OVERRIDE; | 81 virtual void AddObserver(Observer* observer) OVERRIDE; |
82 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 82 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
83 virtual void OnPersistentStoreQueryComplete( | 83 virtual void OnPersistentStoreQueryComplete( |
84 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; | 84 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; |
85 virtual void OnItemAddedToPersistentStore(int32 download_id, | 85 virtual void OnItemAddedToPersistentStore(int32 download_id, |
86 int64 db_handle) OVERRIDE; | 86 int64 db_handle) OVERRIDE; |
87 virtual int InProgressCount() const OVERRIDE; | 87 virtual int InProgressCount() const OVERRIDE; |
88 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 88 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
89 virtual FilePath LastDownloadPath() OVERRIDE; | |
90 virtual void ClearLastDownloadPath() OVERRIDE; | |
91 virtual void FileSelected(const FilePath& path, int32 download_id) OVERRIDE; | |
92 virtual void FileSelectionCanceled(int32 download_id) OVERRIDE; | |
93 virtual void RestartDownload(int32 download_id) OVERRIDE; | |
94 virtual void CheckForHistoryFilesRemoval() OVERRIDE; | 89 virtual void CheckForHistoryFilesRemoval() OVERRIDE; |
95 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; | 90 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; |
96 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; | 91 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; |
97 virtual void SavePageDownloadFinished( | 92 virtual void SavePageDownloadFinished( |
98 content::DownloadItem* download) OVERRIDE; | 93 content::DownloadItem* download) OVERRIDE; |
99 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; | 94 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; |
100 virtual bool GenerateFileHash() OVERRIDE; | 95 virtual bool GenerateFileHash() OVERRIDE; |
101 | 96 |
102 private: | 97 private: |
103 typedef std::set<content::DownloadItem*> DownloadSet; | 98 typedef std::set<content::DownloadItem*> DownloadSet; |
(...skipping 27 matching lines...) Expand all Loading... |
131 content::DownloadId GetNextId(); | 126 content::DownloadId GetNextId(); |
132 | 127 |
133 // Called on the FILE thread to check the existence of a downloaded file. | 128 // Called on the FILE thread to check the existence of a downloaded file. |
134 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); | 129 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); |
135 | 130 |
136 // Called on the UI thread if the FILE thread detects the removal of | 131 // Called on the UI thread if the FILE thread detects the removal of |
137 // the downloaded file. The UI thread updates the state of the file | 132 // the downloaded file. The UI thread updates the state of the file |
138 // and then notifies this update to the file's observer. | 133 // and then notifies this update to the file's observer. |
139 void OnFileRemovalDetected(int32 download_id); | 134 void OnFileRemovalDetected(int32 download_id); |
140 | 135 |
141 // Called back after a target path for the file to be downloaded to has been | |
142 // determined, either automatically based on the suggested file name, or by | |
143 // the user in a Save As dialog box. | |
144 void OnTargetPathAvailable(DownloadItemImpl* download); | |
145 | |
146 // Removes |download| from the active and in progress maps. | 136 // Removes |download| from the active and in progress maps. |
147 // Called when the download is cancelled or has an error. | 137 // Called when the download is cancelled or has an error. |
148 // Does nothing if the download is not in the history DB. | 138 // Does nothing if the download is not in the history DB. |
149 void RemoveFromActiveList(DownloadItemImpl* download); | 139 void RemoveFromActiveList(DownloadItemImpl* download); |
150 | 140 |
151 // Inform observers that the model has changed. | 141 // Inform observers that the model has changed. |
152 void NotifyModelChanged(); | 142 void NotifyModelChanged(); |
153 | 143 |
154 // Debugging routine to confirm relationship between below | 144 // Debugging routine to confirm relationship between below |
155 // containers; no-op if NDEBUG. | 145 // containers; no-op if NDEBUG. |
156 void AssertContainersConsistent() const; | 146 void AssertContainersConsistent() const; |
157 | 147 |
158 // Add a DownloadItem to history_downloads_. | 148 // Add a DownloadItem to history_downloads_. |
159 void AddDownloadItemToHistory(DownloadItemImpl* item, int64 db_handle); | 149 void AddDownloadItemToHistory(DownloadItemImpl* item, int64 db_handle); |
160 | 150 |
161 // Remove from internal maps. | 151 // Remove from internal maps. |
162 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); | 152 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); |
163 | 153 |
164 // Called in response to our request to the DownloadFileManager to | 154 // Called in response to our request to the DownloadFileManager to |
165 // create a DownloadFile. A |reason| of | 155 // create a DownloadFile. A |reason| of |
166 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. | 156 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. |
167 void OnDownloadFileCreated( | 157 void OnDownloadFileCreated( |
168 int32 download_id, content::DownloadInterruptReason reason); | 158 int32 download_id, content::DownloadInterruptReason reason); |
169 | 159 |
| 160 // Called when the delegate has completed determining the download target. |
| 161 // Arguments following |download_id| are as per |
| 162 // content::DownloadTargetCallback. |
| 163 void OnDownloadTargetDetermined( |
| 164 int32 download_id, |
| 165 const FilePath& target_path, |
| 166 content::DownloadItem::TargetDisposition disposition, |
| 167 content::DownloadDangerType danger_type, |
| 168 const FilePath& intermediate_path); |
| 169 |
170 // Called when a download entry is committed to the persistent store. | 170 // Called when a download entry is committed to the persistent store. |
171 void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item); | 171 void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item); |
172 | 172 |
173 // Called when Save Page As entry is committed to the persistent store. | 173 // Called when Save Page As entry is committed to the persistent store. |
174 void OnSavePageItemAddedToPersistentStore(DownloadItemImpl* item); | 174 void OnSavePageItemAddedToPersistentStore(DownloadItemImpl* item); |
175 | 175 |
176 // Overridden from DownloadItemImplDelegate | 176 // Overridden from DownloadItemImplDelegate |
177 // (Note that |GetBrowserContext| are present in both interfaces.) | 177 // (Note that |GetBrowserContext| are present in both interfaces.) |
| 178 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE; |
178 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; | 179 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; |
179 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; | 180 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
180 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; | 181 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; |
181 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE; | 182 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE; |
182 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE; | 183 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE; |
183 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE; | 184 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE; |
184 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; | 185 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; |
185 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; | 186 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; |
186 virtual void DownloadRenamedToIntermediateName( | 187 virtual void DownloadRenamedToIntermediateName( |
187 DownloadItemImpl* download) OVERRIDE; | 188 DownloadItemImpl* download) OVERRIDE; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 224 |
224 // Observers that want to be notified of changes to the set of downloads. | 225 // Observers that want to be notified of changes to the set of downloads. |
225 ObserverList<Observer> observers_; | 226 ObserverList<Observer> observers_; |
226 | 227 |
227 // The current active browser context. | 228 // The current active browser context. |
228 content::BrowserContext* browser_context_; | 229 content::BrowserContext* browser_context_; |
229 | 230 |
230 // Non-owning pointer for handling file writing on the download_thread_. | 231 // Non-owning pointer for handling file writing on the download_thread_. |
231 DownloadFileManager* file_manager_; | 232 DownloadFileManager* file_manager_; |
232 | 233 |
233 // The user's last choice for download directory. This is only used when the | |
234 // user wants us to prompt for a save location for each download. | |
235 FilePath last_download_path_; | |
236 | |
237 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 234 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
238 content::DownloadManagerDelegate* delegate_; | 235 content::DownloadManagerDelegate* delegate_; |
239 | 236 |
240 net::NetLog* net_log_; | 237 net::NetLog* net_log_; |
241 | 238 |
242 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 239 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
243 }; | 240 }; |
244 | 241 |
245 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 242 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |