| 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 16 matching lines...) Expand all  Loading... | 
| 27 // DownloadItems are destroyed. | 27 // DownloadItems are destroyed. | 
| 28 | 28 | 
| 29 #include "chrome/browser/download/download_history.h" | 29 #include "chrome/browser/download/download_history.h" | 
| 30 | 30 | 
| 31 #include <utility> | 31 #include <utility> | 
| 32 | 32 | 
| 33 #include "base/macros.h" | 33 #include "base/macros.h" | 
| 34 #include "base/metrics/histogram_macros.h" | 34 #include "base/metrics/histogram_macros.h" | 
| 35 #include "chrome/browser/download/download_crx_util.h" | 35 #include "chrome/browser/download/download_crx_util.h" | 
| 36 #include "components/history/content/browser/download_constants_utils.h" | 36 #include "components/history/content/browser/download_constants_utils.h" | 
|  | 37 #include "components/history/content/browser/download_database_helper.h" | 
| 37 #include "components/history/core/browser/download_database.h" | 38 #include "components/history/core/browser/download_database.h" | 
| 38 #include "components/history/core/browser/download_row.h" | 39 #include "components/history/core/browser/download_row.h" | 
| 39 #include "components/history/core/browser/history_service.h" | 40 #include "components/history/core/browser/history_service.h" | 
| 40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" | 
| 41 #include "content/public/browser/download_item.h" | 42 #include "content/public/browser/download_item.h" | 
| 42 #include "content/public/browser/download_manager.h" | 43 #include "content/public/browser/download_manager.h" | 
| 43 #include "extensions/features/features.h" | 44 #include "extensions/features/features.h" | 
| 44 | 45 | 
| 45 #if BUILDFLAG(ENABLE_EXTENSIONS) | 46 #if BUILDFLAG(ENABLE_EXTENSIONS) | 
| 46 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 47 #include "chrome/browser/extensions/api/downloads/downloads_api.h" | 
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 290         it->guid, loading_id_, it->current_path, it->target_path, it->url_chain, | 291         it->guid, loading_id_, it->current_path, it->target_path, it->url_chain, | 
| 291         it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url, | 292         it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url, | 
| 292         it->mime_type, it->original_mime_type, it->start_time, it->end_time, | 293         it->mime_type, it->original_mime_type, it->start_time, it->end_time, | 
| 293         it->etag, it->last_modified, it->received_bytes, it->total_bytes, | 294         it->etag, it->last_modified, it->received_bytes, it->total_bytes, | 
| 294         std::string(),  // TODO(asanka): Need to persist and restore hash of | 295         std::string(),  // TODO(asanka): Need to persist and restore hash of | 
| 295                         // partial file for an interrupted download. No need to | 296                         // partial file for an interrupted download. No need to | 
| 296                         // store hash for a completed file. | 297                         // store hash for a completed file. | 
| 297         history::ToContentDownloadState(it->state), | 298         history::ToContentDownloadState(it->state), | 
| 298         history::ToContentDownloadDangerType(it->danger_type), | 299         history::ToContentDownloadDangerType(it->danger_type), | 
| 299         history::ToContentDownloadInterruptReason(it->interrupt_reason), | 300         history::ToContentDownloadInterruptReason(it->interrupt_reason), | 
| 300         it->opened); | 301         it->opened, history::ToContentReceivedSlices(it->download_slice_info)); | 
| 301 #if BUILDFLAG(ENABLE_EXTENSIONS) | 302 #if BUILDFLAG(ENABLE_EXTENSIONS) | 
| 302     if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { | 303     if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { | 
| 303       new extensions::DownloadedByExtension( | 304       new extensions::DownloadedByExtension( | 
| 304           item, it->by_ext_id, it->by_ext_name); | 305           item, it->by_ext_id, it->by_ext_name); | 
| 305       item->UpdateObservers(); | 306       item->UpdateObservers(); | 
| 306     } | 307     } | 
| 307 #endif | 308 #endif | 
| 308     DCHECK_EQ(DownloadHistoryData::PERSISTED, | 309     DCHECK_EQ(DownloadHistoryData::PERSISTED, | 
| 309               DownloadHistoryData::Get(item)->state()); | 310               DownloadHistoryData::Get(item)->state()); | 
| 310     ++history_size_; | 311     ++history_size_; | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 491 } | 492 } | 
| 492 | 493 | 
| 493 void DownloadHistory::RemoveDownloadsBatch() { | 494 void DownloadHistory::RemoveDownloadsBatch() { | 
| 494   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 495   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 
| 495   IdSet remove_ids; | 496   IdSet remove_ids; | 
| 496   removing_ids_.swap(remove_ids); | 497   removing_ids_.swap(remove_ids); | 
| 497   history_->RemoveDownloads(remove_ids); | 498   history_->RemoveDownloads(remove_ids); | 
| 498   for (Observer& observer : observers_) | 499   for (Observer& observer : observers_) | 
| 499     observer.OnDownloadsRemoved(remove_ids); | 500     observer.OnDownloadsRemoved(remove_ids); | 
| 500 } | 501 } | 
| OLD | NEW | 
|---|