diff options
author | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 18:43:08 +0000 |
---|---|---|
committer | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 18:43:08 +0000 |
commit | 6b323787634825c525d1a17f402ad8252d42c924 (patch) | |
tree | 7a9e99ffda8983e8fda145fac9dc311e93402d27 /chrome/browser | |
parent | 5b0ae24406c5cf0e587b05592256629e5aae31f2 (diff) | |
download | chromium_src-6b323787634825c525d1a17f402ad8252d42c924.zip chromium_src-6b323787634825c525d1a17f402ad8252d42c924.tar.gz chromium_src-6b323787634825c525d1a17f402ad8252d42c924.tar.bz2 |
Fix a race condition opening a downloaded file.
There is a potential race condition where we attempt
to open, via the shell, a fast completing download
before it has been renamed. This fix posts the rename
operation before calling DownloadFinished, which posts
the shell open.
BUG=3954 (http://crbug.com/3954)
Review URL: http://codereview.chromium.org/42685
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 42feb0e..436d4bb 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -684,6 +684,14 @@ void DownloadManager::ContinueStartDownload(DownloadCreateInfo* info, return; } + // Called before DownloadFinished in order to avoid a race condition where we + // attempt to open a completed download before it has been renamed. + file_loop_->PostTask(FROM_HERE, + NewRunnableMethod(file_manager_, + &DownloadFileManager::OnFinalDownloadName, + download->id(), + target_path)); + // If the download already completed by the time we reached this point, then // notify observers that it did. PendingFinishedMap::iterator pending_it = @@ -693,12 +701,6 @@ void DownloadManager::ContinueStartDownload(DownloadCreateInfo* info, download->Rename(target_path); - file_loop_->PostTask(FROM_HERE, - NewRunnableMethod(file_manager_, - &DownloadFileManager::OnFinalDownloadName, - download->id(), - target_path)); - if (profile_->IsOffTheRecord()) { // Fake a db handle for incognito mode, since nothing is actually stored in // the database in this mode. We have to make sure that these handles don't |