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

Side by Side Diff: content/public/browser/download_manager.h

Issue 10232010: DownloadUrlParameters (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: comments Created 8 years, 7 months 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 | Annotate | Revision Log
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 // The DownloadManager object manages the process of downloading, including 5 // The DownloadManager object manages the process of downloading, including
6 // updates to the history system and providing the information for displaying 6 // updates to the history system and providing the information for displaying
7 // the downloads view in the Destinations tab. There is one DownloadManager per 7 // the downloads view in the Destinations tab. There is one DownloadManager per
8 // active browser context in Chrome. 8 // active browser context in Chrome.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 19 matching lines...) Expand all
30 30
31 #include <string> 31 #include <string>
32 #include <vector> 32 #include <vector>
33 33
34 #include "base/basictypes.h" 34 #include "base/basictypes.h"
35 #include "base/callback.h" 35 #include "base/callback.h"
36 #include "base/file_path.h" 36 #include "base/file_path.h"
37 #include "base/gtest_prod_util.h" 37 #include "base/gtest_prod_util.h"
38 #include "base/message_loop_helpers.h" 38 #include "base/message_loop_helpers.h"
39 #include "base/time.h" 39 #include "base/time.h"
40 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/download_id.h" 41 #include "content/public/browser/download_id.h"
41 #include "content/public/browser/download_interrupt_reasons.h" 42 #include "content/public/browser/download_interrupt_reasons.h"
42 #include "content/public/browser/download_item.h" 43 #include "content/public/browser/download_item.h"
43 #include "content/public/browser/browser_thread.h" 44 #include "net/base/net_errors.h"
44 #include "net/base/net_log.h" 45 #include "net/base/net_log.h"
45 #include "net/base/net_errors.h"
46 46
47 class DownloadRequestHandle; 47 class DownloadRequestHandle;
48 class GURL; 48 class GURL;
49 struct DownloadCreateInfo; 49 struct DownloadCreateInfo;
50 struct DownloadRetrieveInfo; 50 struct DownloadRetrieveInfo;
51 51
52 namespace content { 52 namespace content {
53
53 class BrowserContext; 54 class BrowserContext;
54 class DownloadManagerDelegate; 55 class DownloadManagerDelegate;
55 class DownloadQuery; 56 class DownloadQuery;
56 class WebContents; 57 class DownloadUrlParameters;
57 struct DownloadSaveInfo; 58 class ResourceContext;
59 class ResourceDispatcherHostImpl;
Randy Smith (Not in Mondays) 2012/05/02 18:36:22 Why the additional forward decls for Resource*?
benjhayden 2012/05/02 20:01:26 Done.
58 60
59 // Browser's download manager: manages all downloads and destination view. 61 // Browser's download manager: manages all downloads and destination view.
60 class CONTENT_EXPORT DownloadManager 62 class CONTENT_EXPORT DownloadManager
61 : public base::RefCountedThreadSafe<DownloadManager> { 63 : public base::RefCountedThreadSafe<DownloadManager> {
62 public: 64 public:
63 // NOTE: If there is an error, the DownloadId will be invalid.
64 typedef base::Callback<void(DownloadId, net::Error)> OnStartedCallback;
65
66 virtual ~DownloadManager() {} 65 virtual ~DownloadManager() {}
67 66
68 static DownloadManager* Create( 67 static DownloadManager* Create(
69 DownloadManagerDelegate* delegate, 68 DownloadManagerDelegate* delegate,
70 net::NetLog* net_log); 69 net::NetLog* net_log);
71 70
72 // A method that can be used in tests to ensure that all the internal download 71 // A method that can be used in tests to ensure that all the internal download
73 // classes have no pending downloads. 72 // classes have no pending downloads.
74 static bool EnsureNoPendingDownloadsForTesting(); 73 static bool EnsureNoPendingDownloadsForTesting();
75 74
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 164
166 // Remove downloads will delete all downloads that have a timestamp that is 165 // Remove downloads will delete all downloads that have a timestamp that is
167 // the same or more recent than |remove_begin|. The number of downloads 166 // the same or more recent than |remove_begin|. The number of downloads
168 // deleted is returned back to the caller. 167 // deleted is returned back to the caller.
169 virtual int RemoveDownloads(base::Time remove_begin) = 0; 168 virtual int RemoveDownloads(base::Time remove_begin) = 0;
170 169
171 // Remove all downloads will delete all downloads. The number of downloads 170 // Remove all downloads will delete all downloads. The number of downloads
172 // deleted is returned back to the caller. 171 // deleted is returned back to the caller.
173 virtual int RemoveAllDownloads() = 0; 172 virtual int RemoveAllDownloads() = 0;
174 173
175 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the 174 // See DownloadUrlParameters for details about controlling the download.
176 // referrer for the download, and may be empty. If |prefer_cache| is true, 175 virtual void DownloadUrl(scoped_ptr<DownloadUrlParameters> parameters) = 0;
177 // then if the response to |url| is in the HTTP cache it will be used without
178 // revalidation. If |post_id| is non-negative, then it identifies the post
179 // transaction used to originally retrieve the |url| resource - it also
180 // requires |prefer_cache| to be |true| since re-post'ing is not done.
181 // |save_info| specifies where the downloaded file should be
182 // saved, and whether the user should be prompted about the download.
183 // |web_contents| is the web page that the download is done in context of,
184 // and must be non-NULL.
185 // |callback| will be called when the download starts, or if an error
186 // occurs that prevents a download item from being created.
187 virtual void DownloadUrl(const GURL& url,
188 const GURL& referrer,
189 const std::string& referrer_encoding,
190 bool prefer_cache,
191 int64 post_id,
192 const DownloadSaveInfo& save_info,
193 WebContents* web_contents,
194 const OnStartedCallback& callback) = 0;
195 176
196 // Allow objects to observe the download creation process. 177 // Allow objects to observe the download creation process.
197 virtual void AddObserver(Observer* observer) = 0; 178 virtual void AddObserver(Observer* observer) = 0;
198 179
199 // Remove a download observer from ourself. 180 // Remove a download observer from ourself.
200 virtual void RemoveObserver(Observer* observer) = 0; 181 virtual void RemoveObserver(Observer* observer) = 0;
201 182
202 // Called by the embedder, after creating the download manager, to let it know 183 // Called by the embedder, after creating the download manager, to let it know
203 // about downloads from previous runs of the browser. 184 // about downloads from previous runs of the browser.
204 virtual void OnPersistentStoreQueryComplete( 185 virtual void OnPersistentStoreQueryComplete(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 private: 251 private:
271 friend class base::RefCountedThreadSafe< 252 friend class base::RefCountedThreadSafe<
272 DownloadManager, BrowserThread::DeleteOnUIThread>; 253 DownloadManager, BrowserThread::DeleteOnUIThread>;
273 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 254 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
274 friend class base::DeleteHelper<DownloadManager>; 255 friend class base::DeleteHelper<DownloadManager>;
275 }; 256 };
276 257
277 } // namespace content 258 } // namespace content
278 259
279 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 260 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698