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