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

Side by Side Diff: chrome/browser/download/download_manager.h

Issue 306032: Simplify threading in browser thread by making only ChromeThread deal with di... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: a few more simplifications Created 11 years, 1 month 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 // Each download is represented by a DownloadItem, and all DownloadItems 10 // Each download is represented by a DownloadItem, and all DownloadItems
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 bool Init(Profile* profile); 342 bool Init(Profile* profile);
343 343
344 // Schedule a query of the history service to retrieve all downloads. 344 // Schedule a query of the history service to retrieve all downloads.
345 void QueryHistoryForDownloads(); 345 void QueryHistoryForDownloads();
346 346
347 // Notifications sent from the download thread to the UI thread 347 // Notifications sent from the download thread to the UI thread
348 void StartDownload(DownloadCreateInfo* info); 348 void StartDownload(DownloadCreateInfo* info);
349 void UpdateDownload(int32 download_id, int64 size); 349 void UpdateDownload(int32 download_id, int64 size);
350 void DownloadFinished(int32 download_id, int64 size); 350 void DownloadFinished(int32 download_id, int64 size);
351 351
352 // Helper method for cancelling the network request associated with a 352 // Called from a view when a user clicks a UI button or link.
353 // download.
354 static void CancelDownloadRequest(int render_process_id, int request_id);
355
356 // Called from a view when a user clicks a UI button or link.
357 void DownloadCancelled(int32 download_id); 353 void DownloadCancelled(int32 download_id);
358 void PauseDownload(int32 download_id, bool pause); 354 void PauseDownload(int32 download_id, bool pause);
359 void RemoveDownload(int64 download_handle); 355 void RemoveDownload(int64 download_handle);
360 356
361 // Called when the download is renamed to its final name. 357 // Called when the download is renamed to its final name.
362 void DownloadRenamedToFinalName(int download_id, const FilePath& full_path); 358 void DownloadRenamedToFinalName(int download_id, const FilePath& full_path);
363 359
364 // Remove downloads after remove_begin (inclusive) and before remove_end 360 // Remove downloads after remove_begin (inclusive) and before remove_end
365 // (exclusive). You may pass in null Time values to do an unbounded delete 361 // (exclusive). You may pass in null Time values to do an unbounded delete
366 // in either direction. 362 // in either direction.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 // Used to make sure we have a safe file extension and filename for a 450 // Used to make sure we have a safe file extension and filename for a
455 // download. |file_name| can either be just the file name or it can be a 451 // download. |file_name| can either be just the file name or it can be a
456 // full path to a file. 452 // full path to a file.
457 void GenerateSafeFilename(const std::string& mime_type, 453 void GenerateSafeFilename(const std::string& mime_type,
458 FilePath* file_name); 454 FilePath* file_name);
459 455
460 // Used to determine whether the download item is an extension file or not. 456 // Used to determine whether the download item is an extension file or not.
461 static bool IsExtensionInstall(const DownloadItem* item); 457 static bool IsExtensionInstall(const DownloadItem* item);
462 static bool IsExtensionInstall(const DownloadCreateInfo* info); 458 static bool IsExtensionInstall(const DownloadCreateInfo* info);
463 459
460 // Runs the network cancel. Must be called on the IO thread.
461 static void OnCancelDownloadRequest(ResourceDispatcherHost* rdh,
462 int render_process_id,
463 int request_id);
464
464 private: 465 private:
465 // Opens a download via the Windows shell. 466 // Opens a download via the Windows shell.
466 void OpenDownloadInShell(const DownloadItem* download, 467 void OpenDownloadInShell(const DownloadItem* download,
467 gfx::NativeView parent_window); 468 gfx::NativeView parent_window);
468 469
469 // Opens downloaded Chrome extension file (*.crx). 470 // Opens downloaded Chrome extension file (*.crx).
470 void OpenChromeExtension(const FilePath& full_path, const GURL& download_url, 471 void OpenChromeExtension(const FilePath& full_path, const GURL& download_url,
471 const GURL& referrer_url); 472 const GURL& referrer_url);
472 473
473 // Shutdown the download manager. This call is needed only after Init. 474 // Shutdown the download manager. This call is needed only after Init.
(...skipping 29 matching lines...) Expand all
503 void GenerateFilename(DownloadCreateInfo* info, FilePath* generated_name); 504 void GenerateFilename(DownloadCreateInfo* info, FilePath* generated_name);
504 505
505 // Persist the automatic opening preference. 506 // Persist the automatic opening preference.
506 void SaveAutoOpens(); 507 void SaveAutoOpens();
507 508
508 // Download cancel helper function. 509 // Download cancel helper function.
509 void DownloadCancelledInternal(int download_id, 510 void DownloadCancelledInternal(int download_id,
510 int render_process_id, 511 int render_process_id,
511 int request_id); 512 int request_id);
512 513
513 // Runs the network cancel on the IO thread.
514 static void OnCancelDownloadRequest(ResourceDispatcherHost* rdh,
515 int render_process_id,
516 int request_id);
517
518 // Runs the pause on the IO thread. 514 // Runs the pause on the IO thread.
519 static void OnPauseDownloadRequest(ResourceDispatcherHost* rdh, 515 static void OnPauseDownloadRequest(ResourceDispatcherHost* rdh,
520 int render_process_id, 516 int render_process_id,
521 int request_id, 517 int request_id,
522 bool pause); 518 bool pause);
523 519
524 // Performs the last steps required when a download has been completed. 520 // Performs the last steps required when a download has been completed.
525 // It is necessary to break down the flow when a download is finished as 521 // It is necessary to break down the flow when a download is finished as
526 // dangerous downloads are downloaded to temporary files that need to be 522 // dangerous downloads are downloaded to temporary files that need to be
527 // renamed on the file thread first. 523 // renamed on the file thread first.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 PendingFinishedMap pending_finished_downloads_; 619 PendingFinishedMap pending_finished_downloads_;
624 620
625 // The "Save As" dialog box used to ask the user where a file should be 621 // The "Save As" dialog box used to ask the user where a file should be
626 // saved. 622 // saved.
627 scoped_refptr<SelectFileDialog> select_file_dialog_; 623 scoped_refptr<SelectFileDialog> select_file_dialog_;
628 624
629 DISALLOW_COPY_AND_ASSIGN(DownloadManager); 625 DISALLOW_COPY_AND_ASSIGN(DownloadManager);
630 }; 626 };
631 627
632 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_ 628 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698