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 |
11 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/sequenced_task_runner_helpers.h" | 16 #include "base/sequenced_task_runner_helpers.h" |
17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
18 #include "content/browser/download/download_item_impl_delegate.h" | 18 #include "content/browser/download/download_item_impl_delegate.h" |
19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
20 #include "content/public/browser/download_manager.h" | 20 #include "content/public/browser/download_manager.h" |
| 21 #include "content/public/browser/download_url_parameters.h" |
21 | 22 |
22 namespace net { | 23 namespace net { |
23 class BoundNetLog; | 24 class BoundNetLog; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class DownloadFileFactory; | 28 class DownloadFileFactory; |
28 class DownloadItemFactory; | 29 class DownloadItemFactory; |
29 class DownloadItemImpl; | 30 class DownloadItemImpl; |
30 | 31 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; | 92 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; |
92 | 93 |
93 // For testing. | 94 // For testing. |
94 friend class DownloadManagerTest; | 95 friend class DownloadManagerTest; |
95 friend class DownloadTest; | 96 friend class DownloadTest; |
96 | 97 |
97 friend class base::RefCountedThreadSafe<DownloadManagerImpl>; | 98 friend class base::RefCountedThreadSafe<DownloadManagerImpl>; |
98 | 99 |
99 virtual ~DownloadManagerImpl(); | 100 virtual ~DownloadManagerImpl(); |
100 | 101 |
101 // Creates the download item. Must be called on the UI thread. | 102 // Retrieves the download item corresponding to the passed |
102 virtual DownloadItemImpl* CreateDownloadItem( | 103 // DownloadCreateInfo. This will create the download item |
103 DownloadCreateInfo* info, const net::BoundNetLog& bound_net_log); | 104 // if this is a new download (common case) or retrieve an |
| 105 // existing download item if this is a resuming download. |
| 106 virtual DownloadItemImpl* GetOrCreateDownloadItem(DownloadCreateInfo* info); |
104 | 107 |
105 // Get next download id. | 108 // Get next download id. |
106 DownloadId GetNextId(); | 109 DownloadId GetNextId(); |
107 | 110 |
108 // Called on the FILE thread to check the existence of a downloaded file. | 111 // Called on the FILE thread to check the existence of a downloaded file. |
109 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); | 112 void CheckForFileRemovalOnFileThread(int32 download_id, const FilePath& path); |
110 | 113 |
111 // Called on the UI thread if the FILE thread detects the removal of | 114 // Called on the UI thread if the FILE thread detects the removal of |
112 // the downloaded file. The UI thread updates the state of the file | 115 // the downloaded file. The UI thread updates the state of the file |
113 // and then notifies this update to the file's observer. | 116 // and then notifies this update to the file's observer. |
114 void OnFileRemovalDetected(int32 download_id); | 117 void OnFileRemovalDetected(int32 download_id); |
115 | 118 |
116 // Remove from internal maps. | 119 // Remove from internal maps. |
117 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); | 120 int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); |
118 | 121 |
119 // Overridden from DownloadItemImplDelegate | 122 // Overridden from DownloadItemImplDelegate |
120 // (Note that |GetBrowserContext| are present in both interfaces.) | 123 // (Note that |GetBrowserContext| are present in both interfaces.) |
121 virtual void DetermineDownloadTarget( | 124 virtual void DetermineDownloadTarget( |
122 DownloadItemImpl* item, const DownloadTargetCallback& callback) OVERRIDE; | 125 DownloadItemImpl* item, const DownloadTargetCallback& callback) OVERRIDE; |
123 virtual bool ShouldCompleteDownload( | 126 virtual bool ShouldCompleteDownload( |
124 DownloadItemImpl* item, const base::Closure& complete_callback) OVERRIDE; | 127 DownloadItemImpl* item, const base::Closure& complete_callback) OVERRIDE; |
125 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; | 128 virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
126 virtual bool ShouldOpenDownload( | 129 virtual bool ShouldOpenDownload( |
127 DownloadItemImpl* item, | 130 DownloadItemImpl* item, |
128 const ShouldOpenDownloadCallback& callback) OVERRIDE; | 131 const ShouldOpenDownloadCallback& callback) OVERRIDE; |
129 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; | 132 virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; |
| 133 virtual void ResumeInterruptedDownload( |
| 134 scoped_ptr<content::DownloadUrlParameters> params, |
| 135 content::DownloadId id) OVERRIDE; |
130 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; | 136 virtual void DownloadOpened(DownloadItemImpl* download) OVERRIDE; |
131 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; | 137 virtual void DownloadRemoved(DownloadItemImpl* download) OVERRIDE; |
132 virtual void ShowDownloadInBrowser(DownloadItemImpl* download) OVERRIDE; | 138 virtual void ShowDownloadInBrowser(DownloadItemImpl* download) OVERRIDE; |
133 | 139 |
134 // Factory for creation of downloads items. | 140 // Factory for creation of downloads items. |
135 scoped_ptr<DownloadItemFactory> item_factory_; | 141 scoped_ptr<DownloadItemFactory> item_factory_; |
136 | 142 |
137 // Factory for the creation of download files. | 143 // Factory for the creation of download files. |
138 scoped_ptr<DownloadFileFactory> file_factory_; | 144 scoped_ptr<DownloadFileFactory> file_factory_; |
139 | 145 |
(...skipping 18 matching lines...) Expand all Loading... |
158 DownloadManagerDelegate* delegate_; | 164 DownloadManagerDelegate* delegate_; |
159 | 165 |
160 net::NetLog* net_log_; | 166 net::NetLog* net_log_; |
161 | 167 |
162 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 168 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
163 }; | 169 }; |
164 | 170 |
165 } // namespace content | 171 } // namespace content |
166 | 172 |
167 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 173 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |