diff options
author | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-09 05:08:09 +0000 |
---|---|---|
committer | ahendrickson@chromium.org <ahendrickson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-09 05:08:09 +0000 |
commit | ef17c9ae62cabcb07c9e4319938328847fe58dce (patch) | |
tree | c9316a534a976a6aba1da119a951b8ca18194f3e /content/browser/download/download_file_manager.cc | |
parent | 9f626f9bffe7ed3e0cc9aa4e7bc1cafc2dad75f9 (diff) | |
download | chromium_src-ef17c9ae62cabcb07c9e4319938328847fe58dce.zip chromium_src-ef17c9ae62cabcb07c9e4319938328847fe58dce.tar.gz chromium_src-ef17c9ae62cabcb07c9e4319938328847fe58dce.tar.bz2 |
Hooked up NetLog to DownloadItem, DownloadFile, and FileStream.
The ChromeNetLog object is owned by the browser process, which has a longer lifetime than the profile and therefore than the download system. For each download, there will be one BoundNetLog (or a copy thereof) used by DownloadItem and DownloadFile, and one separate one used by FileStream.
For most downloads, the path to get a NetLog pointer to the download objects (DownloadItem, DownloadFile and FileStream) is through the URL request. A BoundNetLog is created and passed in to the DownloadResourceHandler constructor, which adds it to a DownloadCreateInfo that it makes. This gets it to DownloadItem, DownloadFile/BaseFile, and FileStream.
For downloads created from the history database, the path is via the DownloadService and the DownloadManager constructor. Likewise for downloads created as part of a 'Save Page As' operation, although that may change in the future with further refactoring of the 'Save Page As' code.
For downloads initiated by drag & drop on Linux and Mac (but not on Windows), the FileStream needs to get a NetLog pointer from another source. In this case, it is via the ContentClient (effectively a global) and ContentBrowserClient classes.
Note that FileStream has a different NetLog source than the other classes.
This is the final of 4 CLs that will enable net logging for downloads.
BUG=None
TEST=Go to a web page with downloadable content.
Open a new tab with about:net-internals.
Download a file.
Check the EVENTS tab of about:net-internals: there should be DOWNLOAD and FILESTREAM events.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=121050
Review URL: http://codereview.chromium.org/9296012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_file_manager.cc')
-rw-r--r-- | content/browser/download/download_file_manager.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/content/browser/download/download_file_manager.cc b/content/browser/download/download_file_manager.cc index 1b360af..a0a6c46 100644 --- a/content/browser/download/download_file_manager.cc +++ b/content/browser/download/download_file_manager.cc @@ -46,17 +46,20 @@ class DownloadFileFactoryImpl DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, DownloadManager* download_manager, - bool calculate_hash) OVERRIDE; + bool calculate_hash, + const net::BoundNetLog& bound_net_log) OVERRIDE; }; DownloadFile* DownloadFileFactoryImpl::CreateFile( DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, DownloadManager* download_manager, - bool calculate_hash) { + bool calculate_hash, + const net::BoundNetLog& bound_net_log) { return new DownloadFileImpl(info, new DownloadRequestHandle(request_handle), - download_manager, calculate_hash); + download_manager, calculate_hash, + bound_net_log); } } // namespace @@ -87,7 +90,8 @@ void DownloadFileManager::OnShutdown() { void DownloadFileManager::CreateDownloadFile( DownloadCreateInfo* info, const DownloadRequestHandle& request_handle, - DownloadManager* download_manager, bool get_hash) { + DownloadManager* download_manager, bool get_hash, + const net::BoundNetLog& bound_net_log) { DCHECK(info); VLOG(20) << __FUNCTION__ << "()" << " info = " << info->DebugString(); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); @@ -96,7 +100,7 @@ void DownloadFileManager::CreateDownloadFile( scoped_ptr<DownloadCreateInfo> infop(info); scoped_ptr<DownloadFile> download_file(download_file_factory_->CreateFile( - info, request_handle, download_manager, get_hash)); + info, request_handle, download_manager, get_hash, bound_net_log)); if (net::OK != download_file->Initialize()) { request_handle.CancelRequest(); return; @@ -167,13 +171,16 @@ void DownloadFileManager::StartDownload( return; } - manager->CreateDownloadItem(info, request_handle); + // |bound_net_log| will be used for logging the both the download item's and + // the download file's events. + net::BoundNetLog bound_net_log = + manager->CreateDownloadItem(info, request_handle); bool hash_needed = manager->GenerateFileHash(); BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind(&DownloadFileManager::CreateDownloadFile, this, info, request_handle, make_scoped_refptr(manager), - hash_needed)); + hash_needed, bound_net_log)); } // We don't forward an update to the UI thread here, since we want to throttle |