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

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: . Created 8 years, 3 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 virtual void CancelRequest() const OVERRIDE {} 115 virtual void CancelRequest() const OVERRIDE {}
118 virtual std::string DebugString() const OVERRIDE { 116 virtual std::string DebugString() const OVERRIDE {
119 return "Null DownloadRequestHandle"; 117 return "Null DownloadRequestHandle";
120 } 118 }
121 }; 119 };
122 120
123 } // namespace 121 } // namespace
124 122
125 namespace content { 123 namespace content {
126 124
127 // Our download table ID starts at 1, so we use 0 to represent a download that
128 // has started, but has not yet had its data persisted in the table. We use fake
129 // database handles in incognito mode starting at -1 and progressively getting
130 // more negative.
131 // static
132 const int DownloadItem::kUninitializedHandle = 0;
133
134 const char DownloadItem::kEmptyFileHash[] = ""; 125 const char DownloadItem::kEmptyFileHash[] = "";
135 126
136 } 127 }
137 128
138 // Our download table ID starts at 1, so we use 0 to represent a download that
139 // has started, but has not yet had its data persisted in the table. We use fake
140 // database handles in incognito mode starting at -1 and progressively getting
141 // more negative.
142
143 // Constructor for reading from the history service. 129 // Constructor for reading from the history service.
144 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 130 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
145 DownloadId download_id, 131 DownloadId download_id,
146 const DownloadPersistentStoreInfo& info, 132 const FilePath& path,
133 const GURL& url,
134 const GURL& referrer_url,
135 const base::Time& start_time,
136 const base::Time& end_time,
137 int64 received_bytes,
138 int64 total_bytes,
139 DownloadItem::DownloadState state,
140 bool opened,
147 const net::BoundNetLog& bound_net_log) 141 const net::BoundNetLog& bound_net_log)
148 : download_id_(download_id), 142 : download_id_(download_id),
149 current_path_(info.path), 143 current_path_(path),
150 target_path_(info.path), 144 target_path_(path),
151 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 145 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
152 url_chain_(1, info.url), 146 url_chain_(1, url),
153 referrer_url_(info.referrer_url), 147 referrer_url_(referrer_url),
154 transition_type_(content::PAGE_TRANSITION_LINK), 148 transition_type_(content::PAGE_TRANSITION_LINK),
155 has_user_gesture_(false), 149 has_user_gesture_(false),
156 total_bytes_(info.total_bytes), 150 total_bytes_(total_bytes),
157 received_bytes_(info.received_bytes), 151 received_bytes_(received_bytes),
158 bytes_per_sec_(0), 152 bytes_per_sec_(0),
159 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 153 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
160 start_tick_(base::TimeTicks()), 154 start_tick_(base::TimeTicks()),
161 state_(info.state), 155 state_(state),
162 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 156 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
163 start_time_(info.start_time), 157 start_time_(start_time),
164 end_time_(info.end_time), 158 end_time_(end_time),
165 db_handle_(info.db_handle),
166 delegate_(delegate), 159 delegate_(delegate),
167 is_paused_(false), 160 is_paused_(false),
168 open_when_complete_(false), 161 open_when_complete_(false),
169 file_externally_removed_(false), 162 file_externally_removed_(false),
170 safety_state_(SAFE), 163 safety_state_(SAFE),
171 auto_opened_(false), 164 auto_opened_(false),
172 is_persisted_(true),
173 is_temporary_(false), 165 is_temporary_(false),
174 all_data_saved_(false), 166 all_data_saved_(false),
175 opened_(info.opened), 167 opened_(opened),
176 open_enabled_(true), 168 open_enabled_(true),
177 delegate_delayed_complete_(false), 169 delegate_delayed_complete_(false),
178 bound_net_log_(bound_net_log), 170 bound_net_log_(bound_net_log),
179 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 171 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
180 delegate_->Attach(); 172 delegate_->Attach();
181 if (IsInProgress()) 173 if (IsInProgress())
182 state_ = CANCELLED; 174 state_ = CANCELLED;
183 if (IsComplete()) 175 if (IsComplete())
184 all_data_saved_ = true; 176 all_data_saved_ = true;
185 Init(false /* not actively downloading */, 177 Init(false /* not actively downloading */,
(...skipping 23 matching lines...) Expand all
209 referrer_charset_(info.referrer_charset), 201 referrer_charset_(info.referrer_charset),
210 remote_address_(info.remote_address), 202 remote_address_(info.remote_address),
211 total_bytes_(info.total_bytes), 203 total_bytes_(info.total_bytes),
212 received_bytes_(0), 204 received_bytes_(0),
213 bytes_per_sec_(0), 205 bytes_per_sec_(0),
214 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 206 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
215 start_tick_(base::TimeTicks::Now()), 207 start_tick_(base::TimeTicks::Now()),
216 state_(IN_PROGRESS), 208 state_(IN_PROGRESS),
217 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 209 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
218 start_time_(info.start_time), 210 start_time_(info.start_time),
219 db_handle_(DownloadItem::kUninitializedHandle),
220 delegate_(delegate), 211 delegate_(delegate),
221 is_paused_(false), 212 is_paused_(false),
222 open_when_complete_(false), 213 open_when_complete_(false),
223 file_externally_removed_(false), 214 file_externally_removed_(false),
224 safety_state_(SAFE), 215 safety_state_(SAFE),
225 auto_opened_(false), 216 auto_opened_(false),
226 is_persisted_(false),
227 is_temporary_(!info.save_info.file_path.empty()), 217 is_temporary_(!info.save_info.file_path.empty()),
228 all_data_saved_(false), 218 all_data_saved_(false),
229 opened_(false), 219 opened_(false),
230 open_enabled_(true), 220 open_enabled_(true),
231 delegate_delayed_complete_(false), 221 delegate_delayed_complete_(false),
232 bound_net_log_(bound_net_log), 222 bound_net_log_(bound_net_log),
233 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 223 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
234 delegate_->Attach(); 224 delegate_->Attach();
235 Init(true /* actively downloading */, 225 Init(true /* actively downloading */,
236 download_net_logs::SRC_NEW_DOWNLOAD); 226 download_net_logs::SRC_NEW_DOWNLOAD);
(...skipping 27 matching lines...) Expand all
264 mime_type_(mime_type), 254 mime_type_(mime_type),
265 original_mime_type_(mime_type), 255 original_mime_type_(mime_type),
266 total_bytes_(0), 256 total_bytes_(0),
267 received_bytes_(0), 257 received_bytes_(0),
268 bytes_per_sec_(0), 258 bytes_per_sec_(0),
269 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 259 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
270 start_tick_(base::TimeTicks::Now()), 260 start_tick_(base::TimeTicks::Now()),
271 state_(IN_PROGRESS), 261 state_(IN_PROGRESS),
272 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 262 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
273 start_time_(base::Time::Now()), 263 start_time_(base::Time::Now()),
274 db_handle_(DownloadItem::kUninitializedHandle),
275 delegate_(delegate), 264 delegate_(delegate),
276 is_paused_(false), 265 is_paused_(false),
277 open_when_complete_(false), 266 open_when_complete_(false),
278 file_externally_removed_(false), 267 file_externally_removed_(false),
279 safety_state_(SAFE), 268 safety_state_(SAFE),
280 auto_opened_(false), 269 auto_opened_(false),
281 is_persisted_(false),
282 is_temporary_(false), 270 is_temporary_(false),
283 all_data_saved_(false), 271 all_data_saved_(false),
284 opened_(false), 272 opened_(false),
285 open_enabled_(true), 273 open_enabled_(true),
286 delegate_delayed_complete_(false), 274 delegate_delayed_complete_(false),
287 bound_net_log_(bound_net_log), 275 bound_net_log_(bound_net_log),
288 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 276 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
289 delegate_->Attach(); 277 delegate_->Attach();
290 Init(true /* actively downloading */, 278 Init(true /* actively downloading */,
291 download_net_logs::SRC_SAVE_PAGE_AS); 279 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 434 }
447 435
448 int32 DownloadItemImpl::GetId() const { 436 int32 DownloadItemImpl::GetId() const {
449 return download_id_.local(); 437 return download_id_.local();
450 } 438 }
451 439
452 DownloadId DownloadItemImpl::GetGlobalId() const { 440 DownloadId DownloadItemImpl::GetGlobalId() const {
453 return download_id_; 441 return download_id_;
454 } 442 }
455 443
456 int64 DownloadItemImpl::GetDbHandle() const {
457 return db_handle_;
458 }
459
460 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 444 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
461 return state_; 445 return state_;
462 } 446 }
463 447
464 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 448 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
465 return last_reason_; 449 return last_reason_;
466 } 450 }
467 451
468 bool DownloadItemImpl::IsPaused() const { 452 bool DownloadItemImpl::IsPaused() const {
469 return is_paused_; 453 return is_paused_;
470 } 454 }
471 455
472 bool DownloadItemImpl::IsTemporary() const { 456 bool DownloadItemImpl::IsTemporary() const {
473 return is_temporary_; 457 return is_temporary_;
474 } 458 }
475 459
476 bool DownloadItemImpl::IsPersisted() const {
477 return is_persisted_;
478 }
479
480 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to 460 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to
481 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. 461 // |IsPartialDownload()|, when resuming interrupted downloads is implemented.
482 bool DownloadItemImpl::IsPartialDownload() const { 462 bool DownloadItemImpl::IsPartialDownload() const {
483 return (state_ == IN_PROGRESS); 463 return (state_ == IN_PROGRESS);
484 } 464 }
485 465
486 bool DownloadItemImpl::IsInProgress() const { 466 bool DownloadItemImpl::IsInProgress() const {
487 return (state_ == IN_PROGRESS); 467 return (state_ == IN_PROGRESS);
488 } 468 }
489 469
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 } 666 }
687 667
688 bool DownloadItemImpl::GetAutoOpened() { 668 bool DownloadItemImpl::GetAutoOpened() {
689 return auto_opened_; 669 return auto_opened_;
690 } 670 }
691 671
692 bool DownloadItemImpl::GetOpened() const { 672 bool DownloadItemImpl::GetOpened() const {
693 return opened_; 673 return opened_;
694 } 674 }
695 675
696 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
697 // TODO(asanka): Persist GetTargetFilePath() as well.
698 return DownloadPersistentStoreInfo(GetFullPath(),
699 GetURL(),
700 GetReferrerUrl(),
701 GetStartTime(),
702 GetEndTime(),
703 GetReceivedBytes(),
704 GetTotalBytes(),
705 GetState(),
706 GetDbHandle(),
707 GetOpened());
708 }
709
710 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const { 676 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const {
711 return delegate_->GetBrowserContext(); 677 return delegate_->GetBrowserContext();
712 } 678 }
713 679
714 WebContents* DownloadItemImpl::GetWebContents() const { 680 WebContents* DownloadItemImpl::GetWebContents() const {
715 // TODO(rdsmith): Remove null check after removing GetWebContents() from 681 // TODO(rdsmith): Remove null check after removing GetWebContents() from
716 // paths that might be used by DownloadItems created from history import. 682 // paths that might be used by DownloadItems created from history import.
717 // Currently such items have null request_handle_s, where other items 683 // Currently such items have null request_handle_s, where other items
718 // (regular and SavePackage downloads) have actual objects off the pointer. 684 // (regular and SavePackage downloads) have actual objects off the pointer.
719 if (request_handle_.get()) 685 if (request_handle_.get())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 ++iter; 727 ++iter;
762 for ( ; verbose && (iter != last); ++iter) { 728 for ( ; verbose && (iter != last); ++iter) {
763 url_list += " ->\n\t"; 729 url_list += " ->\n\t";
764 const GURL& next_url = *iter; 730 const GURL& next_url = *iter;
765 url_list += next_url.spec(); 731 url_list += next_url.spec();
766 } 732 }
767 } 733 }
768 734
769 if (verbose) { 735 if (verbose) {
770 description += base::StringPrintf( 736 description += base::StringPrintf(
771 " db_handle = %" PRId64
772 " total = %" PRId64 737 " total = %" PRId64
773 " received = %" PRId64 738 " received = %" PRId64
774 " reason = %s" 739 " reason = %s"
775 " paused = %c" 740 " paused = %c"
776 " safety = %s" 741 " safety = %s"
777 " last_modified = '%s'" 742 " last_modified = '%s'"
778 " etag = '%s'" 743 " etag = '%s'"
779 " url_chain = \n\t\"%s\"\n\t" 744 " url_chain = \n\t\"%s\"\n\t"
780 " full_path = \"%" PRFilePath "\"" 745 " full_path = \"%" PRFilePath "\""
781 " target_path = \"%" PRFilePath "\"", 746 " target_path = \"%" PRFilePath "\"",
782 GetDbHandle(),
783 GetTotalBytes(), 747 GetTotalBytes(),
784 GetReceivedBytes(), 748 GetReceivedBytes(),
785 InterruptReasonDebugString(last_reason_).c_str(), 749 InterruptReasonDebugString(last_reason_).c_str(),
786 IsPaused() ? 'T' : 'F', 750 IsPaused() ? 'T' : 'F',
787 DebugSafetyStateString(GetSafetyState()), 751 DebugSafetyStateString(GetSafetyState()),
788 GetLastModifiedTime().c_str(), 752 GetLastModifiedTime().c_str(),
789 GetETag().c_str(), 753 GetETag().c_str(),
790 url_list.c_str(), 754 url_list.c_str(),
791 GetFullPath().value().c_str(), 755 GetFullPath().value().c_str(),
792 GetTargetFilePath().value().c_str()); 756 GetTargetFilePath().value().c_str());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 } 861 }
898 862
899 void DownloadItemImpl::MarkAsComplete() { 863 void DownloadItemImpl::MarkAsComplete() {
900 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 864 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
901 865
902 DCHECK(all_data_saved_); 866 DCHECK(all_data_saved_);
903 end_time_ = base::Time::Now(); 867 end_time_ = base::Time::Now();
904 TransitionTo(COMPLETE); 868 TransitionTo(COMPLETE);
905 } 869 }
906 870
907 void DownloadItemImpl::SetIsPersisted() {
908 is_persisted_ = true;
909 UpdateObservers();
910 }
911
912 void DownloadItemImpl::SetDbHandle(int64 handle) {
913 db_handle_ = handle;
914
915 bound_net_log_.AddEvent(
916 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
917 net::NetLog::Int64Callback("db_handle", db_handle_));
918 }
919
920 // **** Download progression cascade 871 // **** Download progression cascade
921 872
922 void DownloadItemImpl::Init(bool active, 873 void DownloadItemImpl::Init(bool active,
923 download_net_logs::DownloadType download_type) { 874 download_net_logs::DownloadType download_type) {
924 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
925 876
926 if (active) 877 if (active)
927 download_stats::RecordDownloadCount(download_stats::START_COUNT); 878 download_stats::RecordDownloadCount(download_stats::START_COUNT);
928 879
929 if (target_path_.empty()) 880 if (target_path_.empty())
930 target_path_ = current_path_; 881 target_path_ = current_path_;
931 std::string file_name; 882 std::string file_name;
932 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) { 883 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) {
933 // target_path_ works for History and Save As versions. 884 // target_path_ works for History and Save As versions.
934 file_name = target_path_.AsUTF8Unsafe(); 885 file_name = target_path_.AsUTF8Unsafe();
935 } else { 886 } else {
936 // See if it's set programmatically. 887 // See if it's set programmatically.
937 file_name = forced_file_path_.AsUTF8Unsafe(); 888 file_name = forced_file_path_.AsUTF8Unsafe();
938 // Possibly has a 'download' attribute for the anchor. 889 // Possibly has a 'download' attribute for the anchor.
939 if (file_name.empty()) 890 if (file_name.empty())
940 file_name = suggested_filename_; 891 file_name = suggested_filename_;
941 // From the URL file name. 892 // From the URL file name.
942 if (file_name.empty()) 893 if (file_name.empty())
943 file_name = GetURL().ExtractFileName(); 894 file_name = GetURL().ExtractFileName();
944 } 895 }
945 896
946 bound_net_log_.BeginEvent( 897 base::Callback<base::Value*(net::NetLog::LogLevel)> active_data = base::Bind(
947 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 898 &download_net_logs::ItemActivatedCallback, this,
948 base::Bind(&download_net_logs::ItemActivatedCallback, 899 download_type, &file_name);
949 this, download_type, &file_name)); 900 if (active) {
950 901 bound_net_log_.BeginEvent(
951 // If this is not an active download, end the ACTIVE event now. 902 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
952 if (!active) { 903 } else {
953 bound_net_log_.AddEvent( 904 bound_net_log_.AddEvent(
954 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 905 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, active_data);
955 net::NetLog::Int64Callback("db_handle", db_handle_));
956
957 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
958 } 906 }
959 907
960 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 908 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
961 } 909 }
962 910
963 // Called by DownloadManagerImpl when the download target path has been 911 // Called by DownloadManagerImpl when the download target path has been
964 // determined. 912 // determined.
965 void DownloadItemImpl::OnDownloadTargetDetermined( 913 void DownloadItemImpl::OnDownloadTargetDetermined(
966 const FilePath& target_path, 914 const FilePath& target_path,
967 TargetDisposition disposition, 915 TargetDisposition disposition,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1012
1065 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) { 1013 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
1066 Interrupt(reason); 1014 Interrupt(reason);
1067 return; 1015 return;
1068 } 1016 }
1069 1017
1070 // full_path is now the current and target file path. 1018 // full_path is now the current and target file path.
1071 DCHECK(!full_path.empty()); 1019 DCHECK(!full_path.empty());
1072 target_path_ = full_path; 1020 target_path_ = full_path;
1073 SetFullPath(full_path); 1021 SetFullPath(full_path);
1074 delegate_->DownloadRenamedToFinalName(this); 1022 UpdateObservers();
1075 1023
1076 // Complete the download and release the DownloadFile. 1024 // Complete the download and release the DownloadFile.
1077 BrowserThread::PostTask( 1025 BrowserThread::PostTask(
1078 BrowserThread::FILE, FROM_HERE, 1026 BrowserThread::FILE, FROM_HERE,
1079 base::Bind(&DownloadFileManager::CompleteDownload, 1027 base::Bind(&DownloadFileManager::CompleteDownload,
1080 delegate_->GetDownloadFileManager(), GetGlobalId(), 1028 delegate_->GetDownloadFileManager(), GetGlobalId(),
1081 base::Bind(&DownloadItemImpl::OnDownloadFileReleased, 1029 base::Bind(&DownloadItemImpl::OnDownloadFileReleased,
1082 weak_ptr_factory_.GetWeakPtr()))); 1030 weak_ptr_factory_.GetWeakPtr())));
1083 } 1031 }
1084 1032
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 1156
1209 bound_net_log_.AddEvent( 1157 bound_net_log_.AddEvent(
1210 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, 1158 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED,
1211 base::Bind(&download_net_logs::ItemRenamedCallback, 1159 base::Bind(&download_net_logs::ItemRenamedCallback,
1212 &current_path_, &new_path)); 1160 &current_path_, &new_path));
1213 } 1161 }
1214 1162
1215 1163
1216 1164
1217 1165
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698