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

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

Issue 1418663010: Adding WebContent-free Download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing nits. Created 5 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) 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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector>
11 12
12 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
13 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 19 #include "base/observer_list.h"
18 #include "base/sequenced_task_runner_helpers.h" 20 #include "base/sequenced_task_runner_helpers.h"
19 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
20 #include "content/browser/download/download_item_impl_delegate.h" 22 #include "content/browser/download/download_item_impl_delegate.h"
23 #include "content/browser/download/url_downloader.h"
21 #include "content/common/content_export.h" 24 #include "content/common/content_export.h"
25 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/download_manager.h" 26 #include "content/public/browser/download_manager.h"
23 #include "content/public/browser/download_manager_delegate.h" 27 #include "content/public/browser/download_manager_delegate.h"
24 #include "content/public/browser/download_url_parameters.h" 28 #include "content/public/browser/download_url_parameters.h"
25 29
26 namespace net { 30 namespace net {
27 class BoundNetLog; 31 class BoundNetLog;
28 } 32 }
29 33
30 namespace content { 34 namespace content {
31 class DownloadFileFactory; 35 class DownloadFileFactory;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void CheckForHistoryFilesRemoval() override; 106 void CheckForHistoryFilesRemoval() override;
103 DownloadItem* GetDownload(uint32 id) override; 107 DownloadItem* GetDownload(uint32 id) override;
104 108
105 // For testing; specifically, accessed from TestFileErrorInjector. 109 // For testing; specifically, accessed from TestFileErrorInjector.
106 void SetDownloadItemFactoryForTesting( 110 void SetDownloadItemFactoryForTesting(
107 scoped_ptr<DownloadItemFactory> item_factory); 111 scoped_ptr<DownloadItemFactory> item_factory);
108 void SetDownloadFileFactoryForTesting( 112 void SetDownloadFileFactoryForTesting(
109 scoped_ptr<DownloadFileFactory> file_factory); 113 scoped_ptr<DownloadFileFactory> file_factory);
110 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting(); 114 virtual DownloadFileFactory* GetDownloadFileFactoryForTesting();
111 115
116 void RemoveUrlDownloader(UrlDownloader* downloader);
117
112 private: 118 private:
113 typedef std::set<DownloadItem*> DownloadSet; 119 typedef std::set<DownloadItem*> DownloadSet;
114 typedef base::hash_map<uint32, DownloadItemImpl*> DownloadMap; 120 typedef base::hash_map<uint32, DownloadItemImpl*> DownloadMap;
115 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector; 121 typedef std::vector<DownloadItemImpl*> DownloadItemImplVector;
116 typedef base::Callback<bool(const DownloadItemImpl*)> DownloadRemover; 122 typedef base::Callback<bool(const DownloadItemImpl*)> DownloadRemover;
117 123
118 // For testing. 124 // For testing.
119 friend class DownloadManagerTest; 125 friend class DownloadManagerTest;
120 friend class DownloadTest; 126 friend class DownloadTest;
121 127
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 bool ShouldOpenDownload(DownloadItemImpl* item, 167 bool ShouldOpenDownload(DownloadItemImpl* item,
162 const ShouldOpenDownloadCallback& callback) override; 168 const ShouldOpenDownloadCallback& callback) override;
163 void CheckForFileRemoval(DownloadItemImpl* download_item) override; 169 void CheckForFileRemoval(DownloadItemImpl* download_item) override;
164 void ResumeInterruptedDownload( 170 void ResumeInterruptedDownload(
165 scoped_ptr<content::DownloadUrlParameters> params, 171 scoped_ptr<content::DownloadUrlParameters> params,
166 uint32 id) override; 172 uint32 id) override;
167 void OpenDownload(DownloadItemImpl* download) override; 173 void OpenDownload(DownloadItemImpl* download) override;
168 void ShowDownloadInShell(DownloadItemImpl* download) override; 174 void ShowDownloadInShell(DownloadItemImpl* download) override;
169 void DownloadRemoved(DownloadItemImpl* download) override; 175 void DownloadRemoved(DownloadItemImpl* download) override;
170 176
177 void AddUrlDownloader(
178 scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> downloader);
179
171 // Factory for creation of downloads items. 180 // Factory for creation of downloads items.
172 scoped_ptr<DownloadItemFactory> item_factory_; 181 scoped_ptr<DownloadItemFactory> item_factory_;
173 182
174 // Factory for the creation of download files. 183 // Factory for the creation of download files.
175 scoped_ptr<DownloadFileFactory> file_factory_; 184 scoped_ptr<DownloadFileFactory> file_factory_;
176 185
177 // |downloads_| is the owning set for all downloads known to the 186 // |downloads_| is the owning set for all downloads known to the
178 // DownloadManager. This includes downloads started by the user in 187 // DownloadManager. This includes downloads started by the user in
179 // this session, downloads initialized from the history system, and 188 // this session, downloads initialized from the history system, and
180 // "save page as" downloads. 189 // "save page as" downloads.
181 DownloadMap downloads_; 190 DownloadMap downloads_;
182 191
183 int history_size_; 192 int history_size_;
184 193
185 // True if the download manager has been initialized and requires a shutdown. 194 // True if the download manager has been initialized and requires a shutdown.
186 bool shutdown_needed_; 195 bool shutdown_needed_;
187 196
188 // Observers that want to be notified of changes to the set of downloads. 197 // Observers that want to be notified of changes to the set of downloads.
189 base::ObserverList<Observer> observers_; 198 base::ObserverList<Observer> observers_;
190 199
191 // The current active browser context. 200 // The current active browser context.
192 BrowserContext* browser_context_; 201 BrowserContext* browser_context_;
193 202
194 // Allows an embedder to control behavior. Guaranteed to outlive this object. 203 // Allows an embedder to control behavior. Guaranteed to outlive this object.
195 DownloadManagerDelegate* delegate_; 204 DownloadManagerDelegate* delegate_;
196 205
197 net::NetLog* net_log_; 206 net::NetLog* net_log_;
198 207
208 std::vector<scoped_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>>
209 url_downloaders_;
210
199 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_; 211 base::WeakPtrFactory<DownloadManagerImpl> weak_factory_;
200 212
201 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl); 213 DISALLOW_COPY_AND_ASSIGN(DownloadManagerImpl);
202 }; 214 };
203 215
204 } // namespace content 216 } // namespace content
205 217
206 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_ 218 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698