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

Unified Diff: chrome/browser/download/download_item.cc

Issue 6096003: Put history insertion for downloads processing inline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split state and data reception changes, got rid of pending_finished_downloads_. Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_item.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_item.cc
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index f87045109c37ee804255d3b9a655d902ef12a2ab..828493cac9b431a4157f03945b64e0f1ce491518 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -27,6 +27,23 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/pref_names.h"
+// A DownloadItem normally goes through the following states:
+// * Created (when download starts)
+// * Made visible to consumers (e.g. Javascript) after the
+// destination file has been determined.
+// * Entered into the history database.
+// * Made visible in the download shelf.
+// * All data is received. Note that the actual data download occurs
+// in parallel with the above steps, but until those steps are
+// complete, completion of the data download will be ignored.
+// * Download file is renamed to its final name, and possibly
+// auto-opened.
+// TODO(rdsmith): This progress should be reflected in
+// DownloadItem::DownloadState and a state transition table/state diagram.
+//
+// TODO(rdsmith): This description should be updated to reflect the cancel
+// pathways.
+
namespace {
// Update frequency (milliseconds).
@@ -101,9 +118,12 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(info.is_extension_install),
name_finalized_(false),
is_temporary_(false),
+ all_data_received_(false),
opened_(false) {
if (state_ == IN_PROGRESS)
state_ = CANCELLED;
+ if (state_ == COMPLETE)
+ all_data_received_ = true;
Init(false /* don't start progress timer */);
}
@@ -137,6 +157,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(info.is_extension_install),
name_finalized_(false),
is_temporary_(!info.save_info.file_path.empty()),
+ all_data_received_(false),
opened_(false) {
Init(true /* start progress timer */);
}
@@ -171,6 +192,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
is_extension_install_(false),
name_finalized_(false),
is_temporary_(false),
+ all_data_received_(false),
opened_(false) {
Init(true /* start progress timer */);
}
@@ -296,8 +318,14 @@ void DownloadItem::Cancel(bool update_history) {
download_manager_->DownloadCancelled(id_);
}
-void DownloadItem::OnAllDataSaved(int64 size) {
+void DownloadItem::OnDataReceptionAccepted() {
Paweł Hajdan Jr. 2011/01/19 17:16:15 This is another ambiguous name that I'd like to av
Randy Smith (Not in Mondays) 2011/01/19 19:53:03 Done.
+ DCHECK(all_data_received_);
state_ = COMPLETE;
+}
+
+void DownloadItem::OnAllDataSaved(int64 size) {
+ DCHECK(!all_data_received_);
+ all_data_received_ = true;
Paweł Hajdan Jr. 2011/01/19 17:16:15 nit: Now we have two names for the same thing: "sa
Randy Smith (Not in Mondays) 2011/01/19 19:53:03 Done.
UpdateSize(size);
StopProgressTimer();
}
@@ -321,7 +349,7 @@ void DownloadItem::Finished() {
auto_opened_ = true;
}
- // Notify our observers that we are complete (the call to OnAllDataSaved()
+ // Notify our observers that we are complete (the call to OnReadyToFinish()
Paweł Hajdan Jr. 2011/01/19 17:16:15 nit: This method name no longer exists.
Randy Smith (Not in Mondays) 2011/01/19 19:53:03 Fixed, though now that you point it out, I don't c
// set the state to complete but did not notify).
UpdateObservers();
@@ -375,6 +403,10 @@ int DownloadItem::PercentComplete() const {
return percent;
}
+bool DownloadItem::AllDataReceived() const {
Paweł Hajdan Jr. 2011/01/19 17:16:15 nit: Can we add prefix like "Is" or "Has" to unamb
Randy Smith (Not in Mondays) 2011/01/19 19:53:03 The reason I hadn't done this is that I'm not prov
+ return all_data_received_;
+}
+
void DownloadItem::Rename(const FilePath& full_path) {
VLOG(20) << " " << __FUNCTION__ << "()"
<< " full_path = " << full_path.value()
« no previous file with comments | « chrome/browser/download/download_item.h ('k') | chrome/browser/download/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698