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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 scoped_ptr<ByteStreamReader> stream) OVERRIDE; | 61 scoped_ptr<ByteStreamReader> stream) OVERRIDE; |
62 virtual void CancelDownload(int32 download_id) OVERRIDE; | 62 virtual void CancelDownload(int32 download_id) OVERRIDE; |
63 virtual int RemoveDownloadsBetween(base::Time remove_begin, | 63 virtual int RemoveDownloadsBetween(base::Time remove_begin, |
64 base::Time remove_end) OVERRIDE; | 64 base::Time remove_end) OVERRIDE; |
65 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; | 65 virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; |
66 virtual int RemoveAllDownloads() OVERRIDE; | 66 virtual int RemoveAllDownloads() OVERRIDE; |
67 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE; | 67 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> params) OVERRIDE; |
68 virtual void AddObserver(Observer* observer) OVERRIDE; | 68 virtual void AddObserver(Observer* observer) OVERRIDE; |
69 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 69 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
70 virtual content::DownloadItem* CreateDownloadItem( | 70 virtual content::DownloadItem* CreateDownloadItem( |
71 const FilePath& path, | 71 const FilePath& current_path, |
72 const GURL& url, | 72 const FilePath& target_path, |
| 73 const std::vector<GURL>& url_chain, |
73 const GURL& referrer_url, | 74 const GURL& referrer_url, |
74 const base::Time& start_time, | 75 const base::Time& start_time, |
75 const base::Time& end_time, | 76 const base::Time& end_time, |
76 int64 received_bytes, | 77 int64 received_bytes, |
77 int64 total_bytes, | 78 int64 total_bytes, |
78 content::DownloadItem::DownloadState state, | 79 content::DownloadItem::DownloadState state, |
| 80 DownloadDangerType danger_type, |
| 81 DownloadInterruptReason interrupt_reason, |
79 bool opened) OVERRIDE; | 82 bool opened) OVERRIDE; |
80 virtual int InProgressCount() const OVERRIDE; | 83 virtual int InProgressCount() const OVERRIDE; |
81 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 84 virtual BrowserContext* GetBrowserContext() const OVERRIDE; |
82 virtual void CheckForHistoryFilesRemoval() OVERRIDE; | 85 virtual void CheckForHistoryFilesRemoval() OVERRIDE; |
83 virtual DownloadItem* GetDownload(int id) OVERRIDE; | 86 virtual DownloadItem* GetDownload(int id) OVERRIDE; |
84 virtual void MockDownloadOpenForTesting() OVERRIDE; | 87 virtual void MockDownloadOpenForTesting() OVERRIDE; |
85 | 88 |
86 // For testing; specifically, accessed from TestFileErrorInjector. | 89 // For testing; specifically, accessed from TestFileErrorInjector. |
87 void SetDownloadItemFactoryForTesting( | 90 void SetDownloadItemFactoryForTesting( |
88 scoped_ptr<DownloadItemFactory> item_factory); | 91 scoped_ptr<DownloadItemFactory> item_factory); |
89 void SetDownloadFileFactoryForTesting( | 92 void SetDownloadFileFactoryForTesting( |
90 scoped_ptr<DownloadFileFactory> file_factory); | 93 scoped_ptr<DownloadFileFactory> file_factory); |
91 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting(); | 94 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting(); |
92 | 95 |
93 private: | 96 private: |
94 typedef std::set<DownloadItem*> DownloadSet; | 97 typedef std::set<DownloadItem*> DownloadSet; |
95 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; | 98 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; |
96 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; | 99 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; |
97 | 100 |
98 // For testing. | 101 // For testing. |
99 friend class DownloadManagerTest; | 102 friend class DownloadManagerTest; |
100 friend class DownloadTest; | 103 friend class DownloadTest; |
101 | 104 |
102 friend class base::RefCountedThreadSafe<DownloadManagerImpl>; | 105 friend class base::RefCountedThreadSafe<DownloadManagerImpl>; |
103 | 106 |
104 virtual ~DownloadManagerImpl(); | 107 virtual ~DownloadManagerImpl(); |
105 | 108 |
106 // Retrieves the download item corresponding to the passed | 109 // Retrieves the download item corresponding to the passed |
107 // DownloadCreateInfo. This will create the download item | 110 // DownloadCreateInfo (generated on the IO thread). This will create |
108 // if this is a new download (common case) or retrieve an | 111 // the download item if this is a new download (common case) or retrieve an |
109 // existing download item if this is a resuming download. | 112 // existing download item if this is a resuming download. |
110 virtual DownloadItemImpl* GetOrCreateDownloadItem(DownloadCreateInfo* info); | 113 virtual DownloadItemImpl* GetOrCreateDownloadItem(DownloadCreateInfo* info); |
111 | 114 |
112 // Get next download id. | 115 // Get next download id. |
113 DownloadId GetNextId(); | 116 DownloadId GetNextId(); |
114 | 117 |
115 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. | 118 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. |
116 // Updates the state of the file and then notifies this update to the file's | 119 // Updates the state of the file and then notifies this update to the file's |
117 // observer. | 120 // observer. |
118 void OnFileExistenceChecked(int32 download_id, bool result); | 121 void OnFileExistenceChecked(int32 download_id, bool result); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 172 |
170 // Do we actually open downloads when requested? For testing purposes only. | 173 // Do we actually open downloads when requested? For testing purposes only. |
171 bool open_enabled_; | 174 bool open_enabled_; |
172 | 175 |
173 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 176 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
174 }; | 177 }; |
175 | 178 |
176 } // namespace content | 179 } // namespace content |
177 | 180 |
178 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 181 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |