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 18 matching lines...) Expand all Loading... |
29 class DownloadItemFactory; | 29 class DownloadItemFactory; |
30 class DownloadItemImpl; | 30 class DownloadItemImpl; |
31 class DownloadRequestHandleInterface; | 31 class DownloadRequestHandleInterface; |
32 | 32 |
33 class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager, | 33 class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager, |
34 private DownloadItemImplDelegate { | 34 private DownloadItemImplDelegate { |
35 public: | 35 public: |
36 // Caller guarantees that |net_log| will remain valid | 36 // Caller guarantees that |net_log| will remain valid |
37 // for the lifetime of DownloadManagerImpl (until Shutdown() is called). | 37 // for the lifetime of DownloadManagerImpl (until Shutdown() is called). |
38 DownloadManagerImpl(net::NetLog* net_log, BrowserContext* browser_context); | 38 DownloadManagerImpl(net::NetLog* net_log, BrowserContext* browser_context); |
| 39 virtual ~DownloadManagerImpl(); |
39 | 40 |
40 // Implementation functions (not part of the DownloadManager interface). | 41 // Implementation functions (not part of the DownloadManager interface). |
41 | 42 |
42 // Creates a download item for the SavePackage system. | 43 // Creates a download item for the SavePackage system. |
43 // Must be called on the UI thread. Note that the DownloadManager | 44 // Must be called on the UI thread. Note that the DownloadManager |
44 // retains ownership. | 45 // retains ownership. |
45 virtual DownloadItemImpl* CreateSavePackageDownloadItem( | 46 virtual DownloadItemImpl* CreateSavePackageDownloadItem( |
46 const base::FilePath& main_file_path, | 47 const base::FilePath& main_file_path, |
47 const GURL& page_url, | 48 const GURL& page_url, |
48 const std::string& mime_type, | 49 const std::string& mime_type, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 96 |
96 private: | 97 private: |
97 typedef std::set<DownloadItem*> DownloadSet; | 98 typedef std::set<DownloadItem*> DownloadSet; |
98 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; | 99 typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; |
99 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; | 100 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; |
100 | 101 |
101 // For testing. | 102 // For testing. |
102 friend class DownloadManagerTest; | 103 friend class DownloadManagerTest; |
103 friend class DownloadTest; | 104 friend class DownloadTest; |
104 | 105 |
105 friend class base::RefCountedThreadSafe<DownloadManagerImpl>; | |
106 | |
107 virtual ~DownloadManagerImpl(); | |
108 | |
109 // Create a new active item based on the info. Separate from | 106 // Create a new active item based on the info. Separate from |
110 // StartDownload() for testing. | 107 // StartDownload() for testing. |
111 DownloadItemImpl* CreateActiveItem(DownloadId id, | 108 DownloadItemImpl* CreateActiveItem(DownloadId id, |
112 const DownloadCreateInfo& info); | 109 const DownloadCreateInfo& info); |
113 | 110 |
114 // Get next download id. | 111 // Get next download id. |
115 DownloadId GetNextId(); | 112 DownloadId GetNextId(); |
116 | 113 |
117 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. | 114 // Called with the result of DownloadManagerDelegate::CheckForFileExistence. |
118 // Updates the state of the file and then notifies this update to the file's | 115 // Updates the state of the file and then notifies this update to the file's |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 ObserverList<Observer> observers_; | 156 ObserverList<Observer> observers_; |
160 | 157 |
161 // The current active browser context. | 158 // The current active browser context. |
162 BrowserContext* browser_context_; | 159 BrowserContext* browser_context_; |
163 | 160 |
164 // Allows an embedder to control behavior. Guaranteed to outlive this object. | 161 // Allows an embedder to control behavior. Guaranteed to outlive this object. |
165 DownloadManagerDelegate* delegate_; | 162 DownloadManagerDelegate* delegate_; |
166 | 163 |
167 net::NetLog* net_log_; | 164 net::NetLog* net_log_; |
168 | 165 |
| 166 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; |
| 167 |
169 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); | 168 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); |
170 }; | 169 }; |
171 | 170 |
172 } // namespace content | 171 } // namespace content |
173 | 172 |
174 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ | 173 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ |
OLD | NEW |