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 DownloadFileManager owns a set of DownloadFile objects, each of which | 5 // The DownloadFileManager owns a set of DownloadFile objects, each of which |
6 // represent one in progress download and performs the disk IO for that | 6 // represent one in progress download and performs the disk IO for that |
7 // download. The DownloadFileManager itself is a singleton object owned by the | 7 // download. The DownloadFileManager itself is a singleton object owned by the |
8 // ResourceDispatcherHost. | 8 // ResourceDispatcherHost. |
9 // | 9 // |
10 // The DownloadFileManager uses the file_thread for performing file write | 10 // The DownloadFileManager uses the file_thread for performing file write |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 #include <map> | 43 #include <map> |
44 | 44 |
45 #include "base/atomic_sequence_num.h" | 45 #include "base/atomic_sequence_num.h" |
46 #include "base/basictypes.h" | 46 #include "base/basictypes.h" |
47 #include "base/gtest_prod_util.h" | 47 #include "base/gtest_prod_util.h" |
48 #include "base/hash_tables.h" | 48 #include "base/hash_tables.h" |
49 #include "base/memory/ref_counted.h" | 49 #include "base/memory/ref_counted.h" |
50 #include "base/timer.h" | 50 #include "base/timer.h" |
51 #include "content/browser/download/download_request_handle.h" | 51 #include "content/browser/download/download_request_handle.h" |
| 52 #include "content/common/content_export.h" |
52 #include "ui/gfx/native_widget_types.h" | 53 #include "ui/gfx/native_widget_types.h" |
53 | 54 |
54 struct DownloadBuffer; | 55 struct DownloadBuffer; |
55 struct DownloadCreateInfo; | 56 struct DownloadCreateInfo; |
56 struct DownloadSaveInfo; | 57 struct DownloadSaveInfo; |
57 class DownloadFile; | 58 class DownloadFile; |
58 class DownloadManager; | 59 class DownloadManager; |
59 class FilePath; | 60 class FilePath; |
60 class GURL; | 61 class GURL; |
61 class ResourceDispatcherHost; | 62 class ResourceDispatcherHost; |
62 | 63 |
63 namespace net { | 64 namespace net { |
64 class URLRequestContextGetter; | 65 class URLRequestContextGetter; |
65 } | 66 } |
66 | 67 |
67 // Manages all in progress downloads. | 68 // Manages all in progress downloads. |
68 class DownloadFileManager | 69 class DownloadFileManager |
69 : public base::RefCountedThreadSafe<DownloadFileManager> { | 70 : public base::RefCountedThreadSafe<DownloadFileManager> { |
70 public: | 71 public: |
71 explicit DownloadFileManager(ResourceDispatcherHost* rdh); | 72 explicit DownloadFileManager(ResourceDispatcherHost* rdh); |
72 | 73 |
73 // Called on shutdown on the UI thread. | 74 // Called on shutdown on the UI thread. |
74 void Shutdown(); | 75 CONTENT_EXPORT void Shutdown(); |
75 | 76 |
76 // Called on the IO or UI threads. | 77 // Called on the IO or UI threads. |
77 int GetNextId(); | 78 int GetNextId(); |
78 | 79 |
79 // Called on UI thread to make DownloadFileManager start the download. | 80 // Called on UI thread to make DownloadFileManager start the download. |
80 void StartDownload(DownloadCreateInfo* info); | 81 void StartDownload(DownloadCreateInfo* info); |
81 | 82 |
82 // Handlers for notifications sent from the IO thread and run on the | 83 // Handlers for notifications sent from the IO thread and run on the |
83 // FILE thread. | 84 // FILE thread. |
84 void UpdateDownload(int id, DownloadBuffer* buffer); | 85 void UpdateDownload(int id, DownloadBuffer* buffer); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Schedule periodic updates of the download progress. This timer | 167 // Schedule periodic updates of the download progress. This timer |
167 // is controlled from the FILE thread, and posts updates to the UI thread. | 168 // is controlled from the FILE thread, and posts updates to the UI thread. |
168 base::RepeatingTimer<DownloadFileManager> update_timer_; | 169 base::RepeatingTimer<DownloadFileManager> update_timer_; |
169 | 170 |
170 ResourceDispatcherHost* resource_dispatcher_host_; | 171 ResourceDispatcherHost* resource_dispatcher_host_; |
171 | 172 |
172 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 173 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
173 }; | 174 }; |
174 | 175 |
175 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 176 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
OLD | NEW |