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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 DISALLOW_COPY_AND_ASSIGN(DownloadHistoryData); | 95 DISALLOW_COPY_AND_ASSIGN(DownloadHistoryData); |
96 }; | 96 }; |
97 | 97 |
98 const char DownloadHistoryData::kKey[] = | 98 const char DownloadHistoryData::kKey[] = |
99 "DownloadItem DownloadHistoryData"; | 99 "DownloadItem DownloadHistoryData"; |
100 | 100 |
101 history::DownloadRow GetDownloadRow( | 101 history::DownloadRow GetDownloadRow( |
102 content::DownloadItem* item) { | 102 content::DownloadItem* item) { |
103 std::string by_ext_id, by_ext_name; | 103 std::string by_ext_id, by_ext_name; |
104 #if !defined(OS_ANDROID) | 104 #if !defined(OS_ANDROID) |
105 DownloadedByExtension* by_ext = DownloadedByExtension::Get(item); | 105 extensions::DownloadedByExtension* by_ext = |
| 106 extensions::DownloadedByExtension::Get(item); |
106 if (by_ext) { | 107 if (by_ext) { |
107 by_ext_id = by_ext->id(); | 108 by_ext_id = by_ext->id(); |
108 by_ext_name = by_ext->name(); | 109 by_ext_name = by_ext->name(); |
109 } | 110 } |
110 #endif | 111 #endif |
111 | 112 |
112 return history::DownloadRow( | 113 return history::DownloadRow( |
113 item->GetFullPath(), | 114 item->GetFullPath(), |
114 item->GetTargetFilePath(), | 115 item->GetTargetFilePath(), |
115 item->GetUrlChain(), | 116 item->GetUrlChain(), |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 it->etag, | 241 it->etag, |
241 it->last_modified, | 242 it->last_modified, |
242 it->received_bytes, | 243 it->received_bytes, |
243 it->total_bytes, | 244 it->total_bytes, |
244 it->state, | 245 it->state, |
245 it->danger_type, | 246 it->danger_type, |
246 it->interrupt_reason, | 247 it->interrupt_reason, |
247 it->opened); | 248 it->opened); |
248 #if !defined(OS_ANDROID) | 249 #if !defined(OS_ANDROID) |
249 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { | 250 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { |
250 new DownloadedByExtension(item, it->by_ext_id, it->by_ext_name); | 251 new extensions::DownloadedByExtension( |
| 252 item, it->by_ext_id, it->by_ext_name); |
251 item->UpdateObservers(); | 253 item->UpdateObservers(); |
252 } | 254 } |
253 #endif | 255 #endif |
254 DCHECK_EQ(DownloadHistoryData::Get(item)->state(), | 256 DCHECK_EQ(DownloadHistoryData::Get(item)->state(), |
255 DownloadHistoryData::PERSISTED); | 257 DownloadHistoryData::PERSISTED); |
256 ++history_size_; | 258 ++history_size_; |
257 } | 259 } |
258 notifier_.GetManager()->CheckForHistoryFilesRemoval(); | 260 notifier_.GetManager()->CheckForHistoryFilesRemoval(); |
259 } | 261 } |
260 | 262 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 removing_ids_.insert(download_id); | 424 removing_ids_.insert(download_id); |
423 } | 425 } |
424 | 426 |
425 void DownloadHistory::RemoveDownloadsBatch() { | 427 void DownloadHistory::RemoveDownloadsBatch() { |
426 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 428 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
427 IdSet remove_ids; | 429 IdSet remove_ids; |
428 removing_ids_.swap(remove_ids); | 430 removing_ids_.swap(remove_ids); |
429 history_->RemoveDownloads(remove_ids); | 431 history_->RemoveDownloads(remove_ids); |
430 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); | 432 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); |
431 } | 433 } |
OLD | NEW |