Commit e1166217 authored by Min Qin's avatar Min Qin Committed by Commit Bot

Don't update history db for incompleted download if DownloadDB is enabled

if DownloadDB is enabled, there is no need to update incomplete download
in history db.
The DownloadDB should contain all information.

BUG=863602

Change-Id: Idf20bbb91e8e5156aa21354695b0781493c723ef
Reviewed-on: https://chromium-review.googlesource.com/1137235
Commit-Queue: Min Qin <qinmin@chromium.org>
Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575873}
parent 41ba8bb0
...@@ -30,10 +30,12 @@ ...@@ -30,10 +30,12 @@
#include <utility> #include <utility>
#include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chrome/browser/download/download_crx_util.h" #include "chrome/browser/download/download_crx_util.h"
#include "components/download/database/switches.h"
#include "components/download/public/common/download_item.h" #include "components/download/public/common/download_item.h"
#include "components/history/content/browser/download_conversions.h" #include "components/history/content/browser/download_conversions.h"
#include "components/history/core/browser/download_database.h" #include "components/history/core/browser/download_database.h"
...@@ -167,6 +169,14 @@ enum class ShouldUpdateHistoryResult { ...@@ -167,6 +169,14 @@ enum class ShouldUpdateHistoryResult {
ShouldUpdateHistoryResult ShouldUpdateHistory( ShouldUpdateHistoryResult ShouldUpdateHistory(
const history::DownloadRow* previous, const history::DownloadRow* previous,
const history::DownloadRow& current) { const history::DownloadRow& current) {
// No need to update the history for incomplete download if DownloadDB is
// enabled.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
download::switches::kEnableDownloadDB) &&
current.state != history::DownloadState::COMPLETE) {
return ShouldUpdateHistoryResult::NO_UPDATE;
}
// When download path is determined, Chrome should commit the history // When download path is determined, Chrome should commit the history
// immediately. Otherwise the file will be left permanently on the external // immediately. Otherwise the file will be left permanently on the external
// storage if Chrome crashes right away. // storage if Chrome crashes right away.
......
...@@ -102,8 +102,6 @@ class DownloadHistory : public download::AllDownloadItemNotifier::Observer { ...@@ -102,8 +102,6 @@ class DownloadHistory : public download::AllDownloadItemNotifier::Observer {
bool WasRestoredFromHistory(const download::DownloadItem* item) const; bool WasRestoredFromHistory(const download::DownloadItem* item) const;
private: private:
typedef std::set<download::DownloadItem*> ItemSet;
// Callback from |history_| containing all entries in the downloads database // Callback from |history_| containing all entries in the downloads database
// table. // table.
void QueryCallback(std::unique_ptr<std::vector<history::DownloadRow>> infos); void QueryCallback(std::unique_ptr<std::vector<history::DownloadRow>> infos);
......
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