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

Unified Diff: chrome/browser/download/download_manager.h

Issue 7294013: Modified cancel and interrupt processing to avoid race with history. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments, fixed some stuff from try jobs. Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_manager.h
diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h
index 241c894d4ccaa7993366fe8dc131e3da53bcd104..e7c426375011c9a383327080a4b8908ab88ecf16 100644
--- a/chrome/browser/download/download_manager.h
+++ b/chrome/browser/download/download_manager.h
@@ -123,9 +123,22 @@ class DownloadManager
void OnResponseCompleted(int32 download_id, int64 size, int os_error,
const std::string& hash);
- // Called from a view when a user clicks a UI button or link.
- void DownloadCancelled(int32 download_id);
- void RemoveDownload(int64 download_handle);
+ // Called to initiate download cancel on behalf of an off-thread portion
+ // of the download system; redirects to DownloadItem.
+ void CancelDownload(int32 download_handle);
+
+ // This routine is called from the DownloadItem when a
+ // request is cancelled or interrupted. It removes the download
+ // from all internal queues holding in-progress work, and takes care
+ // of the off-thread aspects of the cancel (stopping the request,
+ // cancelling the download on the file thread).
+ void DownloadStopped(int32 download_id);
+
+ // Called from DownloadItem when the download is being removed.
+ // Takes care of all history operations, modifying internal queues,
+ // and notifying DownloadManager observers, and actually deletes
+ // the DownloadItem.
+ void RemoveDownload(DownloadItem* download);
// Determine if the download is ready for completion, i.e. has had
// all data saved, and completed the filename determination and
@@ -267,10 +280,6 @@ class DownloadManager
DownloadItem* GetDownloadItem(int id);
private:
- // For testing.
- friend class DownloadManagerTest;
- friend class MockDownloadManager;
-
// This class is used to let an incognito DownloadManager observe changes to
// a normal DownloadManager, to propagate ModelChanged() calls from the parent
// DownloadManager to the observers of the incognito DownloadManager.
@@ -296,6 +305,11 @@ class DownloadManager
friend class DeleteTask<DownloadManager>;
friend class OtherDownloadManagerObserver;
+ // For testing.
+ friend class DownloadManagerTest;
+ friend class MockDownloadManager;
+ friend class DownloadTest;
+
virtual ~DownloadManager();
// Called on the FILE thread to check the existence of a downloaded file.
@@ -324,12 +338,6 @@ class DownloadManager
void ContinueDownloadWithPath(DownloadItem* download,
const FilePath& chosen_file);
- // Download cancel helper function.
- // |request_handle| is passed by value because it is ultimately passed to
- // other threads, and this way we don't have to worry about object lifetimes.
- void DownloadCancelledInternal(int download_id,
- DownloadRequestHandle request_handle);
-
// All data has been downloaded.
// |hash| is sha256 hash for the downloaded file. It is empty when the hash
// is not available.
@@ -344,6 +352,12 @@ class DownloadManager
// Inform observers that the model has changed.
void NotifyModelChanged();
+ // Return all in progress downloads. This includes downloads that
+ // have not yet been entered into the history (all other accessors
+ // only return downloads that have been entered into the history).
+ // This is intended to be used for testing only.
+ void GetInProgressDownloads(std::vector<DownloadItem*>* result);
+
// Get the download item from the active map. Useful when the item is not
// yet in the history map.
DownloadItem* GetActiveDownloadItem(int id);

Powered by Google App Engine
This is Rietveld 408576698