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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 DownloadHistoryData* data = DownloadHistoryData::Get(item); | 345 DownloadHistoryData* data = DownloadHistoryData::Get(item); |
346 bool was_persisted = IsPersisted(item); | 346 bool was_persisted = IsPersisted(item); |
347 | 347 |
348 // The sql INSERT statement failed. Avoid an infinite loop: don't | 348 // The sql INSERT statement failed. Avoid an infinite loop: don't |
349 // automatically retry. Retry adding the next time the item is updated by | 349 // automatically retry. Retry adding the next time the item is updated by |
350 // resetting the state to NOT_PERSISTED. | 350 // resetting the state to NOT_PERSISTED. |
351 if (!success) { | 351 if (!success) { |
352 DVLOG(20) << __FUNCTION__ << " INSERT failed id=" << download_id; | 352 DVLOG(20) << __func__ << " INSERT failed id=" << download_id; |
353 data->SetState(DownloadHistoryData::NOT_PERSISTED); | 353 data->SetState(DownloadHistoryData::NOT_PERSISTED); |
354 return; | 354 return; |
355 } | 355 } |
356 data->SetState(DownloadHistoryData::PERSISTED); | 356 data->SetState(DownloadHistoryData::PERSISTED); |
357 | 357 |
358 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.HistorySize2", | 358 UMA_HISTOGRAM_CUSTOM_COUNTS("Download.HistorySize2", |
359 history_size_, | 359 history_size_, |
360 0/*min*/, | 360 0/*min*/, |
361 (1 << 23)/*max*/, | 361 (1 << 23)/*max*/, |
362 (1 << 7)/*num_buckets*/); | 362 (1 << 7)/*num_buckets*/); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 removing_ids_.insert(download_id); | 460 removing_ids_.insert(download_id); |
461 } | 461 } |
462 | 462 |
463 void DownloadHistory::RemoveDownloadsBatch() { | 463 void DownloadHistory::RemoveDownloadsBatch() { |
464 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 464 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
465 IdSet remove_ids; | 465 IdSet remove_ids; |
466 removing_ids_.swap(remove_ids); | 466 removing_ids_.swap(remove_ids); |
467 history_->RemoveDownloads(remove_ids); | 467 history_->RemoveDownloads(remove_ids); |
468 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); | 468 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); |
469 } | 469 } |
OLD | NEW |