Fix race in GData downloads for small files where the download may complete before the upload has started causing the uploaded file to not be stored to cache.

1. Prevent a download from completing if the associated GData upload hasn't started yet.

   This ensures proper sequencing of StoreToCache() after the downloads system has released the downloaded file.

2. Begin uploading once all the downloaded data has been saved.

   For smaller downloads, this ensures that the upload starts as soon as all the data is available.

3. Use the correct path when storing downloaded file to cache.

   The download file is renamed to its final name when the download completes. StoreToCache() should only be called with the final name. Otherwise the store operation fails.

4. Ensure an OnDownloadUpdated() notification is sent when all the data has been saved.

   For small downloads, this guarantees that at least one OnDownloadUpdated() notification fulfills all requirements for starting a GData upload as verified by GDataDownloadObserver::ShouldUpload().

BUG=chromium-os:28414
TEST=Manual. Downloading a small file to Docs/ completes successfully and causes the file to appear in the file manager.


Review URL: http://codereview.chromium.org/9861023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129376 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed