diff options
author | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 00:46:53 +0000 |
---|---|---|
committer | benjhayden@chromium.org <benjhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-29 00:46:53 +0000 |
commit | 2909e34853b862eb037ff68891af80b749073274 (patch) | |
tree | 43d5959a44bf7ced269f53769d2d9cf53e17d7a8 /content/shell | |
parent | e3b140eae1c14a6b76dedf0d5b7d9dd3c40af895 (diff) | |
download | chromium_src-2909e34853b862eb037ff68891af80b749073274.zip chromium_src-2909e34853b862eb037ff68891af80b749073274.tar.gz chromium_src-2909e34853b862eb037ff68891af80b749073274.tar.bz2 |
Fix history importing by delaying DownloadManager creation. Replace GetNextIdThunkType with DownloadIdFactory (RefCountedThreadSafe, created by DownloadService).
DownloadService uses the same DownloadIdFactory for an OTR profile as its original profile.
DownloadService passes the DownloadIdFactory into the DownloadManager so that the DownloadManager can allocate new valid ids for items loaded from the history or downloads started on the ui thread.
Since the DownloadService precedes and outlives its DownloadManager, DownloadManager does not have a scoped_refptr<DownloadIdFactory>. Objects that do have a scoped_refptr<DownloadIdFactory>: DownloadService, ProfileIOData, ShellBrowserContext, ShellResourceContext.
The DownloadIdFactory must be RefCountedThreadSafe because ProfileIOData outlives Profile and because it's used in both the OTR and original profiles.
Longer term, the import process should strictly precede profile initialization, and the next_download_id counter should be loaded from the History db strictly before DownloadService is created and creates a DownloadIdFactory.
BUG=98966
Review URL: http://codereview.chromium.org/8401001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r-- | content/shell/shell_browser_context.cc | 7 | ||||
-rw-r--r-- | content/shell/shell_browser_context.h | 2 | ||||
-rw-r--r-- | content/shell/shell_resource_context.cc | 7 | ||||
-rw-r--r-- | content/shell/shell_resource_context.h | 6 |
4 files changed, 14 insertions, 8 deletions
diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index 94ab2f1..78bef35 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -9,6 +9,7 @@ #include "base/path_service.h" #include "content/browser/appcache/chrome_appcache_service.h" #include "content/browser/chrome_blob_storage_context.h" +#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_manager.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/file_system/browser_file_system_helper.h" @@ -80,7 +81,8 @@ namespace content { ShellBrowserContext::ShellBrowserContext( ShellBrowserMainParts* shell_main_parts) - : shell_main_parts_(shell_main_parts) { + : download_id_factory_(new DownloadIdFactory(this)), + shell_main_parts_(shell_main_parts) { } ShellBrowserContext::~ShellBrowserContext() { @@ -123,6 +125,7 @@ DownloadManager* ShellBrowserContext::GetDownloadManager() { download_manager_delegate_ = new ShellDownloadManagerDelegate(); download_manager_ = new DownloadManager(download_manager_delegate_, + download_id_factory_, download_status_updater_.get()); download_manager_delegate_->SetDownloadManager(download_manager_.get()); download_manager_->Init(this); @@ -156,7 +159,7 @@ const ResourceContext& ShellBrowserContext::GetResourceContext() { resource_context_.reset(new ShellResourceContext( static_cast<ShellURLRequestContextGetter*>(GetRequestContext()), GetBlobStorageContext(), - GetDownloadManager()->GetNextIdThunk())); + download_id_factory_)); } return *resource_context_.get(); } diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index c6471ee..55ee135 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -12,6 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "content/browser/browser_context.h" +class DownloadIdFactory; class DownloadManager; class DownloadStatusUpdater; class GeolocationPermissionContext; @@ -60,6 +61,7 @@ class ShellBrowserContext : public BrowserContext { scoped_ptr<SSLHostState> ssl_host_state_; scoped_ptr<DownloadStatusUpdater> download_status_updater_; scoped_refptr<ShellDownloadManagerDelegate> download_manager_delegate_; + scoped_refptr<DownloadIdFactory> download_id_factory_; scoped_refptr<DownloadManager> download_manager_; scoped_refptr<net::URLRequestContextGetter> url_request_getter_; scoped_refptr<HostZoomMap> host_zoom_map_; diff --git a/content/shell/shell_resource_context.cc b/content/shell/shell_resource_context.cc index 5058992..21a696f 100644 --- a/content/shell/shell_resource_context.cc +++ b/content/shell/shell_resource_context.cc @@ -5,6 +5,7 @@ #include "content/shell/shell_resource_context.h" #include "content/browser/chrome_blob_storage_context.h" +#include "content/browser/download/download_id_factory.h" #include "content/shell/shell_url_request_context_getter.h" namespace content { @@ -12,10 +13,10 @@ namespace content { ShellResourceContext::ShellResourceContext( ShellURLRequestContextGetter* getter, ChromeBlobStorageContext* blob_storage_context, - DownloadManager::GetNextIdThunkType next_download_id_thunk) + DownloadIdFactory* download_id_factory) : getter_(getter), blob_storage_context_(blob_storage_context), - next_download_id_thunk_(next_download_id_thunk) { + download_id_factory_(download_id_factory) { } ShellResourceContext::~ShellResourceContext() { @@ -29,7 +30,7 @@ void ShellResourceContext::InitializeInternal() { set_request_context(getter_->GetURLRequestContext()); set_host_resolver(getter_->host_resolver()); set_blob_storage_context(blob_storage_context_); - set_next_download_id_thunk(next_download_id_thunk_); + set_download_id_factory(download_id_factory_); } } // namespace content diff --git a/content/shell/shell_resource_context.h b/content/shell/shell_resource_context.h index bafb05b..710778e 100644 --- a/content/shell/shell_resource_context.h +++ b/content/shell/shell_resource_context.h @@ -8,10 +8,10 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" -#include "content/browser/download/download_manager.h" #include "content/browser/resource_context.h" class ChromeBlobStorageContext; +class DownloadIdFactory; namespace content { @@ -22,7 +22,7 @@ class ShellResourceContext : public content::ResourceContext { ShellResourceContext( ShellURLRequestContextGetter* getter, ChromeBlobStorageContext* blob_storage_context, - DownloadManager::GetNextIdThunkType next_download_id_thunk); + DownloadIdFactory* download_id_factory); virtual ~ShellResourceContext(); private: @@ -32,7 +32,7 @@ class ShellResourceContext : public content::ResourceContext { scoped_refptr<ShellURLRequestContextGetter> getter_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; - DownloadManager::GetNextIdThunkType next_download_id_thunk_; + scoped_refptr<DownloadIdFactory> download_id_factory_; DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); }; |