Commit 938f37f7 authored by asanka@chromium.org's avatar asanka@chromium.org

drive::DownloadHandler should query DownloadHistory.

The drive::DownloadHandler was using the assumption that all
non-IN_PROGRESS downloads that are created were restored from history.
This is not a safe assumption.

Instead query the DownloadHistory to determine whether a new download
was restored from history or not.

Depends on https://codereview.chromium.org/230103002/ which adds a
WasDownloadRestoredFromHistory method to DownloadHistory.

BUG=7648

Review URL: https://codereview.chromium.org/230133002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271595 0039d316-1c4b-4281-b951-d872f2087c98
parent b72e681f
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include "chrome/browser/chromeos/drive/file_system_interface.h" #include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/drive/write_on_cache_file.h" #include "chrome/browser/chromeos/drive/write_on_cache_file.h"
#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
using content::BrowserThread; using content::BrowserThread;
...@@ -94,10 +97,15 @@ void ContinueCheckingForFileExistence( ...@@ -94,10 +97,15 @@ void ContinueCheckingForFileExistence(
// on the download history DB. // on the download history DB.
bool IsPersistedDriveDownload(const base::FilePath& drive_tmp_download_path, bool IsPersistedDriveDownload(const base::FilePath& drive_tmp_download_path,
DownloadItem* download) { DownloadItem* download) {
// Persisted downloads are not in IN_PROGRESS state when created, while newly if (!drive_tmp_download_path.IsParent(download->GetTargetFilePath()))
// created downloads are. return false;
return drive_tmp_download_path.IsParent(download->GetTargetFilePath()) &&
download->GetState() != DownloadItem::IN_PROGRESS; DownloadService* download_service =
DownloadServiceFactory::GetForBrowserContext(
download->GetBrowserContext());
DownloadHistory* download_history = download_service->GetDownloadHistory();
return download_history && download_history->WasRestoredFromHistory(download);
} }
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment