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

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

Issue 1751603002: [Downloads] Rework how hashes are calculated for download files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 void DownloadHistory::QueryCallback(scoped_ptr<InfoVector> infos) { 258 void DownloadHistory::QueryCallback(scoped_ptr<InfoVector> infos) {
259 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 259 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
260 // ManagerGoingDown() may have happened before the history loaded. 260 // ManagerGoingDown() may have happened before the history loaded.
261 if (!notifier_.GetManager()) 261 if (!notifier_.GetManager())
262 return; 262 return;
263 for (InfoVector::const_iterator it = infos->begin(); 263 for (InfoVector::const_iterator it = infos->begin();
264 it != infos->end(); ++it) { 264 it != infos->end(); ++it) {
265 loading_id_ = history::ToContentDownloadId(it->id); 265 loading_id_ = history::ToContentDownloadId(it->id);
266 content::DownloadItem* item = notifier_.GetManager()->CreateDownloadItem( 266 content::DownloadItem* item = notifier_.GetManager()->CreateDownloadItem(
267 loading_id_, 267 loading_id_, it->current_path, it->target_path, it->url_chain,
svaldez 2016/03/09 19:27:33 nit: Might want to revert the formatting, though n
asanka 2016/03/10 16:48:08 'git cl format' :-( I like the previous formatting
268 it->current_path, 268 it->referrer_url, it->mime_type, it->original_mime_type, it->start_time,
269 it->target_path, 269 it->end_time, it->etag, it->last_modified, it->received_bytes,
270 it->url_chain,
271 it->referrer_url,
272 it->mime_type,
273 it->original_mime_type,
274 it->start_time,
275 it->end_time,
276 it->etag,
277 it->last_modified,
278 it->received_bytes,
279 it->total_bytes, 270 it->total_bytes,
271 std::string(), // TODO(asanka): Need to persist and restore hash of
272 // partial file for an interrupted download. No need to
273 // store hash for a completed file.
280 history::ToContentDownloadState(it->state), 274 history::ToContentDownloadState(it->state),
281 history::ToContentDownloadDangerType(it->danger_type), 275 history::ToContentDownloadDangerType(it->danger_type),
282 history::ToContentDownloadInterruptReason(it->interrupt_reason), 276 history::ToContentDownloadInterruptReason(it->interrupt_reason),
283 it->opened); 277 it->opened);
284 #if defined(ENABLE_EXTENSIONS) 278 #if defined(ENABLE_EXTENSIONS)
285 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) { 279 if (!it->by_ext_id.empty() && !it->by_ext_name.empty()) {
286 new extensions::DownloadedByExtension( 280 new extensions::DownloadedByExtension(
287 item, it->by_ext_id, it->by_ext_name); 281 item, it->by_ext_id, it->by_ext_name);
288 item->UpdateObservers(); 282 item->UpdateObservers();
289 } 283 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 removing_ids_.insert(download_id); 454 removing_ids_.insert(download_id);
461 } 455 }
462 456
463 void DownloadHistory::RemoveDownloadsBatch() { 457 void DownloadHistory::RemoveDownloadsBatch() {
464 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 458 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
465 IdSet remove_ids; 459 IdSet remove_ids;
466 removing_ids_.swap(remove_ids); 460 removing_ids_.swap(remove_ids);
467 history_->RemoveDownloads(remove_ids); 461 history_->RemoveDownloads(remove_ids);
468 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); 462 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids));
469 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698