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

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: @r159248 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 422 }
435 423
436 int32 DownloadItemImpl::GetId() const { 424 int32 DownloadItemImpl::GetId() const {
437 return download_id_.local(); 425 return download_id_.local();
438 } 426 }
439 427
440 DownloadId DownloadItemImpl::GetGlobalId() const { 428 DownloadId DownloadItemImpl::GetGlobalId() const {
441 return download_id_; 429 return download_id_;
442 } 430 }
443 431
444 int64 DownloadItemImpl::GetDbHandle() const {
445 return db_handle_;
446 }
447
448 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 432 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
449 return InternalToExternalState(state_); 433 return InternalToExternalState(state_);
450 } 434 }
451 435
452 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 436 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
453 return last_reason_; 437 return last_reason_;
454 } 438 }
455 439
456 bool DownloadItemImpl::IsPaused() const { 440 bool DownloadItemImpl::IsPaused() const {
457 return is_paused_; 441 return is_paused_;
458 } 442 }
459 443
460 bool DownloadItemImpl::IsTemporary() const { 444 bool DownloadItemImpl::IsTemporary() const {
461 return is_temporary_; 445 return is_temporary_;
462 } 446 }
463 447
464 bool DownloadItemImpl::IsPersisted() const {
465 return is_persisted_;
466 }
467
468 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to 448 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to
469 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. 449 // |IsPartialDownload()|, when resuming interrupted downloads is implemented.
470 bool DownloadItemImpl::IsPartialDownload() const { 450 bool DownloadItemImpl::IsPartialDownload() const {
471 return InternalToExternalState(state_) == IN_PROGRESS; 451 return InternalToExternalState(state_) == IN_PROGRESS;
472 } 452 }
473 453
474 bool DownloadItemImpl::IsInProgress() const { 454 bool DownloadItemImpl::IsInProgress() const {
475 return InternalToExternalState(state_) == IN_PROGRESS; 455 return InternalToExternalState(state_) == IN_PROGRESS;
476 } 456 }
477 457
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 654 }
675 655
676 bool DownloadItemImpl::GetAutoOpened() { 656 bool DownloadItemImpl::GetAutoOpened() {
677 return auto_opened_; 657 return auto_opened_;
678 } 658 }
679 659
680 bool DownloadItemImpl::GetOpened() const { 660 bool DownloadItemImpl::GetOpened() const {
681 return opened_; 661 return opened_;
682 } 662 }
683 663
684 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
685 // TODO(asanka): Persist GetTargetFilePath() as well.
686 return DownloadPersistentStoreInfo(GetFullPath(),
687 GetURL(),
688 GetReferrerUrl(),
689 GetStartTime(),
690 GetEndTime(),
691 GetReceivedBytes(),
692 GetTotalBytes(),
693 GetState(),
694 GetDbHandle(),
695 GetOpened());
696 }
697
698 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const { 664 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const {
699 return delegate_->GetBrowserContext(); 665 return delegate_->GetBrowserContext();
700 } 666 }
701 667
702 WebContents* DownloadItemImpl::GetWebContents() const { 668 WebContents* DownloadItemImpl::GetWebContents() const {
703 // TODO(rdsmith): Remove null check after removing GetWebContents() from 669 // TODO(rdsmith): Remove null check after removing GetWebContents() from
704 // paths that might be used by DownloadItems created from history import. 670 // paths that might be used by DownloadItems created from history import.
705 // Currently such items have null request_handle_s, where other items 671 // Currently such items have null request_handle_s, where other items
706 // (regular and SavePackage downloads) have actual objects off the pointer. 672 // (regular and SavePackage downloads) have actual objects off the pointer.
707 if (request_handle_.get()) 673 if (request_handle_.get())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 ++iter; 715 ++iter;
750 for ( ; verbose && (iter != last); ++iter) { 716 for ( ; verbose && (iter != last); ++iter) {
751 url_list += " ->\n\t"; 717 url_list += " ->\n\t";
752 const GURL& next_url = *iter; 718 const GURL& next_url = *iter;
753 url_list += next_url.spec(); 719 url_list += next_url.spec();
754 } 720 }
755 } 721 }
756 722
757 if (verbose) { 723 if (verbose) {
758 description += base::StringPrintf( 724 description += base::StringPrintf(
759 " db_handle = %" PRId64
760 " total = %" PRId64 725 " total = %" PRId64
761 " received = %" PRId64 726 " received = %" PRId64
762 " reason = %s" 727 " reason = %s"
763 " paused = %c" 728 " paused = %c"
764 " safety = %s" 729 " safety = %s"
765 " last_modified = '%s'" 730 " last_modified = '%s'"
766 " etag = '%s'" 731 " etag = '%s'"
767 " url_chain = \n\t\"%s\"\n\t" 732 " url_chain = \n\t\"%s\"\n\t"
768 " full_path = \"%" PRFilePath "\"" 733 " full_path = \"%" PRFilePath "\""
769 " target_path = \"%" PRFilePath "\"", 734 " target_path = \"%" PRFilePath "\"",
770 GetDbHandle(),
771 GetTotalBytes(), 735 GetTotalBytes(),
772 GetReceivedBytes(), 736 GetReceivedBytes(),
773 InterruptReasonDebugString(last_reason_).c_str(), 737 InterruptReasonDebugString(last_reason_).c_str(),
774 IsPaused() ? 'T' : 'F', 738 IsPaused() ? 'T' : 'F',
775 DebugSafetyStateString(GetSafetyState()), 739 DebugSafetyStateString(GetSafetyState()),
776 GetLastModifiedTime().c_str(), 740 GetLastModifiedTime().c_str(),
777 GetETag().c_str(), 741 GetETag().c_str(),
778 url_list.c_str(), 742 url_list.c_str(),
779 GetFullPath().value().c_str(), 743 GetFullPath().value().c_str(),
780 GetTargetFilePath().value().c_str()); 744 GetTargetFilePath().value().c_str());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 849 }
886 850
887 void DownloadItemImpl::MarkAsComplete() { 851 void DownloadItemImpl::MarkAsComplete() {
888 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 852 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
889 853
890 DCHECK(all_data_saved_); 854 DCHECK(all_data_saved_);
891 end_time_ = base::Time::Now(); 855 end_time_ = base::Time::Now();
892 TransitionTo(COMPLETE_INTERNAL); 856 TransitionTo(COMPLETE_INTERNAL);
893 } 857 }
894 858
895 void DownloadItemImpl::SetIsPersisted() {
896 is_persisted_ = true;
897 UpdateObservers();
898 }
899
900 void DownloadItemImpl::SetDbHandle(int64 handle) {
901 db_handle_ = handle;
902
903 bound_net_log_.AddEvent(
904 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
905 net::NetLog::Int64Callback("db_handle", db_handle_));
906 }
907
908 // **** Download progression cascade 859 // **** Download progression cascade
909 860
910 void DownloadItemImpl::Init(bool active, 861 void DownloadItemImpl::Init(bool active,
911 download_net_logs::DownloadType download_type) { 862 download_net_logs::DownloadType download_type) {
912 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 863 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
913 864
914 if (active) 865 if (active)
915 download_stats::RecordDownloadCount(download_stats::START_COUNT); 866 download_stats::RecordDownloadCount(download_stats::START_COUNT);
916 867
917 if (target_path_.empty()) 868 if (target_path_.empty())
918 target_path_ = current_path_; 869 target_path_ = current_path_;
919 std::string file_name; 870 std::string file_name;
920 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) { 871 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) {
921 // target_path_ works for History and Save As versions. 872 // target_path_ works for History and Save As versions.
922 file_name = target_path_.AsUTF8Unsafe(); 873 file_name = target_path_.AsUTF8Unsafe();
923 } else { 874 } else {
924 // See if it's set programmatically. 875 // See if it's set programmatically.
925 file_name = forced_file_path_.AsUTF8Unsafe(); 876 file_name = forced_file_path_.AsUTF8Unsafe();
926 // Possibly has a 'download' attribute for the anchor. 877 // Possibly has a 'download' attribute for the anchor.
927 if (file_name.empty()) 878 if (file_name.empty())
928 file_name = suggested_filename_; 879 file_name = suggested_filename_;
929 // From the URL file name. 880 // From the URL file name.
930 if (file_name.empty()) 881 if (file_name.empty())
931 file_name = GetURL().ExtractFileName(); 882 file_name = GetURL().ExtractFileName();
932 } 883 }
933 884
934 bound_net_log_.BeginEvent( 885 base::Callback<base::Value*(net::NetLog::LogLevel)> active_data = base::Bind(
935 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 886 &download_net_logs::ItemActivatedCallback, this,
936 base::Bind(&download_net_logs::ItemActivatedCallback, 887 download_type, &file_name);
937 this, download_type, &file_name)); 888 if (active) {
938 889 bound_net_log_.BeginEvent(
939 // If this is not an active download, end the ACTIVE event now. 890 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
940 if (!active) { 891 } else {
941 bound_net_log_.AddEvent( 892 bound_net_log_.AddEvent(
asanka 2012/09/28 19:02:30 EndEvent()
benjhayden 2012/10/01 14:10:03 Can you elaborate why? This is Init(), which is on
asanka 2012/10/01 15:59:36 Ignore my comment. I misread.
942 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 893 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
943 net::NetLog::Int64Callback("db_handle", db_handle_));
944
945 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
946 } 894 }
947 895
948 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 896 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
949 } 897 }
950 898
951 // Called by DownloadManagerImpl when the download target path has been 899 // Called by DownloadManagerImpl when the download target path has been
952 // determined. 900 // determined.
953 void DownloadItemImpl::OnDownloadTargetDetermined( 901 void DownloadItemImpl::OnDownloadTargetDetermined(
954 const FilePath& target_path, 902 const FilePath& target_path,
955 TargetDisposition disposition, 903 TargetDisposition disposition,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 1020
1073 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) { 1021 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
1074 Interrupt(reason); 1022 Interrupt(reason);
1075 return; 1023 return;
1076 } 1024 }
1077 1025
1078 // full_path is now the current and target file path. 1026 // full_path is now the current and target file path.
1079 DCHECK(!full_path.empty()); 1027 DCHECK(!full_path.empty());
1080 target_path_ = full_path; 1028 target_path_ = full_path;
1081 SetFullPath(full_path); 1029 SetFullPath(full_path);
1082 delegate_->DownloadRenamedToFinalName(this); 1030 UpdateObservers();
asanka 2012/09/28 19:02:30 Given that with this change we always call UpdateO
benjhayden 2012/10/01 14:10:03 Done.
1083 1031
1084 // Complete the download and release the DownloadFile. 1032 // Complete the download and release the DownloadFile.
1085 BrowserThread::PostTask( 1033 BrowserThread::PostTask(
1086 BrowserThread::FILE, FROM_HERE, 1034 BrowserThread::FILE, FROM_HERE,
1087 base::Bind(&DownloadFileManager::CompleteDownload, 1035 base::Bind(&DownloadFileManager::CompleteDownload,
1088 delegate_->GetDownloadFileManager(), GetGlobalId(), 1036 delegate_->GetDownloadFileManager(), GetGlobalId(),
1089 base::Bind(&DownloadItemImpl::OnDownloadFileReleased, 1037 base::Bind(&DownloadItemImpl::OnDownloadFileReleased,
1090 weak_ptr_factory_.GetWeakPtr()))); 1038 weak_ptr_factory_.GetWeakPtr())));
1091 TransitionTo(COMPLETING_INTERNAL); 1039 TransitionTo(COMPLETING_INTERNAL);
1092 } 1040 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 return "COMPLETE"; 1229 return "COMPLETE";
1282 case CANCELLED_INTERNAL: 1230 case CANCELLED_INTERNAL:
1283 return "CANCELLED"; 1231 return "CANCELLED";
1284 case INTERRUPTED_INTERNAL: 1232 case INTERRUPTED_INTERNAL:
1285 return "INTERRUPTED"; 1233 return "INTERRUPTED";
1286 default: 1234 default:
1287 NOTREACHED() << "Unknown download state " << state; 1235 NOTREACHED() << "Unknown download state " << state;
1288 return "unknown"; 1236 return "unknown";
1289 }; 1237 };
1290 } 1238 }
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698