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

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

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r158560 Created 8 years, 2 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 | Annotate | Revision Log
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 // File method ordering: Methods in this file are in the same order 5 // File method ordering: Methods in this file are in the same order
6 // as in download_item_impl.h, with the following exception: The public 6 // as in download_item_impl.h, with the following exception: The public
7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and 7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and
8 // OnDownloadCompleting are placed in chronological order with the other 8 // OnDownloadCompleting are placed in chronological order with the other
9 // (private) routines that together define a DownloadItem's state transitions 9 // (private) routines that together define a DownloadItem's state transitions
10 // as the download progresses. See "Download progression cascade" later in 10 // as the download progresses. See "Download progression cascade" later in
(...skipping 27 matching lines...) Expand all
38 #include "content/browser/download/download_create_info.h" 38 #include "content/browser/download/download_create_info.h"
39 #include "content/browser/download/download_file.h" 39 #include "content/browser/download/download_file.h"
40 #include "content/browser/download/download_file_manager.h" 40 #include "content/browser/download/download_file_manager.h"
41 #include "content/browser/download/download_interrupt_reasons_impl.h" 41 #include "content/browser/download/download_interrupt_reasons_impl.h"
42 #include "content/browser/download/download_item_impl_delegate.h" 42 #include "content/browser/download/download_item_impl_delegate.h"
43 #include "content/browser/download/download_request_handle.h" 43 #include "content/browser/download/download_request_handle.h"
44 #include "content/browser/download/download_stats.h" 44 #include "content/browser/download/download_stats.h"
45 #include "content/browser/web_contents/web_contents_impl.h" 45 #include "content/browser/web_contents/web_contents_impl.h"
46 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/content_browser_client.h" 47 #include "content/public/browser/content_browser_client.h"
48 #include "content/public/browser/download_persistent_store_info.h"
49 #include "net/base/net_util.h" 48 #include "net/base/net_util.h"
50 49
51 using content::BrowserThread; 50 using content::BrowserThread;
52 using content::DownloadFile; 51 using content::DownloadFile;
53 using content::DownloadId; 52 using content::DownloadId;
54 using content::DownloadItem; 53 using content::DownloadItem;
55 using content::DownloadManager; 54 using content::DownloadManager;
56 using content::DownloadPersistentStoreInfo;
57 using content::WebContents; 55 using content::WebContents;
58 56
59 namespace { 57 namespace {
60 58
61 static void DeleteDownloadedFile(const FilePath& path) { 59 static void DeleteDownloadedFile(const FilePath& path) {
62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
63 61
64 // Make sure we only delete files. 62 // Make sure we only delete files.
65 if (!file_util::DirectoryExists(path)) 63 if (!file_util::DirectoryExists(path))
66 file_util::Delete(path, false); 64 file_util::Delete(path, false);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 virtual void CancelRequest() const OVERRIDE {} 99 virtual void CancelRequest() const OVERRIDE {}
102 virtual std::string DebugString() const OVERRIDE { 100 virtual std::string DebugString() const OVERRIDE {
103 return "Null DownloadRequestHandle"; 101 return "Null DownloadRequestHandle";
104 } 102 }
105 }; 103 };
106 104
107 } // namespace 105 } // namespace
108 106
109 namespace content { 107 namespace content {
110 108
111 // Our download table ID starts at 1, so we use 0 to represent a download that
112 // has started, but has not yet had its data persisted in the table. We use fake
113 // database handles in incognito mode starting at -1 and progressively getting
114 // more negative.
115 // static
116 const int DownloadItem::kUninitializedHandle = 0;
117
118 const char DownloadItem::kEmptyFileHash[] = ""; 109 const char DownloadItem::kEmptyFileHash[] = "";
119 110
120 } 111 }
121 112
122 // Our download table ID starts at 1, so we use 0 to represent a download that
123 // has started, but has not yet had its data persisted in the table. We use fake
124 // database handles in incognito mode starting at -1 and progressively getting
125 // more negative.
126
127 // Constructor for reading from the history service. 113 // Constructor for reading from the history service.
128 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 114 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
129 DownloadId download_id, 115 DownloadId download_id,
130 const DownloadPersistentStoreInfo& info, 116 const FilePath& path,
117 const GURL& url,
118 const GURL& referrer_url,
119 const base::Time& start_time,
120 const base::Time& end_time,
121 int64 received_bytes,
122 int64 total_bytes,
123 DownloadItem::DownloadState state,
124 bool opened,
131 const net::BoundNetLog& bound_net_log) 125 const net::BoundNetLog& bound_net_log)
132 : download_id_(download_id), 126 : download_id_(download_id),
133 current_path_(info.path), 127 current_path_(path),
134 target_path_(info.path), 128 target_path_(path),
135 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 129 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
136 url_chain_(1, info.url), 130 url_chain_(1, url),
137 referrer_url_(info.referrer_url), 131 referrer_url_(referrer_url),
138 transition_type_(content::PAGE_TRANSITION_LINK), 132 transition_type_(content::PAGE_TRANSITION_LINK),
139 has_user_gesture_(false), 133 has_user_gesture_(false),
140 total_bytes_(info.total_bytes), 134 total_bytes_(total_bytes),
141 received_bytes_(info.received_bytes), 135 received_bytes_(received_bytes),
142 bytes_per_sec_(0), 136 bytes_per_sec_(0),
143 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 137 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
144 start_tick_(base::TimeTicks()), 138 start_tick_(base::TimeTicks()),
145 state_(ExternalToInternalState(info.state)), 139 state_(ExternalToInternalState(state)),
146 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 140 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
147 start_time_(info.start_time), 141 start_time_(start_time),
148 end_time_(info.end_time), 142 end_time_(end_time),
149 db_handle_(info.db_handle),
150 delegate_(delegate), 143 delegate_(delegate),
151 is_paused_(false), 144 is_paused_(false),
152 open_when_complete_(false), 145 open_when_complete_(false),
153 file_externally_removed_(false), 146 file_externally_removed_(false),
154 safety_state_(SAFE), 147 safety_state_(SAFE),
155 auto_opened_(false), 148 auto_opened_(false),
156 is_persisted_(true),
157 is_temporary_(false), 149 is_temporary_(false),
158 all_data_saved_(false), 150 all_data_saved_(false),
159 opened_(info.opened), 151 opened_(opened),
160 open_enabled_(true), 152 open_enabled_(true),
161 delegate_delayed_complete_(false), 153 delegate_delayed_complete_(false),
162 bound_net_log_(bound_net_log), 154 bound_net_log_(bound_net_log),
163 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 155 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
164 delegate_->Attach(); 156 delegate_->Attach();
165 if (state_ == IN_PROGRESS_INTERNAL) 157 if (state_ == IN_PROGRESS_INTERNAL)
166 state_ = CANCELLED_INTERNAL; 158 state_ = CANCELLED_INTERNAL;
167 if (state_ == COMPLETE_INTERNAL) 159 if (state_ == COMPLETE_INTERNAL)
168 all_data_saved_ = true; 160 all_data_saved_ = true;
169 Init(false /* not actively downloading */, 161 Init(false /* not actively downloading */,
(...skipping 23 matching lines...) Expand all
193 referrer_charset_(info.referrer_charset), 185 referrer_charset_(info.referrer_charset),
194 remote_address_(info.remote_address), 186 remote_address_(info.remote_address),
195 total_bytes_(info.total_bytes), 187 total_bytes_(info.total_bytes),
196 received_bytes_(0), 188 received_bytes_(0),
197 bytes_per_sec_(0), 189 bytes_per_sec_(0),
198 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 190 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
199 start_tick_(base::TimeTicks::Now()), 191 start_tick_(base::TimeTicks::Now()),
200 state_(IN_PROGRESS_INTERNAL), 192 state_(IN_PROGRESS_INTERNAL),
201 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 193 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
202 start_time_(info.start_time), 194 start_time_(info.start_time),
203 db_handle_(DownloadItem::kUninitializedHandle),
204 delegate_(delegate), 195 delegate_(delegate),
205 is_paused_(false), 196 is_paused_(false),
206 open_when_complete_(false), 197 open_when_complete_(false),
207 file_externally_removed_(false), 198 file_externally_removed_(false),
208 safety_state_(SAFE), 199 safety_state_(SAFE),
209 auto_opened_(false), 200 auto_opened_(false),
210 is_persisted_(false),
211 is_temporary_(!info.save_info.file_path.empty()), 201 is_temporary_(!info.save_info.file_path.empty()),
212 all_data_saved_(false), 202 all_data_saved_(false),
213 opened_(false), 203 opened_(false),
214 open_enabled_(true), 204 open_enabled_(true),
215 delegate_delayed_complete_(false), 205 delegate_delayed_complete_(false),
216 bound_net_log_(bound_net_log), 206 bound_net_log_(bound_net_log),
217 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 207 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
218 delegate_->Attach(); 208 delegate_->Attach();
219 Init(true /* actively downloading */, 209 Init(true /* actively downloading */,
220 download_net_logs::SRC_NEW_DOWNLOAD); 210 download_net_logs::SRC_NEW_DOWNLOAD);
(...skipping 27 matching lines...) Expand all
248 mime_type_(mime_type), 238 mime_type_(mime_type),
249 original_mime_type_(mime_type), 239 original_mime_type_(mime_type),
250 total_bytes_(0), 240 total_bytes_(0),
251 received_bytes_(0), 241 received_bytes_(0),
252 bytes_per_sec_(0), 242 bytes_per_sec_(0),
253 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 243 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
254 start_tick_(base::TimeTicks::Now()), 244 start_tick_(base::TimeTicks::Now()),
255 state_(IN_PROGRESS_INTERNAL), 245 state_(IN_PROGRESS_INTERNAL),
256 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 246 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
257 start_time_(base::Time::Now()), 247 start_time_(base::Time::Now()),
258 db_handle_(DownloadItem::kUninitializedHandle),
259 delegate_(delegate), 248 delegate_(delegate),
260 is_paused_(false), 249 is_paused_(false),
261 open_when_complete_(false), 250 open_when_complete_(false),
262 file_externally_removed_(false), 251 file_externally_removed_(false),
263 safety_state_(SAFE), 252 safety_state_(SAFE),
264 auto_opened_(false), 253 auto_opened_(false),
265 is_persisted_(false),
266 is_temporary_(false), 254 is_temporary_(false),
267 all_data_saved_(false), 255 all_data_saved_(false),
268 opened_(false), 256 opened_(false),
269 open_enabled_(true), 257 open_enabled_(true),
270 delegate_delayed_complete_(false), 258 delegate_delayed_complete_(false),
271 bound_net_log_(bound_net_log), 259 bound_net_log_(bound_net_log),
272 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 260 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
273 delegate_->Attach(); 261 delegate_->Attach();
274 Init(true /* actively downloading */, 262 Init(true /* actively downloading */,
275 download_net_logs::SRC_SAVE_PAGE_AS); 263 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 } 418 }
431 419
432 int32 DownloadItemImpl::GetId() const { 420 int32 DownloadItemImpl::GetId() const {
433 return download_id_.local(); 421 return download_id_.local();
434 } 422 }
435 423
436 DownloadId DownloadItemImpl::GetGlobalId() const { 424 DownloadId DownloadItemImpl::GetGlobalId() const {
437 return download_id_; 425 return download_id_;
438 } 426 }
439 427
440 int64 DownloadItemImpl::GetDbHandle() const {
441 return db_handle_;
442 }
443
444 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 428 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
445 return InternalToExternalState(state_); 429 return InternalToExternalState(state_);
446 } 430 }
447 431
448 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 432 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
449 return last_reason_; 433 return last_reason_;
450 } 434 }
451 435
452 bool DownloadItemImpl::IsPaused() const { 436 bool DownloadItemImpl::IsPaused() const {
453 return is_paused_; 437 return is_paused_;
454 } 438 }
455 439
456 bool DownloadItemImpl::IsTemporary() const { 440 bool DownloadItemImpl::IsTemporary() const {
457 return is_temporary_; 441 return is_temporary_;
458 } 442 }
459 443
460 bool DownloadItemImpl::IsPersisted() const {
461 return is_persisted_;
462 }
463
464 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to 444 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to
465 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. 445 // |IsPartialDownload()|, when resuming interrupted downloads is implemented.
466 bool DownloadItemImpl::IsPartialDownload() const { 446 bool DownloadItemImpl::IsPartialDownload() const {
467 return InternalToExternalState(state_) == IN_PROGRESS; 447 return InternalToExternalState(state_) == IN_PROGRESS;
468 } 448 }
469 449
470 bool DownloadItemImpl::IsInProgress() const { 450 bool DownloadItemImpl::IsInProgress() const {
471 return InternalToExternalState(state_) == IN_PROGRESS; 451 return InternalToExternalState(state_) == IN_PROGRESS;
472 } 452 }
473 453
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 } 650 }
671 651
672 bool DownloadItemImpl::GetAutoOpened() { 652 bool DownloadItemImpl::GetAutoOpened() {
673 return auto_opened_; 653 return auto_opened_;
674 } 654 }
675 655
676 bool DownloadItemImpl::GetOpened() const { 656 bool DownloadItemImpl::GetOpened() const {
677 return opened_; 657 return opened_;
678 } 658 }
679 659
680 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
681 // TODO(asanka): Persist GetTargetFilePath() as well.
682 return DownloadPersistentStoreInfo(GetFullPath(),
683 GetURL(),
684 GetReferrerUrl(),
685 GetStartTime(),
686 GetEndTime(),
687 GetReceivedBytes(),
688 GetTotalBytes(),
689 GetState(),
690 GetDbHandle(),
691 GetOpened());
692 }
693
694 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const { 660 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const {
695 return delegate_->GetBrowserContext(); 661 return delegate_->GetBrowserContext();
696 } 662 }
697 663
698 WebContents* DownloadItemImpl::GetWebContents() const { 664 WebContents* DownloadItemImpl::GetWebContents() const {
699 // TODO(rdsmith): Remove null check after removing GetWebContents() from 665 // TODO(rdsmith): Remove null check after removing GetWebContents() from
700 // paths that might be used by DownloadItems created from history import. 666 // paths that might be used by DownloadItems created from history import.
701 // Currently such items have null request_handle_s, where other items 667 // Currently such items have null request_handle_s, where other items
702 // (regular and SavePackage downloads) have actual objects off the pointer. 668 // (regular and SavePackage downloads) have actual objects off the pointer.
703 if (request_handle_.get()) 669 if (request_handle_.get())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ++iter; 711 ++iter;
746 for ( ; verbose && (iter != last); ++iter) { 712 for ( ; verbose && (iter != last); ++iter) {
747 url_list += " ->\n\t"; 713 url_list += " ->\n\t";
748 const GURL& next_url = *iter; 714 const GURL& next_url = *iter;
749 url_list += next_url.spec(); 715 url_list += next_url.spec();
750 } 716 }
751 } 717 }
752 718
753 if (verbose) { 719 if (verbose) {
754 description += base::StringPrintf( 720 description += base::StringPrintf(
755 " db_handle = %" PRId64
756 " total = %" PRId64 721 " total = %" PRId64
757 " received = %" PRId64 722 " received = %" PRId64
758 " reason = %s" 723 " reason = %s"
759 " paused = %c" 724 " paused = %c"
760 " safety = %s" 725 " safety = %s"
761 " last_modified = '%s'" 726 " last_modified = '%s'"
762 " etag = '%s'" 727 " etag = '%s'"
763 " url_chain = \n\t\"%s\"\n\t" 728 " url_chain = \n\t\"%s\"\n\t"
764 " full_path = \"%" PRFilePath "\"" 729 " full_path = \"%" PRFilePath "\""
765 " target_path = \"%" PRFilePath "\"", 730 " target_path = \"%" PRFilePath "\"",
766 GetDbHandle(),
767 GetTotalBytes(), 731 GetTotalBytes(),
768 GetReceivedBytes(), 732 GetReceivedBytes(),
769 InterruptReasonDebugString(last_reason_).c_str(), 733 InterruptReasonDebugString(last_reason_).c_str(),
770 IsPaused() ? 'T' : 'F', 734 IsPaused() ? 'T' : 'F',
771 DebugSafetyStateString(GetSafetyState()), 735 DebugSafetyStateString(GetSafetyState()),
772 GetLastModifiedTime().c_str(), 736 GetLastModifiedTime().c_str(),
773 GetETag().c_str(), 737 GetETag().c_str(),
774 url_list.c_str(), 738 url_list.c_str(),
775 GetFullPath().value().c_str(), 739 GetFullPath().value().c_str(),
776 GetTargetFilePath().value().c_str()); 740 GetTargetFilePath().value().c_str());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 845 }
882 846
883 void DownloadItemImpl::MarkAsComplete() { 847 void DownloadItemImpl::MarkAsComplete() {
884 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 848 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
885 849
886 DCHECK(all_data_saved_); 850 DCHECK(all_data_saved_);
887 end_time_ = base::Time::Now(); 851 end_time_ = base::Time::Now();
888 TransitionTo(COMPLETE_INTERNAL); 852 TransitionTo(COMPLETE_INTERNAL);
889 } 853 }
890 854
891 void DownloadItemImpl::SetIsPersisted() {
892 is_persisted_ = true;
893 UpdateObservers();
894 }
895
896 void DownloadItemImpl::SetDbHandle(int64 handle) {
897 db_handle_ = handle;
898
899 bound_net_log_.AddEvent(
900 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
901 net::NetLog::Int64Callback("db_handle", db_handle_));
902 }
903
904 // **** Download progression cascade 855 // **** Download progression cascade
905 856
906 void DownloadItemImpl::Init(bool active, 857 void DownloadItemImpl::Init(bool active,
907 download_net_logs::DownloadType download_type) { 858 download_net_logs::DownloadType download_type) {
908 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 859 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
909 860
910 if (active) 861 if (active)
911 download_stats::RecordDownloadCount(download_stats::START_COUNT); 862 download_stats::RecordDownloadCount(download_stats::START_COUNT);
912 863
913 if (target_path_.empty()) 864 if (target_path_.empty())
914 target_path_ = current_path_; 865 target_path_ = current_path_;
915 std::string file_name; 866 std::string file_name;
916 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) { 867 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) {
917 // target_path_ works for History and Save As versions. 868 // target_path_ works for History and Save As versions.
918 file_name = target_path_.AsUTF8Unsafe(); 869 file_name = target_path_.AsUTF8Unsafe();
919 } else { 870 } else {
920 // See if it's set programmatically. 871 // See if it's set programmatically.
921 file_name = forced_file_path_.AsUTF8Unsafe(); 872 file_name = forced_file_path_.AsUTF8Unsafe();
922 // Possibly has a 'download' attribute for the anchor. 873 // Possibly has a 'download' attribute for the anchor.
923 if (file_name.empty()) 874 if (file_name.empty())
924 file_name = suggested_filename_; 875 file_name = suggested_filename_;
925 // From the URL file name. 876 // From the URL file name.
926 if (file_name.empty()) 877 if (file_name.empty())
927 file_name = GetURL().ExtractFileName(); 878 file_name = GetURL().ExtractFileName();
928 } 879 }
929 880
930 bound_net_log_.BeginEvent( 881 base::Callback<base::Value*(net::NetLog::LogLevel)> active_data = base::Bind(
931 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 882 &download_net_logs::ItemActivatedCallback, this,
932 base::Bind(&download_net_logs::ItemActivatedCallback, 883 download_type, &file_name);
933 this, download_type, &file_name)); 884 if (active) {
934 885 bound_net_log_.BeginEvent(
935 // If this is not an active download, end the ACTIVE event now. 886 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
936 if (!active) { 887 } else {
937 bound_net_log_.AddEvent( 888 bound_net_log_.AddEvent(
938 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 889 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
939 net::NetLog::Int64Callback("db_handle", db_handle_));
940
941 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
942 } 890 }
943 891
944 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 892 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
945 } 893 }
946 894
947 // Called by DownloadManagerImpl when the download target path has been 895 // Called by DownloadManagerImpl when the download target path has been
948 // determined. 896 // determined.
949 void DownloadItemImpl::OnDownloadTargetDetermined( 897 void DownloadItemImpl::OnDownloadTargetDetermined(
950 const FilePath& target_path, 898 const FilePath& target_path,
951 TargetDisposition disposition, 899 TargetDisposition disposition,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1016
1069 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) { 1017 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
1070 Interrupt(reason); 1018 Interrupt(reason);
1071 return; 1019 return;
1072 } 1020 }
1073 1021
1074 // full_path is now the current and target file path. 1022 // full_path is now the current and target file path.
1075 DCHECK(!full_path.empty()); 1023 DCHECK(!full_path.empty());
1076 target_path_ = full_path; 1024 target_path_ = full_path;
1077 SetFullPath(full_path); 1025 SetFullPath(full_path);
1078 delegate_->DownloadRenamedToFinalName(this); 1026 UpdateObservers();
1079 1027
1080 // Complete the download and release the DownloadFile. 1028 // Complete the download and release the DownloadFile.
1081 BrowserThread::PostTask( 1029 BrowserThread::PostTask(
1082 BrowserThread::FILE, FROM_HERE, 1030 BrowserThread::FILE, FROM_HERE,
1083 base::Bind(&DownloadFileManager::CompleteDownload, 1031 base::Bind(&DownloadFileManager::CompleteDownload,
1084 delegate_->GetDownloadFileManager(), GetGlobalId(), 1032 delegate_->GetDownloadFileManager(), GetGlobalId(),
1085 base::Bind(&DownloadItemImpl::OnDownloadFileReleased, 1033 base::Bind(&DownloadItemImpl::OnDownloadFileReleased,
1086 weak_ptr_factory_.GetWeakPtr()))); 1034 weak_ptr_factory_.GetWeakPtr())));
1087 TransitionTo(COMPLETING_INTERNAL); 1035 TransitionTo(COMPLETING_INTERNAL);
1088 } 1036 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 return "COMPLETE"; 1225 return "COMPLETE";
1278 case CANCELLED_INTERNAL: 1226 case CANCELLED_INTERNAL:
1279 return "CANCELLED"; 1227 return "CANCELLED";
1280 case INTERRUPTED_INTERNAL: 1228 case INTERRUPTED_INTERNAL:
1281 return "INTERRUPTED"; 1229 return "INTERRUPTED";
1282 default: 1230 default:
1283 NOTREACHED() << "Unknown download state " << state; 1231 NOTREACHED() << "Unknown download state " << state;
1284 return "unknown"; 1232 return "unknown";
1285 }; 1233 };
1286 } 1234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698