| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 namespace content { | 55 namespace content { |
| 56 class BrowserContext; | 56 class BrowserContext; |
| 57 class DownloadManagerDelegate; | 57 class DownloadManagerDelegate; |
| 58 class DownloadQuery; | 58 class DownloadQuery; |
| 59 class WebContents; | 59 class WebContents; |
| 60 | 60 |
| 61 // Browser's download manager: manages all downloads and destination view. | 61 // Browser's download manager: manages all downloads and destination view. |
| 62 class CONTENT_EXPORT DownloadManager | 62 class CONTENT_EXPORT DownloadManager |
| 63 : public base::RefCountedThreadSafe<DownloadManager> { | 63 : public base::RefCountedThreadSafe<DownloadManager> { |
| 64 public: | 64 public: |
| 65 typedef base::Callback<void(DownloadId, net::Error)> OnStartedCallback; |
| 66 |
| 65 virtual ~DownloadManager() {} | 67 virtual ~DownloadManager() {} |
| 66 | 68 |
| 67 static DownloadManager* Create( | 69 static DownloadManager* Create( |
| 68 DownloadManagerDelegate* delegate, | 70 DownloadManagerDelegate* delegate, |
| 69 net::NetLog* net_log); | 71 net::NetLog* net_log); |
| 70 | 72 |
| 71 // Shutdown the download manager. Must be called before destruction. | 73 // Shutdown the download manager. Must be called before destruction. |
| 72 virtual void Shutdown() = 0; | 74 virtual void Shutdown() = 0; |
| 73 | 75 |
| 74 // Interface to implement for observers that wish to be informed of changes | 76 // Interface to implement for observers that wish to be informed of changes |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the | 171 // 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, | 172 // 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 | 173 // 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 | 174 // revalidation. If |post_id| is non-negative, then it identifies the post |
| 173 // transaction used to originally retrieve the |url| resource - it also | 175 // transaction used to originally retrieve the |url| resource - it also |
| 174 // requires |prefer_cache| to be |true| since re-post'ing is not done. | 176 // requires |prefer_cache| to be |true| since re-post'ing is not done. |
| 175 // |save_info| specifies where the downloaded file should be | 177 // |save_info| specifies where the downloaded file should be |
| 176 // saved, and whether the user should be prompted about the download. | 178 // 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, | 179 // |web_contents| is the web page that the download is done in context of, |
| 178 // and must be non-NULL. | 180 // and must be non-NULL. |
| 181 // |callback| will be called when the download starts, or if an error |
| 182 // occurs. |
| 179 virtual void DownloadUrl(const GURL& url, | 183 virtual void DownloadUrl(const GURL& url, |
| 180 const GURL& referrer, | 184 const GURL& referrer, |
| 181 const std::string& referrer_encoding, | 185 const std::string& referrer_encoding, |
| 182 bool prefer_cache, | 186 bool prefer_cache, |
| 183 int64 post_id, | 187 int64 post_id, |
| 184 const DownloadSaveInfo& save_info, | 188 const DownloadSaveInfo& save_info, |
| 185 content::WebContents* web_contents) = 0; | 189 content::WebContents* web_contents, |
| 190 const OnStartedCallback& callback) = 0; |
| 186 | 191 |
| 187 // Allow objects to observe the download creation process. | 192 // Allow objects to observe the download creation process. |
| 188 virtual void AddObserver(Observer* observer) = 0; | 193 virtual void AddObserver(Observer* observer) = 0; |
| 189 | 194 |
| 190 // Remove a download observer from ourself. | 195 // Remove a download observer from ourself. |
| 191 virtual void RemoveObserver(Observer* observer) = 0; | 196 virtual void RemoveObserver(Observer* observer) = 0; |
| 192 | 197 |
| 193 // Called by the embedder, after creating the download manager, to let it know | 198 // Called by the embedder, after creating the download manager, to let it know |
| 194 // about downloads from previous runs of the browser. | 199 // about downloads from previous runs of the browser. |
| 195 virtual void OnPersistentStoreQueryComplete( | 200 virtual void OnPersistentStoreQueryComplete( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 friend class base::RefCountedThreadSafe< | 285 friend class base::RefCountedThreadSafe< |
| 281 DownloadManager, content::BrowserThread::DeleteOnUIThread>; | 286 DownloadManager, content::BrowserThread::DeleteOnUIThread>; |
| 282 friend struct content::BrowserThread::DeleteOnThread< | 287 friend struct content::BrowserThread::DeleteOnThread< |
| 283 content::BrowserThread::UI>; | 288 content::BrowserThread::UI>; |
| 284 friend class base::DeleteHelper<DownloadManager>; | 289 friend class base::DeleteHelper<DownloadManager>; |
| 285 }; | 290 }; |
| 286 | 291 |
| 287 } // namespace content | 292 } // namespace content |
| 288 | 293 |
| 289 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 294 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |