| 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 // 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 // ResourceDispatcherHostImpl. | 8 // ResourceDispatcherHostImpl. |
| 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 #include <map> | 42 #include <map> |
| 43 | 43 |
| 44 #include "base/atomic_sequence_num.h" | 44 #include "base/atomic_sequence_num.h" |
| 45 #include "base/basictypes.h" | 45 #include "base/basictypes.h" |
| 46 #include "base/callback_forward.h" | 46 #include "base/callback_forward.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/memory/scoped_ptr.h" | 50 #include "base/memory/scoped_ptr.h" |
| 51 #include "base/timer.h" | 51 #include "base/timer.h" |
| 52 #include "content/browser/download/download_file.h" |
| 52 #include "content/common/content_export.h" | 53 #include "content/common/content_export.h" |
| 53 #include "content/public/browser/download_id.h" | 54 #include "content/public/browser/download_id.h" |
| 54 #include "content/public/browser/download_interrupt_reasons.h" | 55 #include "content/public/browser/download_interrupt_reasons.h" |
| 55 #include "net/base/net_errors.h" | 56 #include "net/base/net_errors.h" |
| 56 #include "ui/gfx/native_widget_types.h" | 57 #include "ui/gfx/native_widget_types.h" |
| 57 | 58 |
| 58 struct DownloadCreateInfo; | 59 struct DownloadCreateInfo; |
| 59 class DownloadRequestHandle; | 60 class DownloadRequestHandle; |
| 60 class FilePath; | 61 class FilePath; |
| 61 | 62 |
| 62 namespace content { | 63 namespace content { |
| 63 class ByteStreamReader; | 64 class ByteStreamReader; |
| 64 class DownloadFile; | |
| 65 class DownloadId; | 65 class DownloadId; |
| 66 class DownloadManager; | 66 class DownloadManager; |
| 67 } | 67 } |
| 68 | 68 |
| 69 namespace net { | 69 namespace net { |
| 70 class BoundNetLog; | 70 class BoundNetLog; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Manages all in progress downloads. | 73 // Manages all in progress downloads. |
| 74 // Methods are virtual to allow mocks--this class is not intended | 74 // Methods are virtual to allow mocks--this class is not intended |
| 75 // to be a base class. | 75 // to be a base class. |
| 76 class CONTENT_EXPORT DownloadFileManager | 76 class CONTENT_EXPORT DownloadFileManager |
| 77 : public base::RefCountedThreadSafe<DownloadFileManager> { | 77 : public base::RefCountedThreadSafe<DownloadFileManager> { |
| 78 public: | 78 public: |
| 79 // Callback used with CreateDownloadFile(). |reason| will be | 79 // Callback used with CreateDownloadFile(). |reason| will be |
| 80 // DOWNLOAD_INTERRUPT_REASON_NONE on a successful creation. | 80 // DOWNLOAD_INTERRUPT_REASON_NONE on a successful creation. |
| 81 typedef base::Callback<void(content::DownloadInterruptReason reason)> | 81 typedef base::Callback<void(content::DownloadInterruptReason reason)> |
| 82 CreateDownloadFileCallback; | 82 CreateDownloadFileCallback; |
| 83 | 83 |
| 84 // Callback used with RenameDownloadFile(). | 84 // Callback used with RenameDownloadFile(). |
| 85 typedef base::Callback<void(const FilePath&)> RenameCompletionCallback; | 85 typedef content::DownloadFile::RenameCompletionCallback |
| 86 RenameCompletionCallback; |
| 86 | 87 |
| 87 class DownloadFileFactory { | 88 class DownloadFileFactory { |
| 88 public: | 89 public: |
| 89 virtual ~DownloadFileFactory() {} | 90 virtual ~DownloadFileFactory() {} |
| 90 | 91 |
| 91 virtual content::DownloadFile* CreateFile( | 92 virtual content::DownloadFile* CreateFile( |
| 92 DownloadCreateInfo* info, | 93 DownloadCreateInfo* info, |
| 93 scoped_ptr<content::ByteStreamReader> stream, | 94 scoped_ptr<content::ByteStreamReader> stream, |
| 94 content::DownloadManager* download_manager, | 95 content::DownloadManager* download_manager, |
| 95 bool calculate_hash, | 96 bool calculate_hash, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 171 |
| 171 // A map of all in progress downloads. It owns the download files. | 172 // A map of all in progress downloads. It owns the download files. |
| 172 DownloadFileMap downloads_; | 173 DownloadFileMap downloads_; |
| 173 | 174 |
| 174 scoped_ptr<DownloadFileFactory> download_file_factory_; | 175 scoped_ptr<DownloadFileFactory> download_file_factory_; |
| 175 | 176 |
| 176 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); | 177 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); |
| 177 }; | 178 }; |
| 178 | 179 |
| 179 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ | 180 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ |
| OLD | NEW |