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

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: fixes 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
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/download_url_parameters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 58
59 // Browser's download manager: manages all downloads and destination view. 59 // Browser's download manager: manages all downloads and destination view.
60 class CONTENT_EXPORT DownloadManager 60 class CONTENT_EXPORT DownloadManager
61 : public base::RefCountedThreadSafe<DownloadManager> { 61 : public base::RefCountedThreadSafe<DownloadManager> {
62 public: 62 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() {} 63 virtual ~DownloadManager() {}
67 64
68 static DownloadManager* Create( 65 static DownloadManager* Create(
69 DownloadManagerDelegate* delegate, 66 DownloadManagerDelegate* delegate,
70 net::NetLog* net_log); 67 net::NetLog* net_log);
71 68
72 // A method that can be used in tests to ensure that all the internal download 69 // A method that can be used in tests to ensure that all the internal download
73 // classes have no pending downloads. 70 // classes have no pending downloads.
74 static bool EnsureNoPendingDownloadsForTesting(); 71 static bool EnsureNoPendingDownloadsForTesting();
75 72
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 162
166 // Remove downloads will delete all downloads that have a timestamp that is 163 // 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 164 // the same or more recent than |remove_begin|. The number of downloads
168 // deleted is returned back to the caller. 165 // deleted is returned back to the caller.
169 virtual int RemoveDownloads(base::Time remove_begin) = 0; 166 virtual int RemoveDownloads(base::Time remove_begin) = 0;
170 167
171 // Remove all downloads will delete all downloads. The number of downloads 168 // Remove all downloads will delete all downloads. The number of downloads
172 // deleted is returned back to the caller. 169 // deleted is returned back to the caller.
173 virtual int RemoveAllDownloads() = 0; 170 virtual int RemoveAllDownloads() = 0;
174 171
175 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the 172 // See DownloadUrlParameters for details about controlling the download.
176 // referrer for the download, and may be empty. If |prefer_cache| is true, 173 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 174
196 // Allow objects to observe the download creation process. 175 // Allow objects to observe the download creation process.
197 virtual void AddObserver(Observer* observer) = 0; 176 virtual void AddObserver(Observer* observer) = 0;
198 177
199 // Remove a download observer from ourself. 178 // Remove a download observer from ourself.
200 virtual void RemoveObserver(Observer* observer) = 0; 179 virtual void RemoveObserver(Observer* observer) = 0;
201 180
202 // Called by the embedder, after creating the download manager, to let it know 181 // Called by the embedder, after creating the download manager, to let it know
203 // about downloads from previous runs of the browser. 182 // about downloads from previous runs of the browser.
204 virtual void OnPersistentStoreQueryComplete( 183 virtual void OnPersistentStoreQueryComplete(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 private: 249 private:
271 friend class base::RefCountedThreadSafe< 250 friend class base::RefCountedThreadSafe<
272 DownloadManager, BrowserThread::DeleteOnUIThread>; 251 DownloadManager, BrowserThread::DeleteOnUIThread>;
273 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 252 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
274 friend class base::DeleteHelper<DownloadManager>; 253 friend class base::DeleteHelper<DownloadManager>;
275 }; 254 };
276 255
277 } // namespace content 256 } // namespace content
278 257
279 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 258 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/download_url_parameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698