| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // DownloadHistory manages persisting DownloadItems to the history service by | 5 // DownloadHistory manages persisting DownloadItems to the history service by |
| 6 // observing a single DownloadManager and all its DownloadItems using an | 6 // observing a single DownloadManager and all its DownloadItems using an |
| 7 // AllDownloadItemNotifier. | 7 // AllDownloadItemNotifier. |
| 8 // | 8 // |
| 9 // DownloadHistory decides whether and when to add items to, remove items from, | 9 // DownloadHistory decides whether and when to add items to, remove items from, |
| 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to | 10 // and update items in the database. DownloadHistory uses DownloadHistoryData to |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return (data == NULL) ? NULL | 68 return (data == NULL) ? NULL |
| 69 : static_cast<const DownloadHistoryData*>(data); | 69 : static_cast<const DownloadHistoryData*>(data); |
| 70 } | 70 } |
| 71 | 71 |
| 72 explicit DownloadHistoryData(content::DownloadItem* item) | 72 explicit DownloadHistoryData(content::DownloadItem* item) |
| 73 : state_(NOT_PERSISTED), | 73 : state_(NOT_PERSISTED), |
| 74 was_restored_from_history_(false) { | 74 was_restored_from_history_(false) { |
| 75 item->SetUserData(kKey, this); | 75 item->SetUserData(kKey, this); |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual ~DownloadHistoryData() { | 78 ~DownloadHistoryData() override {} |
| 79 } | |
| 80 | 79 |
| 81 PersistenceState state() const { return state_; } | 80 PersistenceState state() const { return state_; } |
| 82 void SetState(PersistenceState s) { state_ = s; } | 81 void SetState(PersistenceState s) { state_ = s; } |
| 83 | 82 |
| 84 bool was_restored_from_history() const { return was_restored_from_history_; } | 83 bool was_restored_from_history() const { return was_restored_from_history_; } |
| 85 void set_was_restored_from_history(bool value) { | 84 void set_was_restored_from_history(bool value) { |
| 86 was_restored_from_history_ = value; | 85 was_restored_from_history_ = value; |
| 87 } | 86 } |
| 88 | 87 |
| 89 // This allows DownloadHistory::OnDownloadUpdated() to see what changed in a | 88 // This allows DownloadHistory::OnDownloadUpdated() to see what changed in a |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 removing_ids_.insert(download_id); | 455 removing_ids_.insert(download_id); |
| 457 } | 456 } |
| 458 | 457 |
| 459 void DownloadHistory::RemoveDownloadsBatch() { | 458 void DownloadHistory::RemoveDownloadsBatch() { |
| 460 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 459 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 461 IdSet remove_ids; | 460 IdSet remove_ids; |
| 462 removing_ids_.swap(remove_ids); | 461 removing_ids_.swap(remove_ids); |
| 463 history_->RemoveDownloads(remove_ids); | 462 history_->RemoveDownloads(remove_ids); |
| 464 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); | 463 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); |
| 465 } | 464 } |
| OLD | NEW |