| 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 "net/base/net_errors.h" | 53 #include "net/base/net_errors.h" |
| 53 #include "ui/gfx/native_widget_types.h" | 54 #include "ui/gfx/native_widget_types.h" |
| 54 | 55 |
| 55 struct DownloadBuffer; | 56 struct DownloadBuffer; |
| 56 struct DownloadCreateInfo; | 57 struct DownloadCreateInfo; |
| 57 struct DownloadSaveInfo; | 58 struct DownloadSaveInfo; |
| 58 class DownloadFile; | 59 class DownloadFile; |
| 59 class DownloadManager; | 60 class DownloadManager; |
| 60 class FilePath; | 61 class FilePath; |
| 61 class GURL; | 62 class GURL; |
| 62 class ResourceDispatcherHost; | 63 class ResourceDispatcherHost; |
| 63 | 64 |
| 64 namespace net { | 65 namespace net { |
| 65 class URLRequestContextGetter; | 66 class URLRequestContextGetter; |
| 66 } | 67 } |
| 67 | 68 |
| 68 // Manages all in progress downloads. | 69 // Manages all in progress downloads. |
| 69 class DownloadFileManager | 70 class DownloadFileManager |
| 70 : public base::RefCountedThreadSafe<DownloadFileManager> { | 71 : public base::RefCountedThreadSafe<DownloadFileManager> { |
| 71 public: | 72 public: |
| 72 explicit DownloadFileManager(ResourceDispatcherHost* rdh); | 73 explicit DownloadFileManager(ResourceDispatcherHost* rdh); |
| 73 | 74 |
| 74 // Called on shutdown on the UI thread. | 75 // Called on shutdown on the UI thread. |
| 75 void Shutdown(); | 76 CONTENT_EXPORT void Shutdown(); |
| 76 | 77 |
| 77 // Called on the IO or UI threads. | 78 // Called on the IO or UI threads. |
| 78 int GetNextId(); | 79 int GetNextId(); |
| 79 | 80 |
| 80 // Called on UI thread to make DownloadFileManager start the download. | 81 // Called on UI thread to make DownloadFileManager start the download. |
| 81 void StartDownload(DownloadCreateInfo* info); | 82 void StartDownload(DownloadCreateInfo* info); |
| 82 | 83 |
| 83 // Handlers for notifications sent from the IO thread and run on the | 84 // Handlers for notifications sent from the IO thread and run on the |
| 84 // FILE thread. | 85 // FILE thread. |
| 85 void UpdateDownload(int id, DownloadBuffer* buffer); | 86 void UpdateDownload(int id, DownloadBuffer* buffer); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Schedule periodic updates of the download progress. This timer | 168 // Schedule periodic updates of the download progress. This timer |
| 168 // is controlled from the FILE thread, and posts updates to the UI thread. | 169 // is controlled from the FILE thread, and posts updates to the UI thread. |
| 169 base::RepeatingTimer<DownloadFileManager> update_timer_; | 170 base::RepeatingTimer<DownloadFileManager> update_timer_; |
| 170 | 171 |
| 171 ResourceDispatcherHost* resource_dispatcher_host_; | 172 ResourceDispatcherHost* resource_dispatcher_host_; |
| 172 | 173 |
| 173 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 174 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 174 }; | 175 }; |
| 175 | 176 |
| 176 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 177 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |