Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 profile in Chrome. | 8 // active profile in Chrome. |
| 9 // | 9 // |
| 10 // Download observers: | 10 // Download observers: |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 #include "base/basictypes.h" | 36 #include "base/basictypes.h" |
| 37 #include "base/file_path.h" | 37 #include "base/file_path.h" |
| 38 #include "base/gtest_prod_util.h" | 38 #include "base/gtest_prod_util.h" |
| 39 #include "base/memory/ref_counted.h" | 39 #include "base/memory/ref_counted.h" |
| 40 #include "base/memory/weak_ptr.h" | 40 #include "base/memory/weak_ptr.h" |
| 41 #include "base/observer_list.h" | 41 #include "base/observer_list.h" |
| 42 #include "base/scoped_ptr.h" | 42 #include "base/scoped_ptr.h" |
| 43 #include "base/time.h" | 43 #include "base/time.h" |
| 44 #include "chrome/browser/download/download_status_updater_delegate.h" | 44 #include "chrome/browser/download/download_status_updater_delegate.h" |
| 45 #include "chrome/browser/download/download_process_handle.h" | |
| 45 #include "chrome/browser/ui/shell_dialogs.h" | 46 #include "chrome/browser/ui/shell_dialogs.h" |
| 46 #include "content/browser/browser_thread.h" | 47 #include "content/browser/browser_thread.h" |
| 47 | 48 |
| 48 class DownloadFileManager; | 49 class DownloadFileManager; |
| 49 class DownloadHistory; | 50 class DownloadHistory; |
| 50 class DownloadItem; | 51 class DownloadItem; |
| 51 class DownloadPrefs; | 52 class DownloadPrefs; |
| 52 class DownloadStatusUpdater; | 53 class DownloadStatusUpdater; |
| 53 class GURL; | 54 class GURL; |
| 54 class Profile; | 55 class Profile; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 // Remove a download observer from ourself. | 191 // Remove a download observer from ourself. |
| 191 void RemoveObserver(Observer* observer); | 192 void RemoveObserver(Observer* observer); |
| 192 | 193 |
| 193 // Methods called on completion of a query sent to the history system. | 194 // Methods called on completion of a query sent to the history system. |
| 194 void OnQueryDownloadEntriesComplete( | 195 void OnQueryDownloadEntriesComplete( |
| 195 std::vector<DownloadCreateInfo>* entries); | 196 std::vector<DownloadCreateInfo>* entries); |
| 196 void OnCreateDownloadEntryComplete( | 197 void OnCreateDownloadEntryComplete( |
| 197 DownloadCreateInfo info, int64 db_handle); | 198 DownloadCreateInfo info, int64 db_handle); |
| 198 | 199 |
| 199 // Display a new download in the appropriate browser UI. | 200 // Display a new download in the appropriate browser UI. |
| 200 void ShowDownloadInBrowser(const DownloadCreateInfo& info, | 201 void ShowDownloadInBrowser(DownloadProcessHandle process_handle, |
|
Paweł Hajdan Jr.
2011/05/09 19:47:31
nit: Why not a pointer?
ahendrickson
2011/05/10 18:04:43
Done.
This function is only called from within on
| |
| 201 DownloadItem* download); | 202 DownloadItem* download); |
| 202 | 203 |
| 203 // The number of in progress (including paused) downloads. | 204 // The number of in progress (including paused) downloads. |
| 204 int in_progress_count() const { | 205 int in_progress_count() const { |
| 205 return static_cast<int>(in_progress_.size()); | 206 return static_cast<int>(in_progress_.size()); |
| 206 } | 207 } |
| 207 | 208 |
| 208 Profile* profile() { return profile_; } | 209 Profile* profile() { return profile_; } |
| 209 | 210 |
| 210 DownloadHistory* download_history() { return download_history_.get(); } | 211 DownloadHistory* download_history() { return download_history_.get(); } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 // suggested file path exists. | 283 // suggested file path exists. |
| 283 void OnPathExistenceAvailable(DownloadCreateInfo* info); | 284 void OnPathExistenceAvailable(DownloadCreateInfo* info); |
| 284 | 285 |
| 285 // Called back after a target path for the file to be downloaded to has been | 286 // Called back after a target path for the file to be downloaded to has been |
| 286 // determined, either automatically based on the suggested file name, or by | 287 // determined, either automatically based on the suggested file name, or by |
| 287 // the user in a Save As dialog box. | 288 // the user in a Save As dialog box. |
| 288 void AttachDownloadItem(DownloadCreateInfo* info); | 289 void AttachDownloadItem(DownloadCreateInfo* info); |
| 289 | 290 |
| 290 // Download cancel helper function. | 291 // Download cancel helper function. |
| 291 void DownloadCancelledInternal(int download_id, | 292 void DownloadCancelledInternal(int download_id, |
| 292 int render_process_id, | 293 DownloadProcessHandle process_handle); |
|
Paweł Hajdan Jr.
2011/05/09 19:47:31
nit: Why not a pointer?
ahendrickson
2011/05/10 18:04:43
Because it is ultimately passed to another thread,
| |
| 293 int request_id); | |
| 294 | 294 |
| 295 // All data has been downloaded. | 295 // All data has been downloaded. |
| 296 // |hash| is sha256 hash for the downloaded file. It is empty when the hash | 296 // |hash| is sha256 hash for the downloaded file. It is empty when the hash |
| 297 // is not available. | 297 // is not available. |
| 298 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); | 298 void OnAllDataSaved(int32 download_id, int64 size, const std::string& hash); |
| 299 | 299 |
| 300 // An error occurred in the download. | 300 // An error occurred in the download. |
| 301 void OnDownloadError(int32 download_id, int64 size, int os_error); | 301 void OnDownloadError(int32 download_id, int64 size, int os_error); |
| 302 | 302 |
| 303 // Updates the app icon about the overall download progress. | 303 // Updates the app icon about the overall download progress. |
| 304 void UpdateAppIcon(); | 304 void UpdateAppIcon(); |
| 305 | 305 |
| 306 // Makes the ResourceDispatcherHost pause/un-pause a download request. | 306 // Makes the ResourceDispatcherHost pause/un-pause a download request. |
| 307 // Called on the IO thread. | 307 // Called on the IO thread. |
| 308 void PauseDownloadRequest(ResourceDispatcherHost* rdh, | 308 void PauseDownloadRequest(ResourceDispatcherHost* rdh, |
| 309 int render_process_id, | 309 DownloadProcessHandle process_handle, |
|
Paweł Hajdan Jr.
2011/05/09 19:47:31
nit: Why not a pointer?
ahendrickson
2011/05/10 18:04:43
Because it's called from other threads, and this w
| |
| 310 int request_id, | |
| 311 bool pause); | 310 bool pause); |
| 312 | 311 |
| 313 // Inform observers that the model has changed. | 312 // Inform observers that the model has changed. |
| 314 void NotifyModelChanged(); | 313 void NotifyModelChanged(); |
| 315 | 314 |
| 316 DownloadItem* GetDownloadItem(int id); | 315 DownloadItem* GetDownloadItem(int id); |
| 317 | 316 |
| 318 // Debugging routine to confirm relationship between below | 317 // Debugging routine to confirm relationship between below |
| 319 // containers; no-op if NDEBUG. | 318 // containers; no-op if NDEBUG. |
| 320 void AssertContainersConsistent() const; | 319 void AssertContainersConsistent() const; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 // The "Save As" dialog box used to ask the user where a file should be | 392 // The "Save As" dialog box used to ask the user where a file should be |
| 394 // saved. | 393 // saved. |
| 395 scoped_refptr<SelectFileDialog> select_file_dialog_; | 394 scoped_refptr<SelectFileDialog> select_file_dialog_; |
| 396 | 395 |
| 397 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; | 396 scoped_ptr<OtherDownloadManagerObserver> other_download_manager_observer_; |
| 398 | 397 |
| 399 DISALLOW_COPY_AND_ASSIGN(DownloadManager); | 398 DISALLOW_COPY_AND_ASSIGN(DownloadManager); |
| 400 }; | 399 }; |
| 401 | 400 |
| 402 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ | 401 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ |
| OLD | NEW |