From ccf94031f44f15d12696051fe5db004cd47f51e5 Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Tue, 12 Feb 2019 16:54:20 +0100 Subject: Fix incrementing download ID Adapt DownloadManagerDelegateQt::m_currentId to https://chromium-review.googlesource.com/1144311 Update Chromium: 09516a434b [Backport] Allow DownloadManagerImpl to get InProgressDownloadManager from DownloadManagerService b3edbf2a84 [Backport] Make DownloadManagerImpl to generate download IDs for in-progress DB Task-number: QTBUG-70702 Change-Id: I1224643398a2084fcd5d70d2c04b105ed69c1f3d Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 8600d3d22d86be364a4c29e559dda7990594d0c5) Reviewed-by: Michal Klocek --- src/3rdparty | 2 +- src/core/download_manager_delegate_qt.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/3rdparty b/src/3rdparty index 493fab1af..b3edbf2a8 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 493fab1afff5034cb5552455add3af3aaf41f9e9 +Subproject commit b3edbf2a84d96ed1d0307a8ef909b2f1f6c2a971 diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 948a62047..f0f0c93b9 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -79,7 +79,7 @@ DownloadManagerDelegateQt::~DownloadManagerDelegateQt() void DownloadManagerDelegateQt::GetNextId(const content::DownloadIdCallback& callback) { - callback.Run(++m_currentId); + callback.Run(m_currentId); } download::DownloadItem *DownloadManagerDelegateQt::findDownloadById(quint32 downloadId) @@ -124,6 +124,8 @@ void DownloadManagerDelegateQt::removeDownload(quint32 downloadId) bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem* item, const content::DownloadTargetCallback& callback) { + m_currentId = item->GetId(); + // Keep the forced file path if set, also as the temporary file, so the check for existence // will already return that the file exists. Forced file paths seem to be only used for // store downloads and other special downloads, so they might never end up here anyway. @@ -184,6 +186,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem* if (webContents) adapterClient = static_cast(webContents->GetDelegate())->adapterClient(); + Q_ASSERT(m_currentId == item->GetId()); ProfileAdapterClient::DownloadItemInfo info = { item->GetId(), toQt(item->GetURL()), @@ -284,8 +287,9 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content if (web_contents) adapterClient = static_cast(web_contents->GetDelegate())->adapterClient(); + // Chromium doesn't increase download ID when saving page. ProfileAdapterClient::DownloadItemInfo info = { - m_currentId + 1, + ++m_currentId, toQt(web_contents->GetURL()), download::DownloadItem::IN_PROGRESS, 0, /* totalBytes */ -- cgit v1.2.3