| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_id.h" | 51 #include "content/browser/download/download_id.h" |
| 52 #include "content/browser/download/download_request_handle.h" | 52 #include "content/browser/download/download_request_handle.h" |
| 53 #include "content/browser/download/interrupt_reasons.h" |
| 53 #include "content/common/content_export.h" | 54 #include "content/common/content_export.h" |
| 54 #include "net/base/net_errors.h" | 55 #include "net/base/net_errors.h" |
| 55 #include "ui/gfx/native_widget_types.h" | 56 #include "ui/gfx/native_widget_types.h" |
| 56 | 57 |
| 57 struct DownloadCreateInfo; | 58 struct DownloadCreateInfo; |
| 58 struct DownloadSaveInfo; | 59 struct DownloadSaveInfo; |
| 59 class DownloadFile; | 60 class DownloadFile; |
| 60 class DownloadManager; | 61 class DownloadManager; |
| 61 class FilePath; | 62 class FilePath; |
| 62 class GURL; | 63 class GURL; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 79 // Called on shutdown on the UI thread. | 80 // Called on shutdown on the UI thread. |
| 80 void Shutdown(); | 81 void Shutdown(); |
| 81 | 82 |
| 82 // Called on UI thread to make DownloadFileManager start the download. | 83 // Called on UI thread to make DownloadFileManager start the download. |
| 83 void StartDownload(DownloadCreateInfo* info); | 84 void StartDownload(DownloadCreateInfo* info); |
| 84 | 85 |
| 85 // Handlers for notifications sent from the IO thread and run on the | 86 // Handlers for notifications sent from the IO thread and run on the |
| 86 // FILE thread. | 87 // FILE thread. |
| 87 void UpdateDownload(DownloadId global_id, content::DownloadBuffer* buffer); | 88 void UpdateDownload(DownloadId global_id, content::DownloadBuffer* buffer); |
| 88 | 89 |
| 89 // |net_error| is 0 for normal completions, and non-0 for errors. | 90 // |reason| is the reason for interruption, if one occurs. |
| 90 // |security_info| contains SSL information (cert_id, cert_status, | 91 // |security_info| contains SSL information (cert_id, cert_status, |
| 91 // security_bits, ssl_connection_status), which can be used to | 92 // security_bits, ssl_connection_status), which can be used to |
| 92 // fine-tune the error message. It is empty if the transaction | 93 // fine-tune the error message. It is empty if the transaction |
| 93 // was not performed securely. | 94 // was not performed securely. |
| 94 void OnResponseCompleted(DownloadId global_id, | 95 void OnResponseCompleted(DownloadId global_id, |
| 95 net::Error net_error, | 96 InterruptReason reason, |
| 96 const std::string& security_info); | 97 const std::string& security_info); |
| 97 | 98 |
| 98 // Handlers for notifications sent from the UI thread and run on the | 99 // Handlers for notifications sent from the UI thread and run on the |
| 99 // FILE thread. These are both terminal actions with respect to the | 100 // FILE thread. These are both terminal actions with respect to the |
| 100 // download file, as far as the DownloadFileManager is concerned -- if | 101 // download file, as far as the DownloadFileManager is concerned -- if |
| 101 // anything happens to the download file after they are called, it will | 102 // anything happens to the download file after they are called, it will |
| 102 // be ignored. | 103 // be ignored. |
| 103 void CancelDownload(DownloadId id); | 104 void CancelDownload(DownloadId id); |
| 104 void CompleteDownload(DownloadId id); | 105 void CompleteDownload(DownloadId id); |
| 105 | 106 |
| (...skipping 60 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 |