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

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: " 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 17 matching lines...) Expand all
28 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 28 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
29 #pragma once 29 #pragma once
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/memory/scoped_ptr.h"
38 #include "base/message_loop_helpers.h" 39 #include "base/message_loop_helpers.h"
39 #include "base/time.h" 40 #include "base/time.h"
41 #include "base/values.h"
42 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/download_id.h" 43 #include "content/public/browser/download_id.h"
41 #include "content/public/browser/download_interrupt_reasons.h" 44 #include "content/public/browser/download_interrupt_reasons.h"
42 #include "content/public/browser/download_item.h" 45 #include "content/public/browser/download_item.h"
43 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/download_save_info.h"
47 #include "googleurl/src/gurl.h"
48 #include "net/base/net_errors.h"
Randy Smith (Not in Mondays) 2012/04/30 19:44:48 Why are there so many include files (and other stu
benjhayden 2012/05/02 15:11:54 Done.
44 #include "net/base/net_log.h" 49 #include "net/base/net_log.h"
45 #include "net/base/net_errors.h"
46 50
47 class DownloadRequestHandle; 51 class DownloadRequestHandle;
48 class GURL;
49 struct DownloadCreateInfo; 52 struct DownloadCreateInfo;
50 struct DownloadRetrieveInfo; 53 struct DownloadRetrieveInfo;
51 54
52 namespace content { 55 namespace content {
56
53 class BrowserContext; 57 class BrowserContext;
54 class DownloadManagerDelegate; 58 class DownloadManagerDelegate;
55 class DownloadQuery; 59 class DownloadQuery;
56 class WebContents; 60 class DownloadUrlParameters;
57 struct DownloadSaveInfo; 61 class ResourceContext;
62 class ResourceDispatcherHostImpl;
58 63
59 // Browser's download manager: manages all downloads and destination view. 64 // Browser's download manager: manages all downloads and destination view.
60 class CONTENT_EXPORT DownloadManager 65 class CONTENT_EXPORT DownloadManager
61 : public base::RefCountedThreadSafe<DownloadManager> { 66 : public base::RefCountedThreadSafe<DownloadManager> {
62 public: 67 public:
63 // NOTE: If there is an error, the DownloadId will be invalid.
64 typedef base::Callback<void(DownloadId, net::Error)> OnStartedCallback;
Randy Smith (Not in Mondays) 2012/04/30 19:44:48 Suggestion: Several of the files in this CL have o
benjhayden 2012/05/02 15:11:54 It seems strange to define a callback in an interf
65
66 virtual ~DownloadManager() {} 68 virtual ~DownloadManager() {}
67 69
68 static DownloadManager* Create( 70 static DownloadManager* Create(
69 DownloadManagerDelegate* delegate, 71 DownloadManagerDelegate* delegate,
70 net::NetLog* net_log); 72 net::NetLog* net_log);
71 73
72 // A method that can be used in tests to ensure that all the internal download 74 // A method that can be used in tests to ensure that all the internal download
73 // classes have no pending downloads. 75 // classes have no pending downloads.
74 static bool EnsureNoPendingDownloadsForTesting(); 76 static bool EnsureNoPendingDownloadsForTesting();
75 77
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 167
166 // Remove downloads will delete all downloads that have a timestamp that is 168 // 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 169 // the same or more recent than |remove_begin|. The number of downloads
168 // deleted is returned back to the caller. 170 // deleted is returned back to the caller.
169 virtual int RemoveDownloads(base::Time remove_begin) = 0; 171 virtual int RemoveDownloads(base::Time remove_begin) = 0;
170 172
171 // Remove all downloads will delete all downloads. The number of downloads 173 // Remove all downloads will delete all downloads. The number of downloads
172 // deleted is returned back to the caller. 174 // deleted is returned back to the caller.
173 virtual int RemoveAllDownloads() = 0; 175 virtual int RemoveAllDownloads() = 0;
174 176
175 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the 177 // Takes ownership of |parameters|.
Randy Smith (Not in Mondays) 2012/04/30 19:44:48 nit, suggestion: "See DownloadUrlParameters for de
benjhayden 2012/05/02 15:11:54 Done.
176 // referrer for the download, and may be empty. If |prefer_cache| is true, 178 virtual void DownloadUrl(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 179
196 // Allow objects to observe the download creation process. 180 // Allow objects to observe the download creation process.
197 virtual void AddObserver(Observer* observer) = 0; 181 virtual void AddObserver(Observer* observer) = 0;
198 182
199 // Remove a download observer from ourself. 183 // Remove a download observer from ourself.
200 virtual void RemoveObserver(Observer* observer) = 0; 184 virtual void RemoveObserver(Observer* observer) = 0;
201 185
202 // Called by the embedder, after creating the download manager, to let it know 186 // Called by the embedder, after creating the download manager, to let it know
203 // about downloads from previous runs of the browser. 187 // about downloads from previous runs of the browser.
204 virtual void OnPersistentStoreQueryComplete( 188 virtual void OnPersistentStoreQueryComplete(
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 private: 254 private:
271 friend class base::RefCountedThreadSafe< 255 friend class base::RefCountedThreadSafe<
272 DownloadManager, BrowserThread::DeleteOnUIThread>; 256 DownloadManager, BrowserThread::DeleteOnUIThread>;
273 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 257 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
274 friend class base::DeleteHelper<DownloadManager>; 258 friend class base::DeleteHelper<DownloadManager>;
275 }; 259 };
276 260
277 } // namespace content 261 } // namespace content
278 262
279 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 263 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698