Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/browser/download/download_history.cc

Issue 2720613002: Downloads: Added transient flag to download item and download database (Closed)
Patch Set: Fixed migration unit test Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 item->GetTabReferrerUrl(), 134 item->GetTabReferrerUrl(),
135 std::string(), // HTTP method (not available yet) 135 std::string(), // HTTP method (not available yet)
136 item->GetMimeType(), item->GetOriginalMimeType(), item->GetStartTime(), 136 item->GetMimeType(), item->GetOriginalMimeType(), item->GetStartTime(),
137 item->GetEndTime(), item->GetETag(), item->GetLastModifiedTime(), 137 item->GetEndTime(), item->GetETag(), item->GetLastModifiedTime(),
138 item->GetReceivedBytes(), item->GetTotalBytes(), 138 item->GetReceivedBytes(), item->GetTotalBytes(),
139 history::ToHistoryDownloadState(item->GetState()), 139 history::ToHistoryDownloadState(item->GetState()),
140 history::ToHistoryDownloadDangerType(item->GetDangerType()), 140 history::ToHistoryDownloadDangerType(item->GetDangerType()),
141 history::ToHistoryDownloadInterruptReason(item->GetLastReason()), 141 history::ToHistoryDownloadInterruptReason(item->GetLastReason()),
142 std::string(), // Hash value (not available yet) 142 std::string(), // Hash value (not available yet)
143 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(), 143 history::ToHistoryDownloadId(item->GetId()), item->GetGuid(),
144 item->GetOpened(), item->GetLastAccessTime(), by_ext_id, by_ext_name, 144 item->GetOpened(), item->GetLastAccessTime(), item->IsVisible(),
145 history::GetHistoryDownloadSliceInfos(*item)); 145 by_ext_id, by_ext_name, history::GetHistoryDownloadSliceInfos(*item));
146 } 146 }
147 147
148 enum class ShouldUpdateHistoryResult { 148 enum class ShouldUpdateHistoryResult {
149 NO_UPDATE, 149 NO_UPDATE,
150 UPDATE, 150 UPDATE,
151 UPDATE_IMMEDIATELY, 151 UPDATE_IMMEDIATELY,
152 }; 152 };
153 153
154 ShouldUpdateHistoryResult ShouldUpdateHistory( 154 ShouldUpdateHistoryResult ShouldUpdateHistory(
155 const history::DownloadRow* previous, 155 const history::DownloadRow* previous,
(...skipping 16 matching lines...) Expand all
172 (previous->received_bytes != current.received_bytes) || 172 (previous->received_bytes != current.received_bytes) ||
173 (previous->total_bytes != current.total_bytes) || 173 (previous->total_bytes != current.total_bytes) ||
174 (previous->etag != current.etag) || 174 (previous->etag != current.etag) ||
175 (previous->last_modified != current.last_modified) || 175 (previous->last_modified != current.last_modified) ||
176 (previous->state != current.state) || 176 (previous->state != current.state) ||
177 (previous->danger_type != current.danger_type) || 177 (previous->danger_type != current.danger_type) ||
178 (previous->interrupt_reason != current.interrupt_reason) || 178 (previous->interrupt_reason != current.interrupt_reason) ||
179 (previous->hash != current.hash) || 179 (previous->hash != current.hash) ||
180 (previous->opened != current.opened) || 180 (previous->opened != current.opened) ||
181 (previous->last_access_time != current.last_access_time) || 181 (previous->last_access_time != current.last_access_time) ||
182 (previous->visible != current.visible) ||
182 (previous->by_ext_id != current.by_ext_id) || 183 (previous->by_ext_id != current.by_ext_id) ||
183 (previous->by_ext_name != current.by_ext_name) || 184 (previous->by_ext_name != current.by_ext_name) ||
184 (previous->download_slice_info != current.download_slice_info)) { 185 (previous->download_slice_info != current.download_slice_info)) {
185 return ShouldUpdateHistoryResult::UPDATE; 186 return ShouldUpdateHistoryResult::UPDATE;
186 } 187 }
187 188
188 return ShouldUpdateHistoryResult::NO_UPDATE; 189 return ShouldUpdateHistoryResult::NO_UPDATE;
189 } 190 }
190 191
191 typedef std::vector<history::DownloadRow> InfoVector; 192 typedef std::vector<history::DownloadRow> InfoVector;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 it->guid, loading_id_, it->current_path, it->target_path, it->url_chain, 293 it->guid, loading_id_, it->current_path, it->target_path, it->url_chain,
293 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url, 294 it->referrer_url, it->site_url, it->tab_url, it->tab_referrer_url,
294 it->mime_type, it->original_mime_type, it->start_time, it->end_time, 295 it->mime_type, it->original_mime_type, it->start_time, it->end_time,
295 it->etag, it->last_modified, it->received_bytes, it->total_bytes, 296 it->etag, it->last_modified, it->received_bytes, it->total_bytes,
296 std::string(), // TODO(asanka): Need to persist and restore hash of 297 std::string(), // TODO(asanka): Need to persist and restore hash of
297 // partial file for an interrupted download. No need to 298 // partial file for an interrupted download. No need to
298 // store hash for a completed file. 299 // store hash for a completed file.
299 history::ToContentDownloadState(it->state), 300 history::ToContentDownloadState(it->state),
300 history::ToContentDownloadDangerType(it->danger_type), 301 history::ToContentDownloadDangerType(it->danger_type),
301 history::ToContentDownloadInterruptReason(it->interrupt_reason), 302 history::ToContentDownloadInterruptReason(it->interrupt_reason),
302 it->opened, it->last_access_time, 303 it->opened, it->last_access_time, it->visible,
303 history::ToContentReceivedSlices(it->download_slice_info)); 304 history::ToContentReceivedSlices(it->download_slice_info));
304 #if BUILDFLAG(ENABLE_EXTENSIONS) 305 #if BUILDFLAG(ENABLE_EXTENSIONS)
305 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { 306 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) {
306 new extensions::DownloadedByExtension( 307 new extensions::DownloadedByExtension(
307 item, it->by_ext_id, it->by_ext_name); 308 item, it->by_ext_id, it->by_ext_name);
308 item->UpdateObservers(); 309 item->UpdateObservers();
309 } 310 }
310 #endif 311 #endif
311 DCHECK_EQ(DownloadHistoryData::PERSISTED, 312 DCHECK_EQ(DownloadHistoryData::PERSISTED,
312 DownloadHistoryData::Get(item)->state()); 313 DownloadHistoryData::Get(item)->state());
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 495 }
495 496
496 void DownloadHistory::RemoveDownloadsBatch() { 497 void DownloadHistory::RemoveDownloadsBatch() {
497 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 498 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
498 IdSet remove_ids; 499 IdSet remove_ids;
499 removing_ids_.swap(remove_ids); 500 removing_ids_.swap(remove_ids);
500 history_->RemoveDownloads(remove_ids); 501 history_->RemoveDownloads(remove_ids);
501 for (Observer& observer : observers_) 502 for (Observer& observer : observers_)
502 observer.OnDownloadsRemoved(remove_ids); 503 observer.OnDownloadsRemoved(remove_ids);
503 } 504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698