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

Unified Diff: content/browser/download/download_manager_impl.h

Issue 23496076: WIP - Refactor programmatic downloads Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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: content/browser/download/download_manager_impl.h
diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h
index a9384c7567f72a34544d9361d6398666af93f382..62dfa88c9959ab2ae024e4d83aa887a18464a6c1 100644
--- a/content/browser/download/download_manager_impl.h
+++ b/content/browser/download/download_manager_impl.h
@@ -11,6 +11,7 @@
#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/sequenced_task_runner_helpers.h"
@@ -29,7 +30,7 @@ namespace content {
class DownloadFileFactory;
class DownloadItemFactory;
class DownloadItemImpl;
-class DownloadRequestHandleInterface;
+class DownloadRequestHandle;
class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
private DownloadItemImplDelegate {
@@ -42,16 +43,9 @@ class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
virtual ~DownloadManagerImpl();
// Implementation functions (not part of the DownloadManager interface).
-
- // Creates a download item for the SavePackage system.
- // Must be called on the UI thread. Note that the DownloadManager
- // retains ownership.
virtual void CreateSavePackageDownloadItem(
- const base::FilePath& main_file_path,
- const GURL& page_url,
- const std::string& mime_type,
- scoped_ptr<DownloadRequestHandleInterface> request_handle,
- const DownloadItemImplCreated& item_created);
+ scoped_ptr<DownloadCreateInfo> info,
+ const DownloadItemImplCreated& created_callback);
// Notifies DownloadManager about a successful completion of |download_item|.
void OnSavePackageSuccessfullyFinished(DownloadItem* download_item);
@@ -61,10 +55,9 @@ class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
virtual DownloadManagerDelegate* GetDelegate() const OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual void GetAllDownloads(DownloadVector* result) OVERRIDE;
- virtual void StartDownload(
- scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<ByteStreamReader> stream,
- const DownloadUrlParameters::OnStartedCallback& on_started) OVERRIDE;
+ virtual void StartDownloadWithActiveRequest(
+ scoped_ptr<DownloadRequestHandle> request_handle,
+ scoped_ptr<DownloadCreateInfo> info) OVERRIDE;
virtual int RemoveDownloadsBetween(base::Time remove_begin,
base::Time remove_end) OVERRIDE;
virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE;
@@ -109,25 +102,35 @@ class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
friend class DownloadManagerTest;
friend class DownloadTest;
- void StartDownloadWithId(
- scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<ByteStreamReader> stream,
- const DownloadUrlParameters::OnStartedCallback& on_started,
+ DownloadItemImpl* UpdateAndGetResumedDownloadItem(
+ uint32 download_id,
+ DownloadRequestHandle* request_handle,
+ const DownloadCreateInfo& new_create_info);
+
+ void DownloadUrlWithId(scoped_ptr<DownloadUrlParameters> params,
+ bool new_download,
+ uint32 download_id);
+
+ void OnDownloadRequestStarted(
+ uint32 download_id,
bool new_download,
- uint32 id);
+ const DownloadUrlParameters::OnStartedCallback& on_started,
+ DownloadRequestHandle* request_handle,
+ DownloadInterruptReason interrupt_reason,
+ scoped_ptr<DownloadCreateInfo> create_info);
+
+ void StartDownloadWithId(scoped_ptr<DownloadRequestHandle> request_handle,
+ scoped_ptr<DownloadCreateInfo> info,
+ uint32 id);
void CreateSavePackageDownloadItemWithId(
- const base::FilePath& main_file_path,
- const GURL& page_url,
- const std::string& mime_type,
- scoped_ptr<DownloadRequestHandleInterface> request_handle,
- const DownloadItemImplCreated& on_started,
+ scoped_ptr<DownloadCreateInfo> info,
+ const DownloadItemImplCreated& download_created_callback,
uint32 id);
// Create a new active item based on the info. Separate from
// StartDownload() for testing.
- DownloadItemImpl* CreateActiveItem(uint32 id,
- const DownloadCreateInfo& info);
+ DownloadItemImpl* CreateActiveItem(uint32 id, const DownloadCreateInfo& info);
// Get next download id. |callback| is called on the UI thread and may
// be called synchronously.
@@ -169,6 +172,15 @@ class CONTENT_EXPORT DownloadManagerImpl : public DownloadManager,
// "save page as" downloads.
DownloadMap downloads_;
+ // Handles to programmatic download requests that are still pending. These
+ // are kept here so that if the DownloadManager were to be destroyed while the
+ // requests are still pending, the associated handles and, by extension, the
+ // URLRequest will also be destroyed.
+ //
+ // TODO(asanka): Move towards model of constructing the DownloadItem early and
+ // then having the DownloadItem own the request handle.
+ ScopedVector<DownloadRequestHandle> pending_requests_;
+
int history_size_;
// True if the download manager has been initialized and requires a shutdown.
« no previous file with comments | « content/browser/download/download_item_impl_unittest.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698