diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 00:35:42 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-27 00:35:42 +0000 |
commit | 98e814064fa88ec31318ce94d8f20c9fba0e92ff (patch) | |
tree | a00e0dbcf23ea0d8d797e360ea422bea346f9b00 | |
parent | f9fac85d18493f8b83152d11652bbf4a24f02338 (diff) | |
download | chromium_src-98e814064fa88ec31318ce94d8f20c9fba0e92ff.zip chromium_src-98e814064fa88ec31318ce94d8f20c9fba0e92ff.tar.gz chromium_src-98e814064fa88ec31318ce94d8f20c9fba0e92ff.tar.bz2 |
Get rid of DownloadIdFactory and instead get the next id from DownloadManagerDelegate. I've also moved DownloadId to the public directory and into the content namespace.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/9169036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119310 0039d316-1c4b-4281-b951-d872f2087c98
52 files changed, 214 insertions, 303 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 24c0c38..782262b 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -44,8 +44,6 @@ include_rules = [ "+content/browser/download/download_create_info.h", "+content/browser/download/download_file_impl.h", "+content/browser/download/download_file_manager.h", - "+content/browser/download/download_id.h", - "+content/browser/download/download_id_factory.h", "+content/browser/download/download_item_impl.h", "+content/browser/download/download_persistent_store_info.h", "+content/browser/download/download_request_handle.h", diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 4c3cd71..73856ba 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -43,6 +43,7 @@ using content::BrowserThread; using content::DownloadFile; +using content::DownloadId; using content::DownloadItem; using content::DownloadManager; using content::WebContents; @@ -66,6 +67,7 @@ struct SafeBrowsingState : public DownloadItem::ExternalData { ChromeDownloadManagerDelegate::ChromeDownloadManagerDelegate(Profile* profile) : profile_(profile), + next_download_id_(0), download_prefs_(new DownloadPrefs(profile->GetPrefs())) { } @@ -94,6 +96,14 @@ void ChromeDownloadManagerDelegate::Shutdown() { download_prefs_.reset(); } +DownloadId ChromeDownloadManagerDelegate::GetNextId() { + if (!profile_->IsOffTheRecord()) + return DownloadId(this, next_download_id_++); + + return profile_->GetOriginalProfile()->GetDownloadManager()->delegate()-> + GetNextId(); +} + bool ChromeDownloadManagerDelegate::ShouldStartDownload(int32 download_id) { // We create a download item and store it in our download map, and inform the // history system of a new download. Since this method can be called while the diff --git a/chrome/browser/download/chrome_download_manager_delegate.h b/chrome/browser/download/chrome_download_manager_delegate.h index b04282e..d0464763 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.h +++ b/chrome/browser/download/chrome_download_manager_delegate.h @@ -54,6 +54,7 @@ class ChromeDownloadManagerDelegate static bool IsExtensionDownload(const content::DownloadItem* item); virtual void Shutdown() OVERRIDE; + virtual content::DownloadId GetNextId() OVERRIDE; virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; virtual void ChooseDownloadPath(content::WebContents* web_contents, const FilePath& suggested_path, @@ -151,6 +152,7 @@ class ChromeDownloadManagerDelegate void OnItemAddedToPersistentStore(int32 download_id, int64 db_handle); Profile* profile_; + int next_download_id_; scoped_ptr<DownloadPrefs> download_prefs_; scoped_ptr<DownloadHistory> download_history_; diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc index ea638ae..eef4509 100644 --- a/chrome/browser/download/download_extension_api.cc +++ b/chrome/browser/download/download_extension_api.cc @@ -36,7 +36,6 @@ #include "chrome/browser/renderer_host/chrome_render_message_filter.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/webui/web_ui_util.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/download_state_info.h" #include "content/browser/download/download_types.h" #include "content/browser/download/interrupt_reasons.h" @@ -49,6 +48,7 @@ #include "net/url_request/url_request.h" using content::BrowserThread; +using content::DownloadId; using content::DownloadItem; using content::DownloadManager; using content::DownloadQuery; @@ -459,7 +459,7 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() { request->AppendBytesToUpload(iodata_->post_body.data(), iodata_->post_body.size()); } - iodata_->rdh->BeginDownload( + net::Error error = iodata_->rdh->BeginDownload( request.Pass(), save_info, iodata_->save_as, @@ -468,21 +468,20 @@ void DownloadsDownloadFunction::BeginDownloadOnIOThread() { iodata_->render_view_host_routing_id, *(iodata_->resource_context)); iodata_.reset(); -} -void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; - BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( - &DownloadsDownloadFunction::RespondOnUIThread, this, - dl_id.local(), error)); + if (error != net::OK) { + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&DownloadsDownloadFunction::OnStarted, this, + DownloadId::Invalid(), error)); + } } -void DownloadsDownloadFunction::RespondOnUIThread(int dl_id, net::Error error) { +void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - VLOG(1) << __FUNCTION__; - if (dl_id >= 0) { - result_.reset(base::Value::CreateIntegerValue(dl_id)); + VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; + if (dl_id.local() >= 0) { + result_.reset(base::Value::CreateIntegerValue(dl_id.local())); } else { error_ = net::ErrorToString(error); } diff --git a/chrome/browser/download/download_extension_api.h b/chrome/browser/download/download_extension_api.h index 7e6b8c8..c629be2 100644 --- a/chrome/browser/download/download_extension_api.h +++ b/chrome/browser/download/download_extension_api.h @@ -15,6 +15,7 @@ #include "base/string16.h" #include "base/values.h" #include "chrome/browser/extensions/extension_function.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager.h" @@ -139,8 +140,7 @@ class DownloadsDownloadFunction : public AsyncDownloadsFunction { int render_view_host_routing_id; }; void BeginDownloadOnIOThread(); - void OnStarted(DownloadId dl_id, net::Error error); - void RespondOnUIThread(int dl_id, net::Error error); + void OnStarted(content::DownloadId dl_id, net::Error error); scoped_ptr<IOData> iodata_; diff --git a/chrome/browser/download/download_item_unittest.cc b/chrome/browser/download/download_item_unittest.cc index 41c6cf6..dcafc04 100644 --- a/chrome/browser/download/download_item_unittest.cc +++ b/chrome/browser/download/download_item_unittest.cc @@ -7,18 +7,18 @@ #include "base/threading/thread.h" #include "chrome/test/base/testing_profile.h" #include "content/browser/download/download_create_info.h" -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_item_impl.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/interrupt_reasons.h" #include "content/browser/download/mock_download_item.h" +#include "content/public/browser/download_id.h" #include "content/test/test_browser_thread.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; +using content::DownloadId; using content::DownloadItem; using content::DownloadManager; @@ -78,8 +78,7 @@ class DownloadItemTest : public testing::Test { }; DownloadItemTest() - : id_factory_(new DownloadIdFactory(kValidDownloadItemIdDomain)), - ui_thread_(BrowserThread::UI, &loop_) { + : ui_thread_(BrowserThread::UI, &loop_) { } ~DownloadItemTest() { @@ -104,7 +103,9 @@ class DownloadItemTest : public testing::Test { scoped_ptr<DownloadCreateInfo> info_; info_.reset(new DownloadCreateInfo()); - info_->download_id = id_factory_->GetNextId(); + static int next_id; + info_->download_id = + content::DownloadId(kValidDownloadItemIdDomain, ++next_id); info_->prompt_user_for_save_location = false; info_->url_chain.push_back(GURL()); info_->state = state; @@ -128,7 +129,6 @@ class DownloadItemTest : public testing::Test { DownloadStatusUpdater download_status_updater_; private: - scoped_refptr<DownloadIdFactory> id_factory_; MessageLoopForUI loop_; // UI thread. content::TestBrowserThread ui_thread_; diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc index 2b303e8..59723fe 100644 --- a/chrome/browser/download/download_manager_unittest.cc +++ b/chrome/browser/download/download_manager_unittest.cc @@ -28,7 +28,6 @@ #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file_impl.h" #include "content/browser/download/download_file_manager.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/interrupt_reasons.h" @@ -66,6 +65,7 @@ using content::BrowserThread; using content::DownloadFile; +using content::DownloadId; using content::DownloadItem; using content::DownloadManager; using ::testing::ReturnRef; @@ -176,11 +176,8 @@ class DownloadManagerTest : public testing::Test { : profile_(new TestingProfile()), download_manager_delegate_(new TestDownloadManagerDelegate( profile_.get())), - id_factory_(new DownloadIdFactory(kValidIdDomain)), download_manager_(DownloadManager::Create( - download_manager_delegate_, - id_factory_, - &download_status_updater_)), + download_manager_delegate_, &download_status_updater_)), ui_thread_(BrowserThread::UI, &message_loop_), file_thread_(BrowserThread::FILE, &message_loop_), download_buffer_(new content::DownloadBuffer) { @@ -255,7 +252,6 @@ class DownloadManagerTest : public testing::Test { DownloadStatusUpdater download_status_updater_; scoped_ptr<TestingProfile> profile_; scoped_refptr<TestDownloadManagerDelegate> download_manager_delegate_; - scoped_refptr<DownloadIdFactory> id_factory_; scoped_refptr<DownloadManager> download_manager_; scoped_refptr<DownloadFileManager> file_manager_; MessageLoopForUI message_loop_; diff --git a/chrome/browser/download/download_service.cc b/chrome/browser/download/download_service.cc index 98031ec..65e1124 100644 --- a/chrome/browser/download/download_service.cc +++ b/chrome/browser/download/download_service.cc @@ -10,7 +10,6 @@ #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" -#include "content/browser/download/download_id_factory.h" #include "content/public/browser/download_manager.h" using content::DownloadManager; @@ -18,20 +17,10 @@ using content::DownloadManager; DownloadService::DownloadService(Profile* profile) : download_manager_created_(false), profile_(profile) { - if (profile_->IsOffTheRecord()) { - id_factory_ = DownloadServiceFactory::GetForProfile( - profile_->GetOriginalProfile())->GetDownloadIdFactory(); - } else { - id_factory_ = new DownloadIdFactory(this); - } } DownloadService::~DownloadService() {} -DownloadIdFactory* DownloadService::GetDownloadIdFactory() const { - return id_factory_.get(); -} - void DownloadService::OnManagerCreated( const DownloadService::OnManagerCreatedCallback& cb) { if (download_manager_created_) { @@ -48,9 +37,7 @@ DownloadManager* DownloadService::GetDownloadManager() { if (!manager_delegate_.get()) manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); manager_ = DownloadManager::Create( - manager_delegate_.get(), - id_factory_.get(), - g_browser_process->download_status_updater()); + manager_delegate_.get(), g_browser_process->download_status_updater()); manager_->Init(profile_); manager_delegate_->SetDownloadManager(manager_); download_manager_created_ = true; diff --git a/chrome/browser/download/download_service.h b/chrome/browser/download/download_service.h index fb9f24a7..b513199 100644 --- a/chrome/browser/download/download_service.h +++ b/chrome/browser/download/download_service.h @@ -16,7 +16,6 @@ class ChromeDownloadManagerDelegate; class Profile; -class DownloadIdFactory; namespace content { class DownloadManager; @@ -29,8 +28,6 @@ class DownloadService : public ProfileKeyedService { explicit DownloadService(Profile* profile); virtual ~DownloadService(); - DownloadIdFactory* GetDownloadIdFactory() const; - // Register a callback to be called whenever the DownloadManager is created. typedef base::Callback<void(content::DownloadManager*)> OnManagerCreatedCallback; @@ -60,8 +57,6 @@ class DownloadService : public ProfileKeyedService { virtual void Shutdown() OVERRIDE; private: - scoped_refptr<DownloadIdFactory> id_factory_; - bool download_manager_created_; Profile* profile_; diff --git a/chrome/browser/download/download_throttling_resource_handler.cc b/chrome/browser/download/download_throttling_resource_handler.cc index 3d98eee..85bc6e1 100644 --- a/chrome/browser/download/download_throttling_resource_handler.cc +++ b/chrome/browser/download/download_throttling_resource_handler.cc @@ -7,7 +7,6 @@ #include "base/logging.h" #include "chrome/browser/download/download_request_limiter.h" #include "chrome/browser/download/download_util.h" -#include "content/browser/download/download_id.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 514f42d..f58e43a 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc @@ -41,7 +41,6 @@ #include "chrome/common/url_constants.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/host_zoom_map.h" #include "content/browser/renderer_host/media/media_stream_manager.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" @@ -188,9 +187,6 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); PrefService* pref_service = profile->GetPrefs(); - download_id_factory_ = DownloadServiceFactory::GetForProfile(profile)-> - GetDownloadIdFactory(); - scoped_ptr<ProfileParams> params(new ProfileParams); params->path = profile->GetPath(); params->is_incognito = profile->IsOffTheRecord(); @@ -515,7 +511,6 @@ void ProfileIOData::LazyInitialize() const { resource_context_.SetUserData(NULL, const_cast<ProfileIOData*>(this)); resource_context_.set_media_observer( io_thread_globals->media.media_internals.get()); - resource_context_.set_download_id_factory(download_id_factory_); resource_context_.set_media_stream_manager(media_stream_manager_.get()); resource_context_.set_audio_manager(profile_params_->audio_manager); diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index 1eac7a7..349d747 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h @@ -25,7 +25,6 @@ class ChromeAppCacheService; class ChromeBlobStorageContext; class CookieSettings; class DesktopNotificationService; -class DownloadIdFactory; class ExtensionInfoMap; class HostContentSettingsMap; class HostZoomMap; @@ -290,7 +289,6 @@ class ProfileIOData { mutable scoped_refptr<fileapi::FileSystemContext> file_system_context_; mutable scoped_refptr<quota::QuotaManager> quota_manager_; mutable scoped_refptr<HostZoomMap> host_zoom_map_; - mutable scoped_refptr<DownloadIdFactory> download_id_factory_; mutable scoped_ptr<media_stream::MediaStreamManager> media_stream_manager_; // TODO(willchan): Remove from ResourceContext. diff --git a/content/browser/download/download_create_info.cc b/content/browser/download/download_create_info.cc index fbcd175..08999f7 100644 --- a/content/browser/download/download_create_info.cc +++ b/content/browser/download/download_create_info.cc @@ -9,22 +9,24 @@ #include "base/format_macros.h" #include "base/stringprintf.h" -DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, - const GURL& url, - const base::Time& start_time, - int64 received_bytes, - int64 total_bytes, - int32 state, - const DownloadId& download_id, - bool has_user_gesture, - content::PageTransition transition_type) +using content::DownloadId; + +DownloadCreateInfo::DownloadCreateInfo( + const FilePath& path, + const GURL& url, + const base::Time& start_time, + int64 received_bytes, + int64 total_bytes, + int32 state, + bool has_user_gesture, + content::PageTransition transition_type) : path(path), url_chain(1, url), start_time(start_time), received_bytes(received_bytes), total_bytes(total_bytes), state(state), - download_id(download_id), + download_id(DownloadId::Invalid()), has_user_gesture(has_user_gesture), transition_type(transition_type), db_handle(0), diff --git a/content/browser/download/download_create_info.h b/content/browser/download/download_create_info.h index 9be00c1..dbfee7f 100644 --- a/content/browser/download/download_create_info.h +++ b/content/browser/download/download_create_info.h @@ -12,10 +12,10 @@ #include "base/basictypes.h" #include "base/file_path.h" #include "base/time.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/download_types.h" #include "content/common/content_export.h" #include "content/public/browser/download_file.h" +#include "content/public/browser/download_id.h" #include "content/public/common/page_transition_types.h" #include "googleurl/src/gurl.h" @@ -28,7 +28,6 @@ struct CONTENT_EXPORT DownloadCreateInfo { int64 received_bytes, int64 total_bytes, int32 state, - const DownloadId& download_id, bool has_user_gesture, content::PageTransition transition_type); DownloadCreateInfo(); @@ -63,7 +62,7 @@ struct CONTENT_EXPORT DownloadCreateInfo { int32 state; // The (per-session) ID of the download. - DownloadId download_id; + content::DownloadId download_id; // True if the download was initiated by user action. bool has_user_gesture; diff --git a/content/browser/download/download_file_impl.cc b/content/browser/download/download_file_impl.cc index 4cff9e8..408081a 100644 --- a/content/browser/download/download_file_impl.cc +++ b/content/browser/download/download_file_impl.cc @@ -13,6 +13,7 @@ #include "content/public/browser/download_manager.h" using content::BrowserThread; +using content::DownloadId; namespace { diff --git a/content/browser/download/download_file_impl.h b/content/browser/download/download_file_impl.h index 69a7c5e..0521435 100644 --- a/content/browser/download/download_file_impl.h +++ b/content/browser/download/download_file_impl.h @@ -49,7 +49,7 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile { virtual void CancelDownloadRequest() OVERRIDE; virtual int Id() const OVERRIDE; virtual content::DownloadManager* GetDownloadManager() OVERRIDE; - virtual const DownloadId& GlobalId() const OVERRIDE; + virtual const content::DownloadId& GlobalId() const OVERRIDE; virtual std::string DebugString() const OVERRIDE; private: @@ -58,7 +58,7 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile { // The unique identifier for this download, assigned at creation by // the DownloadFileManager for its internal record keeping. - DownloadId id_; + content::DownloadId id_; // The handle to the request information. Used for operations outside the // download system, specifically canceling a download. diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc index 4a1f771..a58cb78 100644 --- a/content/browser/download/download_file_manager.cc +++ b/content/browser/download/download_file_manager.cc @@ -29,6 +29,7 @@ using content::BrowserThread; using content::DownloadFile; +using content::DownloadId; namespace { diff --git a/content/browser/download/download_file_manager.h b/content/browser/download/download_file_manager.h index 4688835..1a3054ef 100644 --- a/content/browser/download/download_file_manager.h +++ b/content/browser/download/download_file_manager.h @@ -49,9 +49,9 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/timer.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/interrupt_reasons.h" #include "content/common/content_export.h" +#include "content/public/browser/download_id.h" #include "net/base/net_errors.h" #include "ui/gfx/native_widget_types.h" @@ -96,14 +96,15 @@ class CONTENT_EXPORT DownloadFileManager // Handlers for notifications sent from the IO thread and run on the // FILE thread. - void UpdateDownload(DownloadId global_id, content::DownloadBuffer* buffer); + void UpdateDownload(content::DownloadId global_id, + content::DownloadBuffer* buffer); // |reason| is the reason for interruption, if one occurs. // |security_info| contains SSL information (cert_id, cert_status, // security_bits, ssl_connection_status), which can be used to // fine-tune the error message. It is empty if the transaction // was not performed securely. - void OnResponseCompleted(DownloadId global_id, + void OnResponseCompleted(content::DownloadId global_id, InterruptReason reason, const std::string& security_info); @@ -112,22 +113,23 @@ class CONTENT_EXPORT DownloadFileManager // download file, as far as the DownloadFileManager is concerned -- if // anything happens to the download file after they are called, it will // be ignored. - void CancelDownload(DownloadId id); - void CompleteDownload(DownloadId id); + void CancelDownload(content::DownloadId id); + void CompleteDownload(content::DownloadId id); // Called on FILE thread by DownloadManager at the beginning of its shutdown. void OnDownloadManagerShutdown(content::DownloadManager* manager); // The DownloadManager in the UI thread has provided an intermediate // .crdownload name for the download specified by |id|. - void RenameInProgressDownloadFile(DownloadId id, const FilePath& full_path); + void RenameInProgressDownloadFile(content::DownloadId id, + const FilePath& full_path); // The DownloadManager in the UI thread has provided a final name for the // download specified by |id|. // |overwrite_existing_file| prevents uniquification, and is used for SAFE // downloads, as the user may have decided to overwrite the file. // Sent from the UI thread and run on the FILE thread. - void RenameCompletingDownloadFile(DownloadId id, + void RenameCompletingDownloadFile(content::DownloadId id, const FilePath& full_path, bool overwrite_existing_file); @@ -161,18 +163,20 @@ class CONTENT_EXPORT DownloadFileManager bool hash_needed); // Called only on the download thread. - content::DownloadFile* GetDownloadFile(DownloadId global_id); + content::DownloadFile* GetDownloadFile(content::DownloadId global_id); // Called only from RenameInProgressDownloadFile and // RenameCompletingDownloadFile on the FILE thread. // |rename_error| indicates what error caused the cancel. - void CancelDownloadOnRename(DownloadId global_id, net::Error rename_error); + void CancelDownloadOnRename(content::DownloadId global_id, + net::Error rename_error); // Erases the download file with the given the download |id| and removes // it from the maps. - void EraseDownload(DownloadId global_id); + void EraseDownload(content::DownloadId global_id); - typedef base::hash_map<DownloadId, content::DownloadFile*> DownloadFileMap; + typedef base::hash_map<content::DownloadId, content::DownloadFile*> + DownloadFileMap; // A map of all in progress downloads. It owns the download files. DownloadFileMap downloads_; diff --git a/content/browser/download/download_file_manager_unittest.cc b/content/browser/download/download_file_manager_unittest.cc index ccbe34c..de710f2 100644 --- a/content/browser/download/download_file_manager_unittest.cc +++ b/content/browser/download/download_file_manager_unittest.cc @@ -11,13 +11,12 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/download/download_buffer.h" #include "content/browser/download/download_create_info.h" -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/mock_download_file.h" #include "content/browser/download/mock_download_manager.h" #include "content/browser/download/mock_download_manager_delegate.h" +#include "content/public/browser/download_id.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" #include "testing/gmock/include/gmock/gmock.h" @@ -25,6 +24,7 @@ using content::BrowserThread; using content::BrowserThreadImpl; +using content::DownloadId; using ::testing::_; using ::testing::AtLeast; @@ -34,8 +34,6 @@ using ::testing::StrEq; namespace { -DownloadId::Domain kValidIdDomain = "valid DownloadId::Domain"; - class MockDownloadFileFactory : public DownloadFileManager::DownloadFileFactory { @@ -114,7 +112,6 @@ class DownloadFileManagerTest : public testing::Test { // destructor being called and we get a leak. DownloadFileManagerTest() : download_buffer_(new content::DownloadBuffer()), - id_factory_(new DownloadIdFactory(kValidIdDomain)), ui_thread_(BrowserThread::UI, &loop_), file_thread_(BrowserThread::FILE, &loop_) { } @@ -431,7 +428,6 @@ class DownloadFileManagerTest : public testing::Test { private: MessageLoop loop_; - scoped_refptr<DownloadIdFactory> id_factory_; // UI thread. BrowserThreadImpl ui_thread_; diff --git a/content/browser/download/download_file_unittest.cc b/content/browser/download/download_file_unittest.cc index 4855d44..9ca77c5 100644 --- a/content/browser/download/download_file_unittest.cc +++ b/content/browser/download/download_file_unittest.cc @@ -8,8 +8,6 @@ #include "content/browser/browser_thread_impl.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file_impl.h" -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/download/mock_download_manager.h" @@ -22,6 +20,7 @@ using content::BrowserThread; using content::BrowserThreadImpl; using content::DownloadFile; +using content::DownloadId; using content::DownloadManager; DownloadId::Domain kValidIdDomain = "valid DownloadId::Domain"; @@ -42,7 +41,6 @@ class DownloadFileTest : public testing::Test { // calling Release() on |download_manager_| won't ever result in its // destructor being called and we get a leak. DownloadFileTest() : - id_factory_(new DownloadIdFactory(kValidIdDomain)), ui_thread_(BrowserThread::UI, &loop_), file_thread_(BrowserThread::FILE, &loop_) { } @@ -113,7 +111,6 @@ class DownloadFileTest : public testing::Test { private: MessageLoop loop_; - scoped_refptr<DownloadIdFactory> id_factory_; // UI thread. BrowserThreadImpl ui_thread_; // File thread to satisfy debug checks in DownloadFile. diff --git a/content/browser/download/download_id.cc b/content/browser/download/download_id.cc deleted file mode 100644 index 8cd7b0e..0000000 --- a/content/browser/download/download_id.cc +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <string> - -#include "base/stringprintf.h" -#include "content/browser/download/download_id.h" - -std::string DownloadId::DebugString() const { - return base::StringPrintf("%p:%d", domain_, local_id_); -} - -std::ostream& operator<<(std::ostream& out, const DownloadId& global_id) { - return out << global_id.DebugString(); -} diff --git a/content/browser/download/download_id_factory.cc b/content/browser/download/download_id_factory.cc deleted file mode 100644 index 6b0797f..0000000 --- a/content/browser/download/download_id_factory.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/download/download_id_factory.h" - -#include "content/browser/download/download_id.h" - -DownloadIdFactory::DownloadIdFactory(DownloadId::Domain domain) - : domain_(domain), - next_id_(0) { -} - -DownloadId DownloadIdFactory::GetNextId() { - base::AutoLock lock(lock_); - return DownloadId(domain_, next_id_++); -} diff --git a/content/browser/download/download_id_factory.h b/content/browser/download/download_id_factory.h deleted file mode 100644 index 729c752..0000000 --- a/content/browser/download/download_id_factory.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_FACTORY_H_ -#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_FACTORY_H_ -#pragma once - -#include "base/memory/ref_counted.h" -#include "base/synchronization/lock.h" -#include "content/browser/download/download_id.h" -#include "content/public/browser/browser_thread.h" - -class CONTENT_EXPORT DownloadIdFactory - : public base::RefCountedThreadSafe<DownloadIdFactory> { - public: - // TODO(benjhayden): Instantiate with an explicit next id counter read from - // persistent storage. - explicit DownloadIdFactory(DownloadId::Domain domain); - - DownloadId GetNextId(); - - private: - DownloadId::Domain domain_; - int next_id_; - base::Lock lock_; - - DISALLOW_COPY_AND_ASSIGN(DownloadIdFactory); -}; - -#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_FACTORY_H_ diff --git a/content/browser/download/download_id_unittest.cc b/content/browser/download/download_id_unittest.cc index 18f157f..5a80a39 100644 --- a/content/browser/download/download_id_unittest.cc +++ b/content/browser/download/download_id_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/download/download_id.h" +#include "content/public/browser/download_id.h" #include <algorithm> #include <map> @@ -17,6 +17,7 @@ using content::BrowserThread; using content::BrowserThreadImpl; +using content::DownloadId; using content::DownloadManager; class DownloadIdTest : public testing::Test { diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc index cc48515..2d1ad6d 100644 --- a/content/browser/download/download_item_impl.cc +++ b/content/browser/download/download_item_impl.cc @@ -19,7 +19,6 @@ #include "base/utf_string_conversions.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file_manager.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/download_persistent_store_info.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_stats.h" @@ -32,6 +31,7 @@ using content::BrowserThread; using content::DownloadFile; +using content::DownloadId; using content::DownloadItem; using content::DownloadManager; using content::WebContents; diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h index 87c7d31..c3d3119 100644 --- a/content/browser/download/download_item_impl.h +++ b/content/browser/download/download_item_impl.h @@ -14,9 +14,9 @@ #include "base/observer_list.h" #include "base/time.h" #include "base/timer.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/download_request_handle.h" #include "content/common/content_export.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_item.h" #include "googleurl/src/gurl.h" #include "net/base/net_errors.h" @@ -82,7 +82,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { // Constructing from persistent store: DownloadItemImpl(Delegate* delegate, - DownloadId download_id, + content::DownloadId download_id, const DownloadPersistentStoreInfo& info); // Constructing for a regular download. @@ -97,7 +97,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { const FilePath& path, const GURL& url, bool is_otr, - DownloadId download_id); + content::DownloadId download_id); virtual ~DownloadItemImpl(); @@ -161,7 +161,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { virtual int64 GetReceivedBytes() const OVERRIDE; virtual const std::string& GetHashState() const OVERRIDE; virtual int32 GetId() const OVERRIDE; - virtual DownloadId GetGlobalId() const OVERRIDE; + virtual content::DownloadId GetGlobalId() const OVERRIDE; virtual base::Time GetStartTime() const OVERRIDE; virtual base::Time GetEndTime() const OVERRIDE; virtual void SetDbHandle(int64 handle) OVERRIDE; @@ -240,7 +240,7 @@ class CONTENT_EXPORT DownloadItemImpl : public content::DownloadItem { scoped_ptr<DownloadRequestHandleInterface> request_handle_; // Download ID assigned by DownloadResourceHandler. - DownloadId download_id_; + content::DownloadId download_id_; // Full path to the downloaded or downloading file. FilePath full_path_; diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc index cc8d55c..2276afc 100644 --- a/content/browser/download/download_manager_impl.cc +++ b/content/browser/download/download_manager_impl.cc @@ -19,7 +19,6 @@ #include "build/build_config.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file_manager.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_item_impl.h" #include "content/browser/download/download_persistent_store_info.h" #include "content/browser/download/download_stats.h" @@ -49,6 +48,7 @@ #define CHECK_96627 CHECK using content::BrowserThread; +using content::DownloadId; using content::DownloadItem; using content::WebContents; @@ -116,16 +116,14 @@ namespace content { // static DownloadManager* DownloadManager::Create( content::DownloadManagerDelegate* delegate, - DownloadIdFactory* id_factory, DownloadStatusUpdater* status_updater) { - return new DownloadManagerImpl(delegate, id_factory, status_updater); + return new DownloadManagerImpl(delegate, status_updater); } } // namespace content DownloadManagerImpl::DownloadManagerImpl( content::DownloadManagerDelegate* delegate, - DownloadIdFactory* id_factory, DownloadStatusUpdater* status_updater) : shutdown_needed_(false), browser_context_(NULL), @@ -134,7 +132,6 @@ DownloadManagerImpl::DownloadManagerImpl( ? status_updater->AsWeakPtr() : base::WeakPtr<DownloadStatusUpdater>()), delegate_(delegate), - id_factory_(id_factory), largest_db_handle_in_history_(DownloadItem::kUninitializedHandle) { // NOTE(benjhayden): status_updater may be NULL when using // TestingBrowserProcess. @@ -147,7 +144,7 @@ DownloadManagerImpl::~DownloadManagerImpl() { } DownloadId DownloadManagerImpl::GetNextId() { - return id_factory_->GetNextId(); + return delegate_->GetNextId(); } bool DownloadManagerImpl::ShouldOpenDownload(DownloadItem* item) { diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h index 3a3253b..b69753d 100644 --- a/content/browser/download/download_manager_impl.h +++ b/content/browser/download/download_manager_impl.h @@ -22,7 +22,6 @@ #include "content/common/content_export.h" #include "content/public/browser/download_manager.h" -class DownloadIdFactory; class DownloadStatusUpdater; namespace content { @@ -35,7 +34,6 @@ class CONTENT_EXPORT DownloadManagerImpl public DownloadStatusUpdaterDelegate { public: DownloadManagerImpl(content::DownloadManagerDelegate* delegate, - DownloadIdFactory* id_factory, DownloadStatusUpdater* status_updater); // content::DownloadManager functions. @@ -153,8 +151,8 @@ class CONTENT_EXPORT DownloadManagerImpl // Show the download in the browser. void ShowDownloadInBrowser(content::DownloadItem* download); - // Get next download id from factory. - DownloadId GetNextId(); + // Get next download id. + content::DownloadId GetNextId(); // Called on the FILE thread to check the existence of a downloaded file. void CheckForFileRemovalOnFileThread(int64 db_handle, const FilePath& path); @@ -270,8 +268,6 @@ class CONTENT_EXPORT DownloadManagerImpl // Allows an embedder to control behavior. Guaranteed to outlive this object. content::DownloadManagerDelegate* delegate_; - DownloadIdFactory* id_factory_; - // TODO(rdsmith): Remove when http://crbug.com/85408 is fixed. // For debugging only. int64 largest_db_handle_in_history_; diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc index 34d072d..43a2e17 100644 --- a/content/browser/download/download_resource_handler.cc +++ b/content/browser/download/download_resource_handler.cc @@ -14,6 +14,7 @@ #include "content/browser/download/download_buffer.h" #include "content/browser/download/download_create_info.h" #include "content/browser/download/download_file_manager.h" +#include "content/browser/download/download_manager_impl.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_stats.h" #include "content/browser/download/interrupt_reasons.h" @@ -21,6 +22,7 @@ #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/download_item.h" +#include "content/public/browser/download_manager_delegate.h" #include "content/public/common/resource_response.h" #include "net/base/io_buffer.h" #include "net/base/net_errors.h" @@ -28,7 +30,9 @@ #include "net/url_request/url_request_context.h" using content::BrowserThread; +using content::DownloadId; using content::DownloadItem; +using content::DownloadManager; DownloadResourceHandler::DownloadResourceHandler( ResourceDispatcherHost* rdh, @@ -36,13 +40,12 @@ DownloadResourceHandler::DownloadResourceHandler( int render_view_id, int request_id, const GURL& url, - DownloadId dl_id, DownloadFileManager* download_file_manager, net::URLRequest* request, bool save_as, const DownloadResourceHandler::OnStartedCallback& started_cb, const DownloadSaveInfo& save_info) - : download_id_(dl_id), + : download_id_(DownloadId::Invalid()), global_id_(render_process_host_id, request_id), render_view_id_(render_view_id), content_length_(0), @@ -56,7 +59,6 @@ DownloadResourceHandler::DownloadResourceHandler( is_paused_(false), last_buffer_size_(0), bytes_read_(0) { - DCHECK(dl_id.IsValid()); download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT); } @@ -79,7 +81,6 @@ bool DownloadResourceHandler::OnRequestRedirected( bool DownloadResourceHandler::OnResponseStarted( int request_id, content::ResourceResponse* response) { - DCHECK(download_id_.IsValid()); VLOG(20) << __FUNCTION__ << "()" << DebugString() << " request_id = " << request_id; download_start_time_ = base::TimeTicks::Now(); @@ -99,15 +100,13 @@ bool DownloadResourceHandler::OnResponseStarted( // Deleted in DownloadManager. DownloadCreateInfo* info = new DownloadCreateInfo(FilePath(), GURL(), base::Time::Now(), 0, content_length_, DownloadItem::IN_PROGRESS, - download_id_, request_info->has_user_gesture(), - request_info->transition_type()); + request_info->has_user_gesture(), request_info->transition_type()); info->url_chain = request_->url_chain(); info->referrer_url = GURL(request_->referrer()); info->start_time = base::Time::Now(); info->received_bytes = save_info_.offset; info->total_bytes = content_length_; info->state = DownloadItem::IN_PROGRESS; - info->download_id = download_id_; info->has_user_gesture = request_info->has_user_gesture(); info->content_disposition = content_disposition_; info->mime_type = response->mime_type; @@ -128,8 +127,6 @@ bool DownloadResourceHandler::OnResponseStarted( info->etag = etag; } - CallStartedCB(net::OK); - std::string content_type_header; if (!response->headers || !response->headers->GetMimeType(&content_type_header)) @@ -147,23 +144,26 @@ bool DownloadResourceHandler::OnResponseStarted( save_as_ && save_info_.file_path.empty(); info->referrer_charset = request_->context()->referrer_charset(); info->save_info = save_info_; + + BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, - base::Bind(&DownloadFileManager::StartDownload, - download_file_manager_, info, request_handle)); + base::Bind(&DownloadResourceHandler::StartOnUIThread, this, + info, request_handle)); - // We can't start saving the data before we create the file on disk. - // The request will be un-paused in DownloadFileManager::CreateDownloadFile. + // We can't start saving the data before we create the file on disk and have a + // download id. The request will be un-paused in + // DownloadFileManager::CreateDownloadFile. rdh_->PauseRequest(global_id_.child_id, global_id_.request_id, true); return true; } -void DownloadResourceHandler::CallStartedCB(net::Error error) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); +void DownloadResourceHandler::CallStartedCB(DownloadId id, net::Error error) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (started_cb_.is_null()) return; - started_cb_.Run(download_id_, error); + started_cb_.Run(id, error); started_cb_.Reset(); } @@ -233,6 +233,20 @@ bool DownloadResourceHandler::OnResponseCompleted( int request_id, const net::URLRequestStatus& status, const std::string& security_info) { + if (!download_id_.IsValid()) { + // We got cancelled before the task which sets the id ran on the IO thread. + // Wait for it. + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(base::IgnoreResult(&BrowserThread::PostTask), + BrowserThread::IO, FROM_HERE, + base::Bind(base::IgnoreResult( + &DownloadResourceHandler::OnResponseCompleted), this, + request_id, status, security_info))); + + return true; + } + VLOG(20) << __FUNCTION__ << "()" << DebugString() << " request_id = " << request_id << " status.status() = " << status.status() @@ -259,8 +273,12 @@ bool DownloadResourceHandler::OnResponseCompleted( download_stats::RecordAcceptsRanges(accept_ranges_, bytes_read_); - if (!download_id_.IsValid()) - CallStartedCB(error_code); + // If the callback was already run on the UI thread, this will be a noop. + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::Bind(&DownloadResourceHandler::CallStartedCB, this, + download_id_, error_code)); + // We transfer ownership to |DownloadFileManager| to delete |buffer_|, // so that any functions queued up on the FILE thread are executed // before deletion. @@ -278,6 +296,29 @@ void DownloadResourceHandler::OnRequestClosed() { base::TimeTicks::Now() - download_start_time_); } +void DownloadResourceHandler::StartOnUIThread(DownloadCreateInfo* info, + DownloadRequestHandle handle) { + DownloadManager* download_manager = handle.GetDownloadManager(); + if (!download_manager) + return; // NULL in unittests + info->download_id = download_manager->delegate()->GetNextId(); + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + base::Bind(&DownloadResourceHandler::set_download_id, this, + info->download_id)); + CallStartedCB(info->download_id, net::OK); + // It's safe to continue on with download initiation before we have + // confirmation that that download_id_ has been set on the IO thread, as any + // messages generated by the UI thread that affect the IO thread will be + // behind the message posted above. + download_file_manager_->StartDownload(info, handle); +} + +void DownloadResourceHandler::set_download_id(content::DownloadId id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + download_id_ = id; +} + // If the content-length header is not present (or contains something other // than numbers), the incoming content_length is -1 (unknown size). // Set the content length to 0 to indicate unknown size to DownloadManager. diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h index 5425c51..b651c48 100644 --- a/content/browser/download/download_resource_handler.h +++ b/content/browser/download/download_resource_handler.h @@ -11,14 +11,16 @@ #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/timer.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/download_types.h" #include "content/browser/renderer_host/resource_handler.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/global_request_id.h" #include "net/base/net_errors.h" class DownloadFileManager; +class DownloadRequestHandle; class ResourceDispatcherHost; +struct DownloadCreateInfo; namespace content { class DownloadBuffer; @@ -31,18 +33,17 @@ class URLRequest; // Forwards data to the download thread. class DownloadResourceHandler : public ResourceHandler { public: - typedef base::Callback<void(DownloadId, net::Error)> - OnStartedCallback; + typedef base::Callback<void(content::DownloadId, net::Error)> + OnStartedCallback; static const size_t kLoadsToWrite = 100; // number of data buffers queued - // started_cb will be called exactly once. + // started_cb will be called exactly once on the UI thread. 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, @@ -97,9 +98,14 @@ class DownloadResourceHandler : public ResourceHandler { virtual ~DownloadResourceHandler(); void StartPauseTimer(); - void CallStartedCB(net::Error error); + void CallStartedCB(content::DownloadId id, net::Error error); - DownloadId download_id_; + // Generates a DownloadId and calls DownloadFileManager. + void StartOnUIThread(DownloadCreateInfo* info, + DownloadRequestHandle handle); + void set_download_id(content::DownloadId id); + + content::DownloadId download_id_; content::GlobalRequestID global_id_; int render_view_id_; scoped_refptr<net::IOBuffer> read_buffer_; @@ -108,6 +114,7 @@ class DownloadResourceHandler : public ResourceHandler { DownloadFileManager* download_file_manager_; net::URLRequest* request_; bool save_as_; // Request was initiated via "Save As" by the user. + // This is used only on the UI thread. OnStartedCallback started_cb_; DownloadSaveInfo save_info_; scoped_refptr<content::DownloadBuffer> buffer_; diff --git a/content/browser/download/mock_download_file.h b/content/browser/download/mock_download_file.h index 2e97b04..6aff4da 100644 --- a/content/browser/download/mock_download_file.h +++ b/content/browser/download/mock_download_file.h @@ -11,9 +11,8 @@ #include "base/file_path.h" #include "base/memory/ref_counted.h" -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_request_handle.h" #include "content/public/browser/download_file.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_manager.h" #include "net/base/net_errors.h" #include "testing/gmock/include/gmock/gmock.h" @@ -43,7 +42,7 @@ class MockDownloadFile : virtual public content::DownloadFile { MOCK_METHOD0(CancelDownloadRequest, void()); MOCK_CONST_METHOD0(Id, int()); MOCK_METHOD0(GetDownloadManager, content::DownloadManager*()); - MOCK_CONST_METHOD0(GlobalId, const DownloadId&()); + MOCK_CONST_METHOD0(GlobalId, const content::DownloadId&()); MOCK_CONST_METHOD0(DebugString, std::string()); }; diff --git a/content/browser/download/mock_download_item.h b/content/browser/download/mock_download_item.h index 42d25b8..1212ee5 100644 --- a/content/browser/download/mock_download_item.h +++ b/content/browser/download/mock_download_item.h @@ -8,9 +8,9 @@ #include <string> #include <vector> -#include "content/browser/download/download_id.h" #include "content/browser/download/download_persistent_store_info.h" #include "content/browser/download/interrupt_reasons.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_item.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -73,7 +73,7 @@ class MockDownloadItem : public content::DownloadItem { MOCK_CONST_METHOD0(GetHashState, const std::string&()); MOCK_CONST_METHOD0(GetHash, const std::string&()); MOCK_CONST_METHOD0(GetId, int32()); - MOCK_CONST_METHOD0(GetGlobalId, DownloadId()); + MOCK_CONST_METHOD0(GetGlobalId, content::DownloadId()); MOCK_CONST_METHOD0(GetStartTime, base::Time()); MOCK_CONST_METHOD0(GetEndTime, base::Time()); MOCK_METHOD1(SetDbHandle, void(int64)); diff --git a/content/browser/download/mock_download_manager.h b/content/browser/download/mock_download_manager.h index cf08d82..6e9be3f 100644 --- a/content/browser/download/mock_download_manager.h +++ b/content/browser/download/mock_download_manager.h @@ -6,10 +6,9 @@ #define CONTENT_BROWSER_DOWNLOAD_MOCK_DOWNLOAD_MANAGER_H_ #pragma once -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_request_handle.h" #include "content/browser/download/download_types.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_item.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/download_query.h" diff --git a/content/browser/download/mock_download_manager_delegate.h b/content/browser/download/mock_download_manager_delegate.h index 1fb62cb..ff48765 100644 --- a/content/browser/download/mock_download_manager_delegate.h +++ b/content/browser/download/mock_download_manager_delegate.h @@ -9,6 +9,7 @@ #include "base/compiler_specific.h" #include "base/file_path.h" #include "content/browser/download/download_types.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_manager_delegate.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -25,6 +26,7 @@ class MockDownloadManagerDelegate : public content::DownloadManagerDelegate { // DownloadManagerDelegate functions: MOCK_METHOD1(SetDownloadManager, void(content::DownloadManager* dm)); MOCK_METHOD0(Shutdown, void()); + MOCK_METHOD0(GetNextId, content::DownloadId()); MOCK_METHOD1(ShouldStartDownload, bool(int32 download_id)); MOCK_METHOD3(ChooseDownloadPath, void(content::WebContents* web_contents, const FilePath& suggested_path, diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc index 871f003..f06e475 100644 --- a/content/browser/renderer_host/buffered_resource_handler.cc +++ b/content/browser/renderer_host/buffered_resource_handler.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/string_util.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_resource_handler.h" #include "content/browser/download/download_stats.h" #include "content/browser/download/download_types.h" @@ -303,15 +302,12 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id) { info->set_is_download(true); - DownloadId dl_id = info->context()->download_id_factory()->GetNextId(); - scoped_refptr<ResourceHandler> handler( new DownloadResourceHandler(host_, info->child_id(), info->route_id(), info->request_id(), request_->url(), - dl_id, host_->download_file_manager(), request_, false, diff --git a/content/browser/renderer_host/resource_dispatcher_host.cc b/content/browser/renderer_host/resource_dispatcher_host.cc index b0b29b5..bbbc040 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.cc +++ b/content/browser/renderer_host/resource_dispatcher_host.cc @@ -27,7 +27,6 @@ #include "content/browser/chrome_blob_storage_context.h" #include "content/browser/cross_site_request_manager.h" #include "content/browser/download/download_file_manager.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/download/download_resource_handler.h" #include "content/browser/download/save_file_manager.h" #include "content/browser/download/save_file_resource_handler.h" @@ -877,7 +876,7 @@ void ResourceDispatcherHost::OnDidLoadResourceFromMemoryCache( } // We are explicitly forcing the download of 'url'. -void ResourceDispatcherHost::BeginDownload( +net::Error ResourceDispatcherHost::BeginDownload( scoped_ptr<net::URLRequest> request, const DownloadSaveInfo& save_info, bool prompt_for_save_location, @@ -885,14 +884,9 @@ void ResourceDispatcherHost::BeginDownload( int child_id, int route_id, const content::ResourceContext& context) { - // If DownloadResourceHandler is not begun, then started_cb must be called - // here in order to satisfy its semantics. - if (is_shutdown_) { - if (!started_cb.is_null()) - started_cb.Run(DownloadId::Invalid(), net::ERR_INSUFFICIENT_RESOURCES); - // Time and RDH are resources that are running out. - return; - } + if (is_shutdown_) + return net::ERR_INSUFFICIENT_RESOURCES; + const GURL& url = request->original_url(); const net::URLRequestContext* request_context = context.request_context(); request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); @@ -905,22 +899,17 @@ void ResourceDispatcherHost::BeginDownload( CanRequestURL(child_id, url)) { VLOG(1) << "Denied unauthorized download request for " << url.possibly_invalid_spec(); - if (!started_cb.is_null()) - started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); - return; + return net::ERR_ACCESS_DENIED; } request_id_--; - DownloadId dl_id = context.download_id_factory()->GetNextId(); - scoped_refptr<ResourceHandler> handler( new DownloadResourceHandler(this, child_id, route_id, request_id_, url, - dl_id, download_file_manager_.get(), request.get(), prompt_for_save_location, @@ -936,9 +925,7 @@ void ResourceDispatcherHost::BeginDownload( if (!request_context->job_factory()->IsHandledURL(url)) { VLOG(1) << "Download request for unsupported protocol: " << url.possibly_invalid_spec(); - if (!started_cb.is_null()) - started_cb.Run(DownloadId::Invalid(), net::ERR_ACCESS_DENIED); - return; + return net::ERR_ACCESS_DENIED; } ResourceDispatcherHostRequestInfo* extra_info = @@ -946,6 +933,8 @@ void ResourceDispatcherHost::BeginDownload( SetRequestInfo(request.get(), extra_info); // Request takes ownership. BeginRequestInternal(request.release()); + + return net::OK; } // This function is only used for saving feature. diff --git a/content/browser/renderer_host/resource_dispatcher_host.h b/content/browser/renderer_host/resource_dispatcher_host.h index c2275ad..35aea36 100644 --- a/content/browser/renderer_host/resource_dispatcher_host.h +++ b/content/browser/renderer_host/resource_dispatcher_host.h @@ -81,10 +81,10 @@ class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { bool* message_was_ok); // Initiates a download by explicit request of the renderer, e.g. due to - // alt-clicking a link. If |request| is malformed or not permitted or the RDH - // is shutting down, then |started_cb| will be called immediately. There is no - // situation in which |started_cb| will never be called. - void BeginDownload( + // alt-clicking a link. If the download is started, |started_cb| will be + // called on the UI thread with the DownloadId; otherwise an error code will + // be returned. + net::Error BeginDownload( scoped_ptr<net::URLRequest> request, const DownloadSaveInfo& save_info, bool prompt_for_save_location, diff --git a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc index 8867bad..6657605 100644 --- a/content/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/content/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -12,8 +12,6 @@ #include "base/process_util.h" #include "content/browser/browser_thread_impl.h" #include "content/browser/child_process_security_policy.h" -#include "content/browser/download/download_id.h" -#include "content/browser/download/download_id_factory.h" #include "content/browser/mock_resource_context.h" #include "content/browser/renderer_host/dummy_resource_handler.h" #include "content/browser/renderer_host/layered_resource_handler.h" @@ -1238,12 +1236,6 @@ TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) { EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.error()); } -namespace { -DownloadId MockNextDownloadId() { - return DownloadId(reinterpret_cast<DownloadManager*>(0xFFFFFFFF), 0); -} -} - // Test for http://crbug.com/76202 . We don't want to destroy a // download request prematurely when processing a cancellation from // the renderer. @@ -1264,10 +1256,6 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) { HandleScheme("http"); MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah")); - scoped_refptr<DownloadIdFactory> id_factory( - new DownloadIdFactory("valid DownloadId::Domain")); - content::MockResourceContext::GetInstance()->set_download_id_factory( - id_factory); // Return some data so that the request is identified as a download // and the proper resource handlers are created. EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); @@ -1303,10 +1291,6 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) { HandleScheme("http"); MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah")); - scoped_refptr<DownloadIdFactory> id_factory( - new DownloadIdFactory("valid DownloadId::Domain")); - content::MockResourceContext::GetInstance()->set_download_id_factory( - id_factory); // Return some data so that the request is identified as a download // and the proper resource handlers are created. EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); diff --git a/content/browser/resource_context.cc b/content/browser/resource_context.cc index 6eb7646..9704246 100644 --- a/content/browser/resource_context.cc +++ b/content/browser/resource_context.cc @@ -21,7 +21,6 @@ ResourceContext::ResourceContext() quota_manager_(NULL), host_zoom_map_(NULL), media_observer_(NULL), - download_id_factory_(NULL), media_stream_manager_(NULL), audio_manager_(NULL) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -155,18 +154,6 @@ void ResourceContext::set_media_observer(MediaObserver* media_observer) { media_observer_ = media_observer; } -DownloadIdFactory* ResourceContext::download_id_factory() const { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - EnsureInitialized(); - return download_id_factory_; -} - -void ResourceContext::set_download_id_factory( - DownloadIdFactory* download_id_factory) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - download_id_factory_ = download_id_factory; -} - media_stream::MediaStreamManager* ResourceContext::media_stream_manager() const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/content/browser/resource_context.h b/content/browser/resource_context.h index 21f36de..22803e3 100644 --- a/content/browser/resource_context.h +++ b/content/browser/resource_context.h @@ -15,7 +15,6 @@ class AudioManager; class ChromeAppCacheService; class ChromeBlobStorageContext; -class DownloadIdFactory; class HostZoomMap; class MediaObserver; namespace fileapi { @@ -77,9 +76,6 @@ class CONTENT_EXPORT ResourceContext { MediaObserver* media_observer() const; void set_media_observer(MediaObserver* media_observer); - DownloadIdFactory* download_id_factory() const; - void set_download_id_factory(DownloadIdFactory* download_id_factory); - media_stream::MediaStreamManager* media_stream_manager() const; void set_media_stream_manager( media_stream::MediaStreamManager* media_stream_manager); @@ -102,7 +98,6 @@ class CONTENT_EXPORT ResourceContext { quota::QuotaManager* quota_manager_; HostZoomMap* host_zoom_map_; MediaObserver* media_observer_; - DownloadIdFactory* download_id_factory_; media_stream::MediaStreamManager* media_stream_manager_; AudioManager* audio_manager_; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 0828aee..123c962 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -45,6 +45,7 @@ 'public/browser/devtools_agent_host_registry.h', 'public/browser/devtools_client_host.h', 'public/browser/download_danger_type.h', + 'public/browser/download_id.h', 'public/browser/devtools_frontend_host_delegate.h', 'public/browser/devtools_http_handler.h', 'public/browser/devtools_http_handler_delegate.h', @@ -195,10 +196,6 @@ 'browser/download/download_file_impl.h', 'browser/download/download_file_manager.cc', 'browser/download/download_file_manager.h', - 'browser/download/download_id.cc', - 'browser/download/download_id.h', - 'browser/download/download_id_factory.cc', - 'browser/download/download_id_factory.h', 'browser/download/download_item_impl.cc', 'browser/download/download_item_impl.h', 'browser/download/download_manager_impl.cc', diff --git a/content/public/browser/download_file.h b/content/public/browser/download_file.h index 4a84282..b242a99 100644 --- a/content/public/browser/download_file.h +++ b/content/public/browser/download_file.h @@ -10,8 +10,8 @@ #include "base/basictypes.h" #include "base/file_path.h" -#include "content/browser/download/download_id.h" #include "content/common/content_export.h" +#include "content/public/browser/download_id.h" #include "net/base/net_errors.h" namespace content { diff --git a/content/browser/download/download_id.h b/content/public/browser/download_id.h index d9726bf..96ecc63 100644 --- a/content/browser/download/download_id.h +++ b/content/public/browser/download_id.h @@ -2,16 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_H_ -#define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_H_ +#ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ +#define CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ #pragma once #include <iosfwd> #include <string> #include "base/hash_tables.h" +#include "base/stringprintf.h" #include "content/common/content_export.h" +namespace content { + // DownloadId combines per-profile Download ids with an indication of which // profile in order to be globally unique. DownloadIds are not persistent across // sessions, but their local() field is. @@ -59,7 +62,9 @@ class DownloadId { (static_cast<size_t>(local_id_) << (4 * sizeof(size_t))); } - std::string DebugString() const; + std::string DebugString() const { + return base::StringPrintf("%p:%d", domain_, local_id_); + } private: Domain domain_; @@ -69,22 +74,28 @@ class DownloadId { // Allow copy and assign. }; +} // namespace content + // Allow logging DownloadIds. Looks like "0x01234567:42". CONTENT_EXPORT std::ostream& operator<<(std::ostream& out, - const DownloadId& global_id); + const content::DownloadId& global_id); +inline std::ostream& operator<<(std::ostream& out, + const content::DownloadId& global_id) { + return out << global_id.DebugString(); +} // Allow using DownloadIds as keys in hash_maps. namespace BASE_HASH_NAMESPACE { #if defined(COMPILER_GCC) -template<> struct hash<DownloadId> { - std::size_t operator()(const DownloadId& id) const { +template<> struct hash<content::DownloadId> { + std::size_t operator()(const content::DownloadId& id) const { return id.hash(); } }; #elif defined(COMPILER_MSVC) -inline size_t hash_value(const DownloadId& id) { +inline size_t hash_value(const content::DownloadId& id) { return id.hash(); } #endif // COMPILER } -#endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ID_H_ +#endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_ID_H_ diff --git a/content/public/browser/download_item.h b/content/public/browser/download_item.h index 453d37f..84eeac4 100644 --- a/content/public/browser/download_item.h +++ b/content/public/browser/download_item.h @@ -26,7 +26,6 @@ #include "content/browser/download/interrupt_reasons.h" #include "content/public/browser/download_danger_type.h" -class DownloadId; class DownloadFileManager; class FilePath; class GURL; @@ -41,6 +40,7 @@ class TimeDelta; namespace content { class BrowserContext; +class DownloadId; class DownloadManager; class WebContents; diff --git a/content/public/browser/download_manager.h b/content/public/browser/download_manager.h index 20c584f..32aee86 100644 --- a/content/public/browser/download_manager.h +++ b/content/public/browser/download_manager.h @@ -36,14 +36,13 @@ #include "base/gtest_prod_util.h" #include "base/message_loop_helpers.h" #include "base/time.h" -#include "content/browser/download/download_id.h" #include "content/browser/download/interrupt_reasons.h" +#include "content/public/browser/download_id.h" #include "content/public/browser/download_item.h" #include "content/public/browser/browser_thread.h" #include "net/base/net_errors.h" class DownloadFileManager; -class DownloadIdFactory; class DownloadManagerTest; class DownloadRequestHandle; class DownloadStatusUpdater; @@ -66,7 +65,6 @@ class CONTENT_EXPORT DownloadManager static DownloadManager* Create( DownloadManagerDelegate* delegate, - DownloadIdFactory* id_factory, DownloadStatusUpdater* status_updater); // Shutdown the download manager. Must be called before destruction. diff --git a/content/public/browser/download_manager_delegate.h b/content/public/browser/download_manager_delegate.h index 722aac7..4776ef0 100644 --- a/content/public/browser/download_manager_delegate.h +++ b/content/public/browser/download_manager_delegate.h @@ -14,6 +14,7 @@ namespace content { +class DownloadId; class DownloadItem; class WebContents; @@ -28,6 +29,9 @@ class DownloadManagerDelegate { // Lets the delegate know that the download manager is shutting down. virtual void Shutdown() = 0; + // Returns a new DownloadId. + virtual DownloadId GetNextId() = 0; + // Notifies the delegate that a download is starting. The delegate can return // false to delay the start of the download, in which case it should call // DownloadManager::RestartDownload when it's ready. diff --git a/content/shell/shell_browser_context.cc b/content/shell/shell_browser_context.cc index 2590ee8..f6dff1e 100644 --- a/content/shell/shell_browser_context.cc +++ b/content/shell/shell_browser_context.cc @@ -12,7 +12,6 @@ #include "base/threading/thread.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_impl.h" #include "content/browser/download/download_status_updater.h" #include "content/browser/file_system/browser_file_system_helper.h" @@ -94,8 +93,7 @@ class ShellSpeechInputPreferences : public SpeechInputPreferences { ShellBrowserContext::ShellBrowserContext( ShellBrowserMainParts* shell_main_parts) - : download_id_factory_(new DownloadIdFactory(this)), - shell_main_parts_(shell_main_parts) { + : shell_main_parts_(shell_main_parts) { } ShellBrowserContext::~ShellBrowserContext() { @@ -144,7 +142,6 @@ DownloadManager* ShellBrowserContext::GetDownloadManager() { download_manager_delegate_ = new ShellDownloadManagerDelegate(); download_manager_ = new DownloadManagerImpl(download_manager_delegate_, - download_id_factory_, download_status_updater_.get()); download_manager_delegate_->SetDownloadManager(download_manager_.get()); download_manager_->Init(this); @@ -177,8 +174,7 @@ const ResourceContext& ShellBrowserContext::GetResourceContext() { if (!resource_context_.get()) { resource_context_.reset(new ShellResourceContext( static_cast<ShellURLRequestContextGetter*>(GetRequestContext()), - GetBlobStorageContext(), - download_id_factory_)); + GetBlobStorageContext())); } return *resource_context_.get(); } diff --git a/content/shell/shell_browser_context.h b/content/shell/shell_browser_context.h index 5bf24b8..b1b8a7b 100644 --- a/content/shell/shell_browser_context.h +++ b/content/shell/shell_browser_context.h @@ -12,7 +12,6 @@ #include "base/memory/scoped_ptr.h" #include "content/public/browser/browser_context.h" -class DownloadIdFactory; class DownloadManager; class DownloadStatusUpdater; class HostZoomMap; @@ -60,7 +59,6 @@ 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_download_manager_delegate.cc b/content/shell/shell_download_manager_delegate.cc index 67ff59a..7856a66 100644 --- a/content/shell/shell_download_manager_delegate.cc +++ b/content/shell/shell_download_manager_delegate.cc @@ -39,6 +39,11 @@ void ShellDownloadManagerDelegate::SetDownloadManager( void ShellDownloadManagerDelegate::Shutdown() { } +DownloadId ShellDownloadManagerDelegate::GetNextId() { + static int next_id; + return DownloadId(this, ++next_id); +} + bool ShellDownloadManagerDelegate::ShouldStartDownload(int32 download_id) { DownloadItem* download = download_manager_->GetActiveDownloadItem(download_id); diff --git a/content/shell/shell_download_manager_delegate.h b/content/shell/shell_download_manager_delegate.h index d46ac43..9cb5e97 100644 --- a/content/shell/shell_download_manager_delegate.h +++ b/content/shell/shell_download_manager_delegate.h @@ -25,6 +25,7 @@ class ShellDownloadManagerDelegate void SetDownloadManager(DownloadManager* manager); virtual void Shutdown() OVERRIDE; + virtual DownloadId GetNextId() OVERRIDE; virtual bool ShouldStartDownload(int32 download_id) OVERRIDE; virtual void ChooseDownloadPath(WebContents* web_contents, const FilePath& suggested_path, diff --git a/content/shell/shell_resource_context.cc b/content/shell/shell_resource_context.cc index 21a696f..fa725cf 100644 --- a/content/shell/shell_resource_context.cc +++ b/content/shell/shell_resource_context.cc @@ -5,18 +5,15 @@ #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 { ShellResourceContext::ShellResourceContext( ShellURLRequestContextGetter* getter, - ChromeBlobStorageContext* blob_storage_context, - DownloadIdFactory* download_id_factory) + ChromeBlobStorageContext* blob_storage_context) : getter_(getter), - blob_storage_context_(blob_storage_context), - download_id_factory_(download_id_factory) { + blob_storage_context_(blob_storage_context) { } ShellResourceContext::~ShellResourceContext() { @@ -30,7 +27,6 @@ void ShellResourceContext::InitializeInternal() { set_request_context(getter_->GetURLRequestContext()); set_host_resolver(getter_->host_resolver()); set_blob_storage_context(blob_storage_context_); - 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 710778e..f01a120 100644 --- a/content/shell/shell_resource_context.h +++ b/content/shell/shell_resource_context.h @@ -11,7 +11,6 @@ #include "content/browser/resource_context.h" class ChromeBlobStorageContext; -class DownloadIdFactory; namespace content { @@ -21,8 +20,7 @@ class ShellResourceContext : public content::ResourceContext { public: ShellResourceContext( ShellURLRequestContextGetter* getter, - ChromeBlobStorageContext* blob_storage_context, - DownloadIdFactory* download_id_factory); + ChromeBlobStorageContext* blob_storage_context); virtual ~ShellResourceContext(); private: @@ -32,7 +30,6 @@ class ShellResourceContext : public content::ResourceContext { scoped_refptr<ShellURLRequestContextGetter> getter_; scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; - scoped_refptr<DownloadIdFactory> download_id_factory_; DISALLOW_COPY_AND_ASSIGN(ShellResourceContext); }; |