Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: content/browser/download/download_file_manager.h

Issue 8770024: Added a download file factory to the download file manager, for testing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged with trunk Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ 40 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_
41 #pragma once 41 #pragma once
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/memory/scoped_ptr.h"
50 #include "base/timer.h" 51 #include "base/timer.h"
51 #include "content/browser/download/download_id.h" 52 #include "content/browser/download/download_id.h"
52 #include "content/browser/download/interrupt_reasons.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 class DownloadFile; 59 class DownloadFile;
59 class DownloadManager; 60 class DownloadManager;
60 class DownloadRequestHandle; 61 class DownloadRequestHandle;
61 class FilePath; 62 class FilePath;
62 class ResourceDispatcherHost; 63 class ResourceDispatcherHost;
63 64
64 namespace content { 65 namespace content {
65 class DownloadBuffer; 66 class DownloadBuffer;
66 } 67 }
67 68
68 // Manages all in progress downloads. 69 // Manages all in progress downloads.
69 class CONTENT_EXPORT DownloadFileManager 70 class CONTENT_EXPORT DownloadFileManager
70 : public base::RefCountedThreadSafe<DownloadFileManager> { 71 : public base::RefCountedThreadSafe<DownloadFileManager> {
71 public: 72 public:
72 explicit DownloadFileManager(ResourceDispatcherHost* rdh); 73 class DownloadFileFactory {
74 public:
75 virtual ~DownloadFileFactory() {}
76
77 virtual DownloadFile* CreateFile(
78 DownloadCreateInfo* info,
79 const DownloadRequestHandle& request_handle,
80 DownloadManager* download_manager) = 0;
81 };
82
83 // Takes ownership of the factory.
84 // Passing in a NULL for |factory| will cause the default
Randy Smith (Not in Mondays) 2011/12/07 20:57:41 nit: "the" to "a", since we're talking about objec
ahendrickson 2011/12/07 21:11:17 Done.
85 // |DownloadFileFactory| to be used.
86 DownloadFileManager(ResourceDispatcherHost* rdh,
87 DownloadFileFactory* factory);
73 88
74 // Called on shutdown on the UI thread. 89 // Called on shutdown on the UI thread.
75 void Shutdown(); 90 void Shutdown();
76 91
77 // Called on UI thread to make DownloadFileManager start the download. 92 // Called on UI thread to make DownloadFileManager start the download.
78 void StartDownload(DownloadCreateInfo* info, 93 void StartDownload(DownloadCreateInfo* info,
79 const DownloadRequestHandle& request_handle); 94 const DownloadRequestHandle& request_handle);
80 95
81 // Handlers for notifications sent from the IO thread and run on the 96 // Handlers for notifications sent from the IO thread and run on the
82 // FILE thread. 97 // FILE thread.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap; 173 typedef base::hash_map<DownloadId, DownloadFile*> DownloadFileMap;
159 174
160 // A map of all in progress downloads. It owns the download files. 175 // A map of all in progress downloads. It owns the download files.
161 DownloadFileMap downloads_; 176 DownloadFileMap downloads_;
162 177
163 // Schedule periodic updates of the download progress. This timer 178 // Schedule periodic updates of the download progress. This timer
164 // is controlled from the FILE thread, and posts updates to the UI thread. 179 // is controlled from the FILE thread, and posts updates to the UI thread.
165 base::RepeatingTimer<DownloadFileManager> update_timer_; 180 base::RepeatingTimer<DownloadFileManager> update_timer_;
166 181
167 ResourceDispatcherHost* resource_dispatcher_host_; 182 ResourceDispatcherHost* resource_dispatcher_host_;
183 scoped_ptr<DownloadFileFactory> download_file_factory_;
168 184
169 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); 185 DISALLOW_COPY_AND_ASSIGN(DownloadFileManager);
170 }; 186 };
171 187
172 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_ 188 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698