| 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 14 matching lines...) Expand all Loading... |
| 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/public/browser/download_id.h" | 40 #include "content/public/browser/download_id.h" |
| 40 #include "content/public/browser/download_interrupt_reasons.h" | 41 #include "content/public/browser/download_interrupt_reasons.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 Loading... |
| 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: If there is an error, the DownloadId will be invalid. |
| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the | 174 // Downloads the content at |url|. |referrer| and |referrer_encoding| are the |
| 171 // referrer for the download, and may be empty. If |prefer_cache| is true, | 175 // referrer for the download, and may be empty. If |prefer_cache| is true, |
| 172 // then if the response to |url| is in the HTTP cache it will be used without | 176 // then if the response to |url| is in the HTTP cache it will be used without |
| 173 // revalidation. If |post_id| is non-negative, then it identifies the post | 177 // revalidation. If |post_id| is non-negative, then it identifies the post |
| 174 // transaction used to originally retrieve the |url| resource - it also | 178 // transaction used to originally retrieve the |url| resource - it also |
| 175 // requires |prefer_cache| to be |true| since re-post'ing is not done. | 179 // requires |prefer_cache| to be |true| since re-post'ing is not done. |
| 176 // |save_info| specifies where the downloaded file should be | 180 // |save_info| specifies where the downloaded file should be |
| 177 // saved, and whether the user should be prompted about the download. | 181 // saved, and whether the user should be prompted about the download. |
| 178 // |web_contents| is the web page that the download is done in context of, | 182 // |web_contents| is the web page that the download is done in context of, |
| 179 // and must be non-NULL. | 183 // and must be non-NULL. |
| 184 // |callback| will be called when the download starts, or if an error |
| 185 // occurs that prevents ad download item from being created. |
| 180 virtual void DownloadUrl(const GURL& url, | 186 virtual void DownloadUrl(const GURL& url, |
| 181 const GURL& referrer, | 187 const GURL& referrer, |
| 182 const std::string& referrer_encoding, | 188 const std::string& referrer_encoding, |
| 183 bool prefer_cache, | 189 bool prefer_cache, |
| 184 int64 post_id, | 190 int64 post_id, |
| 185 const DownloadSaveInfo& save_info, | 191 const DownloadSaveInfo& save_info, |
| 186 content::WebContents* web_contents) = 0; | 192 content::WebContents* web_contents, |
| 193 const OnStartedCallback& callback) = 0; |
| 187 | 194 |
| 188 // Allow objects to observe the download creation process. | 195 // Allow objects to observe the download creation process. |
| 189 virtual void AddObserver(Observer* observer) = 0; | 196 virtual void AddObserver(Observer* observer) = 0; |
| 190 | 197 |
| 191 // Remove a download observer from ourself. | 198 // Remove a download observer from ourself. |
| 192 virtual void RemoveObserver(Observer* observer) = 0; | 199 virtual void RemoveObserver(Observer* observer) = 0; |
| 193 | 200 |
| 194 // Called by the embedder, after creating the download manager, to let it know | 201 // Called by the embedder, after creating the download manager, to let it know |
| 195 // about downloads from previous runs of the browser. | 202 // about downloads from previous runs of the browser. |
| 196 virtual void OnPersistentStoreQueryComplete( | 203 virtual void OnPersistentStoreQueryComplete( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 friend class base::RefCountedThreadSafe< | 288 friend class base::RefCountedThreadSafe< |
| 282 DownloadManager, content::BrowserThread::DeleteOnUIThread>; | 289 DownloadManager, content::BrowserThread::DeleteOnUIThread>; |
| 283 friend struct content::BrowserThread::DeleteOnThread< | 290 friend struct content::BrowserThread::DeleteOnThread< |
| 284 content::BrowserThread::UI>; | 291 content::BrowserThread::UI>; |
| 285 friend class base::DeleteHelper<DownloadManager>; | 292 friend class base::DeleteHelper<DownloadManager>; |
| 286 }; | 293 }; |
| 287 | 294 |
| 288 } // namespace content | 295 } // namespace content |
| 289 | 296 |
| 290 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ | 297 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |