| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 int32 download_id, | 67 int32 download_id, |
| 68 content::DownloadInterruptReason reason) OVERRIDE; | 68 content::DownloadInterruptReason reason) OVERRIDE; |
| 69 virtual int RemoveDownloadsBetween(base::Time remove_begin, | 69 virtual int RemoveDownloadsBetween(base::Time remove_begin, |
| 70 base::Time remove_end) OVERRIDE; | 70 base::Time remove_end) OVERRIDE; |
| 71 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; | 71 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; |
| 72 virtual int RemoveAllDownloads() OVERRIDE; | 72 virtual int RemoveAllDownloads() OVERRIDE; |
| 73 virtual void DownloadUrl( | 73 virtual void DownloadUrl( |
| 74 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; | 74 scoped_ptr<content::DownloadUrlParameters> params) OVERRIDE; |
| 75 virtual void AddObserver(Observer* observer) OVERRIDE; | 75 virtual void AddObserver(Observer* observer) OVERRIDE; |
| 76 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 76 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
| 77 virtual void OnPersistentStoreQueryComplete( | 77 virtual content::DownloadItem* CreateDownloadItem( |
| 78 std::vector<content::DownloadPersistentStoreInfo>* entries) OVERRIDE; | 78 const FilePath& path, |
| 79 virtual void OnItemAddedToPersistentStore(int32 download_id, | 79 const GURL& url, |
| 80 int64 db_handle) OVERRIDE; | 80 const GURL& referrer_url, |
| 81 const base::Time& start_time, |
| 82 const base::Time& end_time, |
| 83 int64 received_bytes, |
| 84 int64 total_bytes, |
| 85 content::DownloadItem::DownloadState state, |
| 86 bool opened) OVERRIDE; |
| 81 virtual int InProgressCount() const OVERRIDE; | 87 virtual int InProgressCount() const OVERRIDE; |
| 82 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; | 88 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; |
| 83 virtual void CheckForHistoryFilesRemoval() OVERRIDE; | 89 virtual void CheckForHistoryFilesRemoval() OVERRIDE; |
| 84 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; | 90 virtual content::DownloadItem* GetDownloadItem(int id) OVERRIDE; |
| 85 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; | 91 virtual content::DownloadItem* GetDownload(int id) OVERRIDE; |
| 86 virtual void SavePageDownloadFinished( | |
| 87 content::DownloadItem* download) OVERRIDE; | |
| 88 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; | 92 virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; |
| 89 | 93 |
| 90 private: | 94 private: |
| 91 typedef std::set<content::DownloadItem*> DownloadSet; | 95 typedef std::set<content::DownloadItem*> DownloadSet; |
| 92 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; | 96 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; |
| 93 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; | 97 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; |
| 94 | 98 |
| 95 // For testing. | 99 // For testing. |
| 96 friend class DownloadManagerTest; | 100 friend class DownloadManagerTest; |
| 97 friend class DownloadTest; | 101 friend class DownloadTest; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Does nothing if the download is not in the history DB. | 135 // Does nothing if the download is not in the history DB. |
| 132 void RemoveFromActiveList(DownloadItemImpl* download); | 136 void RemoveFromActiveList(DownloadItemImpl* download); |
| 133 | 137 |
| 134 // Inform observers that the model has changed. | 138 // Inform observers that the model has changed. |
| 135 void NotifyModelChanged(); | 139 void NotifyModelChanged(); |
| 136 | 140 |
| 137 // Debugging routine to confirm relationship between below | 141 // Debugging routine to confirm relationship between below |
| 138 // containers; no-op if NDEBUG. | 142 // containers; no-op if NDEBUG. |
| 139 void AssertContainersConsistent() const; | 143 void AssertContainersConsistent() const; |
| 140 | 144 |
| 141 // Add a DownloadItem to history_downloads_. | |
| 142 void AddDownloadItemToHistory(DownloadItemImpl* item, int64 db_handle); | |
| 143 | |
| 144 // Remove from internal maps. | 145 // Remove from internal maps. |
| 145 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); | 146 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); |
| 146 | 147 |
| 147 // Called in response to our request to the DownloadFileManager to | 148 // Called in response to our request to the DownloadFileManager to |
| 148 // create a DownloadFile. A |reason| of | 149 // create a DownloadFile. A |reason| of |
| 149 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. | 150 // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. |
| 150 void OnDownloadFileCreated( | 151 void OnDownloadFileCreated( |
| 151 int32 download_id, content::DownloadInterruptReason reason); | 152 int32 download_id, content::DownloadInterruptReason reason); |
| 152 | 153 |
| 153 // Called when the delegate has completed determining the download target. | 154 // Called when the delegate has completed determining the download target. |
| 154 // Arguments following |download_id| are as per | 155 // Arguments following |download_id| are as per |
| 155 // content::DownloadTargetCallback. | 156 // content::DownloadTargetCallback. |
| 156 void OnDownloadTargetDetermined( | 157 void OnDownloadTargetDetermined( |
| 157 int32 download_id, | 158 int32 download_id, |
| 158 const FilePath& target_path, | 159 const FilePath& target_path, |
| 159 content::DownloadItem::TargetDisposition disposition, | 160 content::DownloadItem::TargetDisposition disposition, |
| 160 content::DownloadDangerType danger_type, | 161 content::DownloadDangerType danger_type, |
| 161 const FilePath& intermediate_path); | 162 const FilePath& intermediate_path); |
| 162 | 163 |
| 163 // Called when a download entry is committed to the persistent store. | |
| 164 void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item); | |
| 165 | |
| 166 // Called when Save Page As entry is committed to the persistent store. | |
| 167 void OnSavePageItemAddedToPersistentStore(DownloadItemImpl* item); | |
| 168 | |
| 169 // Overridden from DownloadItemImplDelegate | 164 // Overridden from DownloadItemImplDelegate |
| 170 // (Note that |GetBrowserContext| are present in both interfaces.) | 165 // (Note that |GetBrowserContext| are present in both interfaces.) |
| 171 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE; | 166 virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE; |
| 172 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; | 167 virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; |
| 173 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; | 168 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
| 174 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; | 169 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; |
| 175 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE; | 170 virtual void MaybeCompleteDownload(DownloadItemImpl* download) OVERRIDE; |
| 176 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE; | 171 virtual void DownloadStopped(DownloadItemImpl* download) OVERRIDE; |
| 177 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE; | 172 virtual void DownloadCompleted(DownloadItemImpl* download) OVERRIDE; |
| 178 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; | 173 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; |
| 179 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; | 174 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; |
| 180 virtual void DownloadRenamedToIntermediateName( | 175 virtual void DownloadRenamedToIntermediateName( |
| 181 DownloadItemImpl* download) OVERRIDE; | 176 DownloadItemImpl* download) OVERRIDE; |
| 182 virtual void DownloadRenamedToFinalName(DownloadItemImpl* download) OVERRIDE; | |
| 183 virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE; | 177 virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE; |
| 184 | 178 |
| 185 // Factory for creation of downloads items. | 179 // Factory for creation of downloads items. |
| 186 scoped_ptr<content::DownloadItemFactory> factory_; | 180 scoped_ptr<content::DownloadItemFactory> factory_; |
| 187 | 181 |
| 188 // |downloads_| is the owning set for all downloads known to the | 182 // |downloads_| is the owning set for all downloads known to the |
| 189 // DownloadManager. This includes downloads started by the user in | 183 // DownloadManager. This includes downloads started by the user in |
| 190 // this session, downloads initialized from the history system, and | 184 // this session, downloads initialized from the history system, and |
| 191 // "save page as" downloads. All other DownloadItem containers in | 185 // "save page as" downloads. All other DownloadItem containers in |
| 192 // the DownloadManager are maps; they do not own the DownloadItems. | 186 // the DownloadManager are maps; they do not own the DownloadItems. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 220 |
| 227 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 221 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
| 228 content::DownloadManagerDelegate* delegate_; | 222 content::DownloadManagerDelegate* delegate_; |
| 229 | 223 |
| 230 net::NetLog* net_log_; | 224 net::NetLog* net_log_; |
| 231 | 225 |
| 232 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 226 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
| 233 }; | 227 }; |
| 234 | 228 |
| 235 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 229 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| OLD | NEW |