| 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 | 5 |
| 6 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 6 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| 7 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 7 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| 8 #pragma once | 8 #pragma once |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 | 12 |
| 13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/message_loop_helpers.h" | 17 #include "base/message_loop_helpers.h" |
| 18 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
| 19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 20 #include "content/browser/download/download_item_impl.h" | 20 #include "content/browser/download/download_item_impl.h" |
| 21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
| 22 #include "content/public/browser/download_manager.h" | 22 #include "content/public/browser/download_manager.h" |
| 23 | 23 |
| 24 class CONTENT_EXPORT DownloadManagerImpl | 24 class CONTENT_EXPORT DownloadManagerImpl |
| 25 : public content::DownloadManager, | 25 : public content::DownloadManager, |
| 26 public DownloadItemImpl::Delegate { | 26 public DownloadItemImpl::Delegate { |
| 27 public: | 27 public: |
| 28 DownloadManagerImpl(content::DownloadManagerDelegate* delegate); | 28 DownloadManagerImpl(content::DownloadManagerDelegate* delegate, |
| 29 net::NetLog* net_log); |
| 29 | 30 |
| 30 // content::DownloadManager functions. | 31 // content::DownloadManager functions. |
| 31 virtual void Shutdown() OVERRIDE; | 32 virtual void Shutdown() OVERRIDE; |
| 32 virtual void GetTemporaryDownloads(const FilePath& dir_path, | 33 virtual void GetTemporaryDownloads(const FilePath& dir_path, |
| 33 DownloadVector* result) OVERRIDE; | 34 DownloadVector* result) OVERRIDE; |
| 34 virtual void GetAllDownloads(const FilePath& dir_path, | 35 virtual void GetAllDownloads(const FilePath& dir_path, |
| 35 DownloadVector* result) OVERRIDE; | 36 DownloadVector* result) OVERRIDE; |
| 36 virtual void SearchDownloads(const string16& query, | 37 virtual void SearchDownloads(const string16& query, |
| 37 DownloadVector* result) OVERRIDE; | 38 DownloadVector* result) OVERRIDE; |
| 38 virtual bool Init(content::BrowserContext* browser_context) OVERRIDE; | 39 virtual bool Init(content::BrowserContext* browser_context) OVERRIDE; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 174 |
| 174 // Remove from internal maps. | 175 // Remove from internal maps. |
| 175 int RemoveDownloadItems(const DownloadVector& pending_deletes); | 176 int RemoveDownloadItems(const DownloadVector& pending_deletes); |
| 176 | 177 |
| 177 // Called when a download entry is committed to the persistent store. | 178 // Called when a download entry is committed to the persistent store. |
| 178 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 179 void OnDownloadItemAddedToPersistentStore(int32 download_id, int64 db_handle); |
| 179 | 180 |
| 180 // Called when Save Page As entry is committed to the persistent store. | 181 // Called when Save Page As entry is committed to the persistent store. |
| 181 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); | 182 void OnSavePageItemAddedToPersistentStore(int32 download_id, int64 db_handle); |
| 182 | 183 |
| 184 virtual net::NetLog* GetNetLog(); |
| 185 |
| 183 // For unit tests only. | 186 // For unit tests only. |
| 184 virtual void SetFileManager(DownloadFileManager* file_manager) OVERRIDE; | 187 virtual void SetFileManager(DownloadFileManager* file_manager) OVERRIDE; |
| 185 | 188 |
| 186 // |downloads_| is the owning set for all downloads known to the | 189 // |downloads_| is the owning set for all downloads known to the |
| 187 // DownloadManager. This includes downloads started by the user in | 190 // DownloadManager. This includes downloads started by the user in |
| 188 // this session, downloads initialized from the history system, and | 191 // this session, downloads initialized from the history system, and |
| 189 // "save page as" downloads. All other DownloadItem containers in | 192 // "save page as" downloads. All other DownloadItem containers in |
| 190 // the DownloadManager are maps; they do not own the DownloadItems. | 193 // the DownloadManager are maps; they do not own the DownloadItems. |
| 191 // Note that this is the only place (with any functional implications; | 194 // Note that this is the only place (with any functional implications; |
| 192 // see save_page_downloads_ below) that "save page as" downloads are | 195 // see save_page_downloads_ below) that "save page as" downloads are |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // user wants us to prompt for a save location for each download. | 246 // user wants us to prompt for a save location for each download. |
| 244 FilePath last_download_path_; | 247 FilePath last_download_path_; |
| 245 | 248 |
| 246 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 249 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
| 247 content::DownloadManagerDelegate* delegate_; | 250 content::DownloadManagerDelegate* delegate_; |
| 248 | 251 |
| 249 // TODO(rdsmith): Remove when http://crbug.com/85408 is fixed. | 252 // TODO(rdsmith): Remove when http://crbug.com/85408 is fixed. |
| 250 // For debugging only. | 253 // For debugging only. |
| 251 int64 largest_db_handle_in_history_; | 254 int64 largest_db_handle_in_history_; |
| 252 | 255 |
| 256 net::NetLog* net_log_; |
| 257 |
| 253 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 258 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
| 254 }; | 259 }; |
| 255 | 260 |
| 256 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 261 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
| OLD | NEW |