| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // have no control over when DownloadItems are destroyed. | 48 // have no control over when DownloadItems are destroyed. |
| 49 class DownloadHistoryData : public base::SupportsUserData::Data { | 49 class DownloadHistoryData : public base::SupportsUserData::Data { |
| 50 public: | 50 public: |
| 51 static DownloadHistoryData* Get(content::DownloadItem* item) { | 51 static DownloadHistoryData* Get(content::DownloadItem* item) { |
| 52 base::SupportsUserData::Data* data = item->GetUserData(kKey); | 52 base::SupportsUserData::Data* data = item->GetUserData(kKey); |
| 53 return (data == NULL) ? NULL : | 53 return (data == NULL) ? NULL : |
| 54 static_cast<DownloadHistoryData*>(data); | 54 static_cast<DownloadHistoryData*>(data); |
| 55 } | 55 } |
| 56 | 56 |
| 57 DownloadHistoryData(content::DownloadItem* item, int64 handle) | 57 DownloadHistoryData(content::DownloadItem* item, int64 handle) |
| 58 : is_adding_(false), | 58 : is_adding_(false), db_handle_(handle) { |
| 59 db_handle_(handle), | |
| 60 info_(NULL) { | |
| 61 item->SetUserData(kKey, this); | 59 item->SetUserData(kKey, this); |
| 62 } | 60 } |
| 63 | 61 |
| 64 virtual ~DownloadHistoryData() { | 62 virtual ~DownloadHistoryData() { |
| 65 } | 63 } |
| 66 | 64 |
| 67 // Whether this item is currently being added to the database. | 65 // Whether this item is currently being added to the database. |
| 68 bool is_adding() const { return is_adding_; } | 66 bool is_adding() const { return is_adding_; } |
| 69 void set_is_adding(bool a) { is_adding_ = a; } | 67 void set_is_adding(bool a) { is_adding_ = a; } |
| 70 | 68 |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 420 |
| 423 void DownloadHistory::RemoveDownloadsBatch() { | 421 void DownloadHistory::RemoveDownloadsBatch() { |
| 424 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 422 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 425 HandleSet remove_handles; | 423 HandleSet remove_handles; |
| 426 IdSet remove_ids; | 424 IdSet remove_ids; |
| 427 removing_handles_.swap(remove_handles); | 425 removing_handles_.swap(remove_handles); |
| 428 removing_ids_.swap(remove_ids); | 426 removing_ids_.swap(remove_ids); |
| 429 history_->RemoveDownloads(remove_handles); | 427 history_->RemoveDownloads(remove_handles); |
| 430 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); | 428 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); |
| 431 } | 429 } |
| OLD | NEW |