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

Side by Side Diff: content/browser/download/download_manager.cc

Issue 8414007: Rearrange Should*Download delegate calls to be more useful and intuitive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaked comment. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/browser/download/download_manager.h" 5 #include "content/browser/download/download_manager.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 // Confirm we're in the proper set of states to be here; 489 // Confirm we're in the proper set of states to be here;
490 // in in_progress_, have all data, have a history handle, (validated or safe). 490 // in in_progress_, have all data, have a history handle, (validated or safe).
491 DCHECK_NE(DownloadItem::DANGEROUS, download->safety_state()); 491 DCHECK_NE(DownloadItem::DANGEROUS, download->safety_state());
492 DCHECK_EQ(1u, in_progress_.count(download->id())); 492 DCHECK_EQ(1u, in_progress_.count(download->id()));
493 DCHECK(download->all_data_saved()); 493 DCHECK(download->all_data_saved());
494 DCHECK(download->db_handle() != DownloadItem::kUninitializedHandle); 494 DCHECK(download->db_handle() != DownloadItem::kUninitializedHandle);
495 DCHECK_EQ(1u, history_downloads_.count(download->db_handle())); 495 DCHECK_EQ(1u, history_downloads_.count(download->db_handle()));
496 496
497 VLOG(20) << __FUNCTION__ << "()" << " executing: download = " 497 VLOG(20) << __FUNCTION__ << "()" << " executing: download = "
498 << download->DebugString(false); 498 << download->DebugString(false);
asanka 2011/10/28 19:22:19 Very minor nit: Should this logging happen after c
Randy Smith (Not in Mondays) 2011/10/29 23:10:39 Yeah, I think so. Done.
499 499
500 // Give the delegate a chance to override.
501 if (!delegate_->ShouldCompleteDownload(download))
502 return;
503
500 // Remove the id from in_progress 504 // Remove the id from in_progress
501 in_progress_.erase(download->id()); 505 in_progress_.erase(download->id());
502 UpdateDownloadProgress(); // Reflect removal from in_progress_. 506 UpdateDownloadProgress(); // Reflect removal from in_progress_.
503 507
504 delegate_->UpdateItemInPersistentStore(download); 508 delegate_->UpdateItemInPersistentStore(download);
505 509
506 // Finish the download. 510 // Finish the download.
507 download->OnDownloadCompleting(file_manager_); 511 download->OnDownloadCompleting(file_manager_);
508 } 512 }
509 513
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 void DownloadManager::MarkDownloadOpened(DownloadItem* download) { 1087 void DownloadManager::MarkDownloadOpened(DownloadItem* download) {
1084 delegate_->UpdateItemInPersistentStore(download); 1088 delegate_->UpdateItemInPersistentStore(download);
1085 int num_unopened = 0; 1089 int num_unopened = 0;
1086 for (DownloadMap::iterator it = history_downloads_.begin(); 1090 for (DownloadMap::iterator it = history_downloads_.begin();
1087 it != history_downloads_.end(); ++it) { 1091 it != history_downloads_.end(); ++it) {
1088 if (it->second->IsComplete() && !it->second->opened()) 1092 if (it->second->IsComplete() && !it->second->opened())
1089 ++num_unopened; 1093 ++num_unopened;
1090 } 1094 }
1091 download_stats::RecordOpensOutstanding(num_unopened); 1095 download_stats::RecordOpensOutstanding(num_unopened);
1092 } 1096 }
OLDNEW
« no previous file with comments | « content/browser/download/download_item.cc ('k') | content/browser/download/mock_download_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698