Populate download slice info between DownloadItem and history DB
This CL populates the slice information between DownloadItem and history DB.
When creating a download from history DB, the slice info should be loaded.
And whenever a slice is updated, the info should persist to the DB.
This is a followup CL to https://codereview.chromium.org/2665243003/.
Added a DownloadDatabaseHelper to convert between DownloadItem::ReceivedSlice and history::DownloadSliceInfo.
Test for DownloadDatabaseHelper::ToContentReceivedSlices() is covered in download_database_helper_unittest.cc.
Test for DownloadDatabaseHelper::GetHistoryDownloadSliceInfo() is covered in download_history_unittest.cc
(mainly because of DEPS issue, the history unittest doesn't depends on content/public/test)
BUG=
644352
Review-Url: https://codereview.chromium.org/2713493002
Cr-Commit-Position: refs/heads/master@{#453015}
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index ccb9aaa..983e26ae 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -141,13 +141,14 @@
DownloadDangerType danger_type,
DownloadInterruptReason interrupt_reason,
bool opened,
+ const std::vector<DownloadItem::ReceivedSlice>& received_slices,
const net::NetLogWithSource& net_log) override {
return new DownloadItemImpl(
delegate, guid, download_id, current_path, target_path, url_chain,
referrer_url, site_url, tab_url, tab_refererr_url, mime_type,
original_mime_type, start_time, end_time, etag, last_modified,
received_bytes, total_bytes, hash, state, danger_type, interrupt_reason,
- opened, net_log);
+ opened, received_slices, net_log);
}
DownloadItemImpl* CreateActiveItem(
@@ -658,7 +659,8 @@
DownloadItem::DownloadState state,
DownloadDangerType danger_type,
DownloadInterruptReason interrupt_reason,
- bool opened) {
+ bool opened,
+ const std::vector<DownloadItem::ReceivedSlice>& received_slices) {
if (base::ContainsKey(downloads_, id)) {
NOTREACHED();
return nullptr;
@@ -668,7 +670,7 @@
this, guid, id, current_path, target_path, url_chain, referrer_url,
site_url, tab_url, tab_refererr_url, mime_type, original_mime_type,
start_time, end_time, etag, last_modified, received_bytes, total_bytes,
- hash, state, danger_type, interrupt_reason, opened,
+ hash, state, danger_type, interrupt_reason, opened, received_slices,
net::NetLogWithSource::Make(net_log_, net::NetLogSourceType::DOWNLOAD));
downloads_[id] = base::WrapUnique(item);
downloads_by_guid_[guid] = item;