OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The DownloadManager object manages the process of downloading, including | 5 // The DownloadManager object manages the process of downloading, including |
6 // updates to the history system and providing the information for displaying | 6 // updates to the history system and providing the information for displaying |
7 // the downloads view in the Destinations tab. There is one DownloadManager per | 7 // the downloads view in the Destinations tab. There is one DownloadManager per |
8 // active browser context in Chrome. | 8 // active browser context in Chrome. |
9 // | 9 // |
10 // Download observers: | 10 // Download observers: |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "base/hash_tables.h" | 39 #include "base/hash_tables.h" |
40 #include "base/memory/ref_counted.h" | 40 #include "base/memory/ref_counted.h" |
41 #include "base/memory/scoped_ptr.h" | 41 #include "base/memory/scoped_ptr.h" |
42 #include "base/memory/weak_ptr.h" | 42 #include "base/memory/weak_ptr.h" |
43 #include "base/observer_list.h" | 43 #include "base/observer_list.h" |
44 #include "base/time.h" | 44 #include "base/time.h" |
45 #include "content/browser/browser_thread.h" | 45 #include "content/browser/browser_thread.h" |
46 #include "content/browser/download/download_item.h" | 46 #include "content/browser/download/download_item.h" |
47 #include "content/browser/download/download_request_handle.h" | 47 #include "content/browser/download/download_request_handle.h" |
48 #include "content/browser/download/download_status_updater_delegate.h" | 48 #include "content/browser/download/download_status_updater_delegate.h" |
| 49 #include "content/common/content_export.h" |
49 | 50 |
50 class DownloadFileManager; | 51 class DownloadFileManager; |
51 class DownloadManagerDelegate; | 52 class DownloadManagerDelegate; |
52 class DownloadStatusUpdater; | 53 class DownloadStatusUpdater; |
53 class GURL; | 54 class GURL; |
54 class ResourceDispatcherHost; | 55 class ResourceDispatcherHost; |
55 class TabContents; | 56 class TabContents; |
56 struct DownloadCreateInfo; | 57 struct DownloadCreateInfo; |
57 struct DownloadSaveInfo; | 58 struct DownloadSaveInfo; |
58 | 59 |
59 namespace content { | 60 namespace content { |
60 class BrowserContext; | 61 class BrowserContext; |
61 } | 62 } |
62 | 63 |
63 // Browser's download manager: manages all downloads and destination view. | 64 // Browser's download manager: manages all downloads and destination view. |
64 class DownloadManager | 65 class CONTENT_EXPORT DownloadManager |
65 : public base::RefCountedThreadSafe<DownloadManager, | 66 : public base::RefCountedThreadSafe<DownloadManager, |
66 BrowserThread::DeleteOnUIThread>, | 67 BrowserThread::DeleteOnUIThread>, |
67 public DownloadStatusUpdaterDelegate { | 68 public DownloadStatusUpdaterDelegate { |
68 public: | 69 public: |
69 DownloadManager(DownloadManagerDelegate* delegate, | 70 DownloadManager(DownloadManagerDelegate* delegate, |
70 DownloadStatusUpdater* status_updater); | 71 DownloadStatusUpdater* status_updater); |
71 | 72 |
72 // Shutdown the download manager. Must be called before destruction. | 73 // Shutdown the download manager. Must be called before destruction. |
73 void Shutdown(); | 74 void Shutdown(); |
74 | 75 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 DownloadManagerDelegate* delegate() const { return delegate_; } | 269 DownloadManagerDelegate* delegate() const { return delegate_; } |
269 | 270 |
270 private: | 271 private: |
271 typedef std::set<DownloadItem*> DownloadSet; | 272 typedef std::set<DownloadItem*> DownloadSet; |
272 typedef base::hash_map<int64, DownloadItem*> DownloadMap; | 273 typedef base::hash_map<int64, DownloadItem*> DownloadMap; |
273 | 274 |
274 // For testing. | 275 // For testing. |
275 friend class DownloadManagerTest; | 276 friend class DownloadManagerTest; |
276 friend class MockDownloadManager; | 277 friend class MockDownloadManager; |
277 | 278 |
| 279 friend base::RefCountedThreadSafe<DownloadManager, |
| 280 BrowserThread::DeleteOnUIThread>; |
278 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 281 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
279 friend class DeleteTask<DownloadManager>; | 282 friend class DeleteTask<DownloadManager>; |
280 | 283 |
281 virtual ~DownloadManager(); | 284 virtual ~DownloadManager(); |
282 | 285 |
283 // Called on the FILE thread to check the existence of a downloaded file. | 286 // Called on the FILE thread to check the existence of a downloaded file. |
284 void CheckForFileRemovalOnFileThread(int64 db_handle, const FilePath& path); | 287 void CheckForFileRemovalOnFileThread(int64 db_handle, const FilePath& path); |
285 | 288 |
286 // Called on the UI thread if the FILE thread detects the removal of | 289 // Called on the UI thread if the FILE thread detects the removal of |
287 // the downloaded file. The UI thread updates the state of the file | 290 // the downloaded file. The UI thread updates the state of the file |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 DownloadManagerDelegate* delegate_; | 400 DownloadManagerDelegate* delegate_; |
398 | 401 |
399 // TODO(rdsmith): Remove when http://crbug.com/84508 is fixed. | 402 // TODO(rdsmith): Remove when http://crbug.com/84508 is fixed. |
400 // For debugging only. | 403 // For debugging only. |
401 int64 largest_db_handle_in_history_; | 404 int64 largest_db_handle_in_history_; |
402 | 405 |
403 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 406 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
404 }; | 407 }; |
405 | 408 |
406 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 409 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
OLD | NEW |