| Index: chrome/browser/download/download_history.cc
|
| diff --git a/chrome/browser/download/download_history.cc b/chrome/browser/download/download_history.cc
|
| index 9e960824d6ea007b7b4a6d3db06d8268c5263d66..0d6da87e7b51e65d955fca19f58e0a573ab74f7a 100644
|
| --- a/chrome/browser/download/download_history.cc
|
| +++ b/chrome/browser/download/download_history.cc
|
| @@ -71,7 +71,8 @@ class DownloadHistoryData : public base::SupportsUserData::Data {
|
|
|
| explicit DownloadHistoryData(content::DownloadItem* item)
|
| : state_(NOT_PERSISTED),
|
| - was_restored_from_history_(false) {
|
| + was_restored_from_history_(false),
|
| + was_revived_(false) {
|
| item->SetUserData(kKey, this);
|
| }
|
|
|
| @@ -85,6 +86,9 @@ class DownloadHistoryData : public base::SupportsUserData::Data {
|
| was_restored_from_history_ = value;
|
| }
|
|
|
| + bool was_revived() const { return was_revived_; }
|
| + void set_was_revived(bool revived) { was_revived_ = revived; }
|
| +
|
| // This allows DownloadHistory::OnDownloadUpdated() to see what changed in a
|
| // DownloadItem if anything, in order to prevent writing to the database
|
| // unnecessarily. It is nullified when the item is no longer in progress in
|
| @@ -103,6 +107,7 @@ class DownloadHistoryData : public base::SupportsUserData::Data {
|
| PersistenceState state_;
|
| scoped_ptr<history::DownloadRow> info_;
|
| bool was_restored_from_history_;
|
| + bool was_revived_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(DownloadHistoryData);
|
| };
|
| @@ -372,8 +377,12 @@ void DownloadHistory::OnDownloadCreated(
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|
| // All downloads should pass through OnDownloadCreated exactly once.
|
| - CHECK(!DownloadHistoryData::Get(item));
|
| - DownloadHistoryData* data = new DownloadHistoryData(item);
|
| + DownloadHistoryData* data = DownloadHistoryData::Get(item);
|
| + CHECK(!data || data->was_revived());
|
| +
|
| + if (!data)
|
| + data = new DownloadHistoryData(item);
|
| +
|
| if (item->GetId() == loading_id_) {
|
| data->SetState(DownloadHistoryData::PERSISTED);
|
| data->set_was_restored_from_history(true);
|
| @@ -385,6 +394,15 @@ void DownloadHistory::OnDownloadCreated(
|
| MaybeAddToHistory(item);
|
| }
|
|
|
| +void DownloadHistory::OnDownloadRevived(
|
| + content::DownloadManager* manager, content::DownloadItem* item) {
|
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
| +
|
| + DownloadHistoryData* data = DownloadHistoryData::Get(item);
|
| + if (data)
|
| + data->set_was_revived(true);
|
| +}
|
| +
|
| void DownloadHistory::OnDownloadUpdated(
|
| content::DownloadManager* manager, content::DownloadItem* item) {
|
| DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
|
|
|