summaryrefslogtreecommitdiffstats
path: root/content/browser/download/download_resource_handler.h
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-29 18:43:50 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-29 18:43:50 +0000
commit0b6006406af742ca7637b928b87fa837c7b2e917 (patch)
treec85ff7a2b54b37758a0f0bd6ff4e9b100ebcd21d /content/browser/download/download_resource_handler.h
parent2ff744dc8c33ca3dfa2068c9488ee56b391e9622 (diff)
downloadchromium_src-0b6006406af742ca7637b928b87fa837c7b2e917.zip
chromium_src-0b6006406af742ca7637b928b87fa837c7b2e917.tar.gz
chromium_src-0b6006406af742ca7637b928b87fa837c7b2e917.tar.bz2
Revert 98656 - Make a new integer field in sql::MetaTable (a per-profile db) containing a counter for the next download id, so that this id is unique across sessions. This id will allow us to merge download id with db_handle and merge most/all of the maps in DownloadManager in future CLs.
Make DownloadManager read this field to initialize its next_id_ counter in Init(). Put a fine-grained mutex in DownloadManager::GetNextId() so that it can be called directly from any thread. Define a thunk wrapping DM::GNI() to be passed around between threads to guard against other threads calling any other DM methods. This thunk owns a scoped_refptr<DM> to manage life-time issues. This pattern is implemented for DM elsewhere. Store this thunk in ResourceContext to be called by ResourceDispatchHost/DownloadThrottlingResourceHandler on the IO thread. Pass the returned DownloadId into DownloadResourceHandler. The alternative way to obtain ids on the IO thread is to jump over to the UI thread and back. This way would add significant latency to a critical path. GetNextId() should be fast and easily accessible from any thread. Now that ids are per-profile, define a class DownloadId containing a per-profile id and an indication of which profile, currently the DownloadManager*. DownloadIds are hashable, comparable, globally unique, not persistent, and are used by DownloadFileManager. When the download is added to the history, MetaTable.next_download_id will be set to the new download's id +1 if that number is greater than MT.next_download_id. Increasing this counter at the same time as the download is added to the db prevents the counter from desyncing from the db, which was the primary concern re storing the counter in the BrowserPrefs. See also http://codereview.chromium.org/7192016 LMK what to write a test for if anything. Review URL: http://codereview.chromium.org/7237034 TBR=benjhayden@chromium.org Review URL: http://codereview.chromium.org/7793003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_resource_handler.h')
-rw-r--r--content/browser/download/download_resource_handler.h23
1 files changed, 10 insertions, 13 deletions
diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h
index e864c0e..b4cdbd6 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -11,7 +11,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/timer.h"
#include "content/browser/download/download_file.h"
-#include "content/browser/download/download_id.h"
#include "content/browser/renderer_host/global_request_id.h"
#include "content/browser/renderer_host/resource_handler.h"
@@ -26,17 +25,15 @@ class URLRequest;
// Forwards data to the download thread.
class DownloadResourceHandler : public ResourceHandler {
public:
- DownloadResourceHandler(
- ResourceDispatcherHost* rdh,
- int render_process_host_id,
- int render_view_id,
- int request_id,
- const GURL& url,
- DownloadId dl_id,
- DownloadFileManager* download_file_manager,
- net::URLRequest* request,
- bool save_as,
- const DownloadSaveInfo& save_info);
+ DownloadResourceHandler(ResourceDispatcherHost* rdh,
+ int render_process_host_id,
+ int render_view_id,
+ int request_id,
+ const GURL& url,
+ DownloadFileManager* download_file_manager,
+ net::URLRequest* request,
+ bool save_as,
+ const DownloadSaveInfo& save_info);
virtual bool OnUploadProgress(int request_id, uint64 position, uint64 size);
@@ -78,7 +75,7 @@ class DownloadResourceHandler : public ResourceHandler {
void StartPauseTimer();
- DownloadId download_id_;
+ int download_id_;
GlobalRequestID global_id_;
int render_view_id_;
scoped_refptr<net::IOBuffer> read_buffer_;