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

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

Issue 9570005: Added callback to DownloadUrl() so we can find download failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed CLANG issue. Created 8 years, 9 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 14 matching lines...) Expand all
25 // all persisted downloads. 25 // all persisted downloads.
26 26
27 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 27 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
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/file_path.h" 36 #include "base/file_path.h"
36 #include "base/gtest_prod_util.h" 37 #include "base/gtest_prod_util.h"
37 #include "base/message_loop_helpers.h" 38 #include "base/message_loop_helpers.h"
38 #include "base/time.h" 39 #include "base/time.h"
39 #include "content/browser/download/interrupt_reasons.h" 40 #include "content/browser/download/interrupt_reasons.h"
40 #include "content/public/browser/download_id.h" 41 #include "content/public/browser/download_id.h"
41 #include "content/public/browser/download_item.h" 42 #include "content/public/browser/download_item.h"
42 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
43 #include "net/base/net_log.h" 44 #include "net/base/net_log.h"
44 #include "net/base/net_errors.h" 45 #include "net/base/net_errors.h"
(...skipping 10 matching lines...) Expand all
55 namespace content { 56 namespace content {
56 class BrowserContext; 57 class BrowserContext;
57 class DownloadManagerDelegate; 58 class DownloadManagerDelegate;
58 class DownloadQuery; 59 class DownloadQuery;
59 class WebContents; 60 class WebContents;
60 61
61 // Browser's download manager: manages all downloads and destination view. 62 // Browser's download manager: manages all downloads and destination view.
62 class CONTENT_EXPORT DownloadManager 63 class CONTENT_EXPORT DownloadManager
63 : public base::RefCountedThreadSafe<DownloadManager> { 64 : public base::RefCountedThreadSafe<DownloadManager> {
64 public: 65 public:
66 // NOTE: It is OK for the DownloadId to be invalid if there is an error.
Randy Smith (Not in Mondays) 2012/03/07 21:16:57 wording nit: "Is it OK" sounds like telling the co
ahendrickson 2012/03/08 21:33:07 Done.
67 typedef base::Callback<void(DownloadId, net::Error)> OnStartedCallback;
68
65 virtual ~DownloadManager() {} 69 virtual ~DownloadManager() {}
66 70
67 static DownloadManager* Create( 71 static DownloadManager* Create(
68 DownloadManagerDelegate* delegate, 72 DownloadManagerDelegate* delegate,
69 net::NetLog* net_log); 73 net::NetLog* net_log);
70 74
71 // Shutdown the download manager. Must be called before destruction. 75 // Shutdown the download manager. Must be called before destruction.
72 virtual void Shutdown() = 0; 76 virtual void Shutdown() = 0;
73 77
74 // Interface to implement for observers that wish to be informed of changes 78 // Interface to implement for observers that wish to be informed of changes
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the 173 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the
170 // referrer for the download, and may be empty. If |prefer_cache| is true, 174 // referrer for the download, and may be empty. If |prefer_cache| is true,
171 // then if the response to |url| is in the HTTP cache it will be used without 175 // then if the response to |url| is in the HTTP cache it will be used without
172 // revalidation. If |post_id| is non-negative, then it identifies the post 176 // revalidation. If |post_id| is non-negative, then it identifies the post
173 // transaction used to originally retrieve the |url| resource - it also 177 // transaction used to originally retrieve the |url| resource - it also
174 // requires |prefer_cache| to be |true| since re-post'ing is not done. 178 // requires |prefer_cache| to be |true| since re-post'ing is not done.
175 // |save_info| specifies where the downloaded file should be 179 // |save_info| specifies where the downloaded file should be
176 // saved, and whether the user should be prompted about the download. 180 // saved, and whether the user should be prompted about the download.
177 // |web_contents| is the web page that the download is done in context of, 181 // |web_contents| is the web page that the download is done in context of,
178 // and must be non-NULL. 182 // and must be non-NULL.
183 // |callback| will be called when the download starts, or if an error
184 // occurs.
Randy Smith (Not in Mondays) 2012/03/07 21:16:57 This sentence is actually underspecified, as the d
jstritar 2012/03/07 21:34:39 What if we define a Delegate that has separate met
ahendrickson 2012/03/08 21:33:07 Done.
Randy Smith (Not in Mondays) 2012/03/09 19:14:02 typo: "prevents ad download".
ahendrickson 2012/03/09 20:50:08 Done.
179 virtual void DownloadUrl(const GURL& url, 185 virtual void DownloadUrl(const GURL& url,
180 const GURL& referrer, 186 const GURL& referrer,
181 const std::string& referrer_encoding, 187 const std::string& referrer_encoding,
182 bool prefer_cache, 188 bool prefer_cache,
183 int64 post_id, 189 int64 post_id,
184 const DownloadSaveInfo& save_info, 190 const DownloadSaveInfo& save_info,
185 content::WebContents* web_contents) = 0; 191 content::WebContents* web_contents,
192 const OnStartedCallback& callback) = 0;
186 193
187 // Allow objects to observe the download creation process. 194 // Allow objects to observe the download creation process.
188 virtual void AddObserver(Observer* observer) = 0; 195 virtual void AddObserver(Observer* observer) = 0;
189 196
190 // Remove a download observer from ourself. 197 // Remove a download observer from ourself.
191 virtual void RemoveObserver(Observer* observer) = 0; 198 virtual void RemoveObserver(Observer* observer) = 0;
192 199
193 // Called by the embedder, after creating the download manager, to let it know 200 // Called by the embedder, after creating the download manager, to let it know
194 // about downloads from previous runs of the browser. 201 // about downloads from previous runs of the browser.
195 virtual void OnPersistentStoreQueryComplete( 202 virtual void OnPersistentStoreQueryComplete(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 friend class base::RefCountedThreadSafe< 287 friend class base::RefCountedThreadSafe<
281 DownloadManager, content::BrowserThread::DeleteOnUIThread>; 288 DownloadManager, content::BrowserThread::DeleteOnUIThread>;
282 friend struct content::BrowserThread::DeleteOnThread< 289 friend struct content::BrowserThread::DeleteOnThread<
283 content::BrowserThread::UI>; 290 content::BrowserThread::UI>;
284 friend class base::DeleteHelper<DownloadManager>; 291 friend class base::DeleteHelper<DownloadManager>;
285 }; 292 };
286 293
287 } // namespace content 294 } // namespace content
288 295
289 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ 296 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698