| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 virtual void DownloadUrl( | 69 virtual void DownloadUrl( |
| 70 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; | 70 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; |
| 71 virtual void AddObserver(Observer* observer) OVERRIDE; | 71 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 72 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 72 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 73 virtual void OnPersistentStoreQueryComplete( | 73 virtual void OnPersistentStoreQueryComplete( |
| 74 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; | 74 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; |
| 75 virtual void OnItemAddedToPersistentStore(int32 download_id, | 75 virtual void OnItemAddedToPersistentStore(int32 download_id, |
| 76 int64 db_handle) OVERRIDE; | 76 int64 db_handle) OVERRIDE; |
| 77 virtual int InProgressCount() const OVERRIDE; | 77 virtual int InProgressCount() const OVERRIDE; |
| 78 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 78 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
| 79 virtual FilePath LastDownloadPath() OVERRIDE; | |
| 80 virtual net::BoundNetLog CreateDownloadItem( | 79 virtual net::BoundNetLog CreateDownloadItem( |
| 81 DownloadCreateInfo* info) OVERRIDE; | 80 DownloadCreateInfo* info) OVERRIDE; |
| 82 virtual content::DownloadItem* CreateSavePackageDownloadItem( | 81 virtual content::DownloadItem* CreateSavePackageDownloadItem( |
| 83 const FilePath& main_file_path, | 82 const FilePath& main_file_path, |
| 84 const GURL& page_url, | 83 const GURL& page_url, |
| 85 bool is_otr, | 84 bool is_otr, |
| 86 const std::string& mime_type, | 85 const std::string& mime_type, |
| 87 content::DownloadItem::Observer* observer) OVERRIDE; | 86 content::DownloadItem::Observer* observer) OVERRIDE; |
| 88 virtual void ClearLastDownloadPath() OVERRIDE; | 87 virtual void ClearTransientState() OVERRIDE; |
| 89 virtual void FileSelected(const FilePath& path, int32 download_id) OVERRIDE; | |
| 90 virtual void FileSelectionCanceled(int32 download_id) OVERRIDE; | |
| 91 virtual void RestartDownload(int32 download_id) OVERRIDE; | |
| 92 virtual void CheckForHistoryFilesRemoval() OVERRIDE; | 88 virtual void CheckForHistoryFilesRemoval() OVERRIDE; |
| 93 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; | 89 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; |
| 94 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; | 90 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; |
| 95 virtual void SavePageDownloadFinished( | 91 virtual void SavePageDownloadFinished( |
| 96 content::DownloadItem* download) OVERRIDE; | 92 content::DownloadItem* download) OVERRIDE; |
| 97 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; | 93 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; |
| 98 virtual bool GenerateFileHash() OVERRIDE; | 94 virtual bool GenerateFileHash() OVERRIDE; |
| 99 | 95 |
| 100 // Overridden from DownloadItemImpl::Delegate | 96 // Overridden from DownloadItemImpl::Delegate |
| 101 // (Note that |GetBrowserContext| are present in both interfaces.) | 97 // (Note that |GetBrowserContext| are present in both interfaces.) |
| 98 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE; |
| 102 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE; | 99 virtual bool ShouldOpenDownload(content::DownloadItem* item) OVERRIDE; |
| 103 virtual bool ShouldOpenFileBasedOnExtension( | 100 virtual bool ShouldOpenFileBasedOnExtension( |
| 104 const FilePath& path) OVERRIDE; | 101 const FilePath& path) OVERRIDE; |
| 105 virtual void CheckForFileRemoval( | 102 virtual void CheckForFileRemoval( |
| 106 content::DownloadItem* download_item) OVERRIDE; | 103 content::DownloadItem* download_item) OVERRIDE; |
| 107 virtual void MaybeCompleteDownload( | 104 virtual void MaybeCompleteDownload( |
| 108 content::DownloadItem* download) OVERRIDE; | 105 content::DownloadItem* download) OVERRIDE; |
| 109 virtual void DownloadStopped( | 106 virtual void DownloadStopped( |
| 110 content::DownloadItem* download) OVERRIDE; | 107 content::DownloadItem* download) OVERRIDE; |
| 111 virtual void DownloadCompleted( | 108 virtual void DownloadCompleted( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 content::DownloadId GetNextId(); | 144 content::DownloadId GetNextId(); |
| 148 | 145 |
| 149 // Called on the FILE thread to check the existence of a downloaded file. | 146 // Called on the FILE thread to check the existence of a downloaded file. |
| 150 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); | 147 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); |
| 151 | 148 |
| 152 // Called on the UI thread if the FILE thread detects the removal of | 149 // Called on the UI thread if the FILE thread detects the removal of |
| 153 // the downloaded file. The UI thread updates the state of the file | 150 // the downloaded file. The UI thread updates the state of the file |
| 154 // and then notifies this update to the file's observer. | 151 // and then notifies this update to the file's observer. |
| 155 void OnFileRemovalDetected(int32 download_id); | 152 void OnFileRemovalDetected(int32 download_id); |
| 156 | 153 |
| 157 // Called back after a target path for the file to be downloaded to has been | |
| 158 // determined, either automatically based on the suggested file name, or by | |
| 159 // the user in a Save As dialog box. | |
| 160 void OnTargetPathAvailable(content::DownloadItem* download); | |
| 161 | |
| 162 // Retrieves the download from the |download_id|. | 154 // Retrieves the download from the |download_id|. |
| 163 // Returns NULL if the download is not active. | 155 // Returns NULL if the download is not active. |
| 164 content::DownloadItem* GetActiveDownload(int32 download_id); | 156 content::DownloadItem* GetActiveDownload(int32 download_id); |
| 165 | 157 |
| 166 // Removes |download| from the active and in progress maps. | 158 // Removes |download| from the active and in progress maps. |
| 167 // Called when the download is cancelled or has an error. | 159 // Called when the download is cancelled or has an error. |
| 168 // Does nothing if the download is not in the history DB. | 160 // Does nothing if the download is not in the history DB. |
| 169 void RemoveFromActiveList(content::DownloadItem* download); | 161 void RemoveFromActiveList(content::DownloadItem* download); |
| 170 | 162 |
| 171 // Inform observers that the model has changed. | 163 // Inform observers that the model has changed. |
| 172 void NotifyModelChanged(); | 164 void NotifyModelChanged(); |
| 173 | 165 |
| 174 // Debugging routine to confirm relationship between below | 166 // Debugging routine to confirm relationship between below |
| 175 // containers; no-op if NDEBUG. | 167 // containers; no-op if NDEBUG. |
| 176 void AssertContainersConsistent() const; | 168 void AssertContainersConsistent() const; |
| 177 | 169 |
| 178 // Add a DownloadItem to history_downloads_. | 170 // Add a DownloadItem to history_downloads_. |
| 179 void AddDownloadItemToHistory(content::DownloadItem* item, int64 db_handle); | 171 void AddDownloadItemToHistory(content::DownloadItem* item, int64 db_handle); |
| 180 | 172 |
| 181 // Remove from internal maps. | 173 // Remove from internal maps. |
| 182 int RemoveDownloadItems(const DownloadVector& pending_deletes); | 174 int RemoveDownloadItems(const DownloadVector& pending_deletes); |
| 183 | 175 |
| 184 // Called in response to our request to the DownloadFileManager to | 176 // Called in response to our request to the DownloadFileManager to |
| 185 // create a DownloadFile. A |reason| of | 177 // create a DownloadFile. A |reason| of |
| 186 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. | 178 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. |
| 187 void OnDownloadFileCreated( | 179 void OnDownloadFileCreated( |
| 188 int32 download_id, content::DownloadInterruptReason reason); | 180 int32 download_id, content::DownloadInterruptReason reason); |
| 189 | 181 |
| 182 void OnDownloadTargetDetermined( |
| 183 int32 download_id, |
| 184 const FilePath& target_path, |
| 185 content::DownloadItem::TargetDisposition disposition, |
| 186 content::DownloadDangerType danger_type, |
| 187 const FilePath& intermediate_path); |
| 188 |
| 190 // Called when a download entry is committed to the persistent store. | 189 // Called when a download entry is committed to the persistent store. |
| 191 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 190 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); |
| 192 | 191 |
| 193 // Called when Save Page As entry is committed to the persistent store. | 192 // Called when Save Page As entry is committed to the persistent store. |
| 194 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 193 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); |
| 195 | 194 |
| 196 // Factory for creation of downloads items. | 195 // Factory for creation of downloads items. |
| 197 scoped_ptr<content::DownloadItemFactory> factory_; | 196 scoped_ptr<content::DownloadItemFactory> factory_; |
| 198 | 197 |
| 199 // |downloads_| is the owning set for all downloads known to the | 198 // |downloads_| is the owning set for all downloads known to the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 233 |
| 235 // Observers that want to be notified of changes to the set of downloads. | 234 // Observers that want to be notified of changes to the set of downloads. |
| 236 ObserverList<Observer> observers_; | 235 ObserverList<Observer> observers_; |
| 237 | 236 |
| 238 // The current active browser context. | 237 // The current active browser context. |
| 239 content::BrowserContext* browser_context_; | 238 content::BrowserContext* browser_context_; |
| 240 | 239 |
| 241 // Non-owning pointer for handling file writing on the download_thread_. | 240 // Non-owning pointer for handling file writing on the download_thread_. |
| 242 DownloadFileManager* file_manager_; | 241 DownloadFileManager* file_manager_; |
| 243 | 242 |
| 244 // The user's last choice for download directory. This is only used when the | |
| 245 // user wants us to prompt for a save location for each download. | |
| 246 FilePath last_download_path_; | |
| 247 | |
| 248 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 243 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
| 249 content::DownloadManagerDelegate* delegate_; | 244 content::DownloadManagerDelegate* delegate_; |
| 250 | 245 |
| 251 net::NetLog* net_log_; | 246 net::NetLog* net_log_; |
| 252 | 247 |
| 253 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 248 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
| 254 }; | 249 }; |
| 255 | 250 |
| 256 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 251 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| OLD | NEW |