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

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 29 matching lines...) Expand all
40 #include "content/browser/download/download_create_info.h" 40 #include "content/browser/download/download_create_info.h"
41 #include "content/browser/download/download_file.h" 41 #include "content/browser/download/download_file.h"
42 #include "content/browser/download/download_file_manager.h" 42 #include "content/browser/download/download_file_manager.h"
43 #include "content/browser/download/download_interrupt_reasons_impl.h" 43 #include "content/browser/download/download_interrupt_reasons_impl.h"
44 #include "content/browser/download/download_item_impl_delegate.h" 44 #include "content/browser/download/download_item_impl_delegate.h"
45 #include "content/browser/download/download_request_handle.h" 45 #include "content/browser/download/download_request_handle.h"
46 #include "content/browser/download/download_stats.h" 46 #include "content/browser/download/download_stats.h"
47 #include "content/browser/web_contents/web_contents_impl.h" 47 #include "content/browser/web_contents/web_contents_impl.h"
48 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
49 #include "content/public/browser/content_browser_client.h" 49 #include "content/public/browser/content_browser_client.h"
50 #include "content/public/browser/download_persistent_store_info.h"
51 #include "net/base/net_util.h" 50 #include "net/base/net_util.h"
52 51
53 using content::BrowserThread; 52 using content::BrowserThread;
54 using content::DownloadFile; 53 using content::DownloadFile;
55 using content::DownloadId; 54 using content::DownloadId;
56 using content::DownloadItem; 55 using content::DownloadItem;
57 using content::DownloadManager; 56 using content::DownloadManager;
58 using content::DownloadPersistentStoreInfo;
59 using content::WebContents; 57 using content::WebContents;
60 58
61 namespace { 59 namespace {
62 60
63 static void DeleteDownloadedFile(const FilePath& path) { 61 static void DeleteDownloadedFile(const FilePath& path) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
65 63
66 // Make sure we only delete files. 64 // Make sure we only delete files.
67 if (!file_util::DirectoryExists(path)) 65 if (!file_util::DirectoryExists(path))
68 file_util::Delete(path, false); 66 file_util::Delete(path, false);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 virtual void CancelRequest() const OVERRIDE {} 117 virtual void CancelRequest() const OVERRIDE {}
120 virtual std::string DebugString() const OVERRIDE { 118 virtual std::string DebugString() const OVERRIDE {
121 return "Null DownloadRequestHandle"; 119 return "Null DownloadRequestHandle";
122 } 120 }
123 }; 121 };
124 122
125 } // namespace 123 } // namespace
126 124
127 namespace content { 125 namespace content {
128 126
129 // Our download table ID starts at 1, so we use 0 to represent a download that
130 // has started, but has not yet had its data persisted in the table. We use fake
131 // database handles in incognito mode starting at -1 and progressively getting
132 // more negative.
133 // static
134 const int DownloadItem::kUninitializedHandle = 0;
135
136 const char DownloadItem::kEmptyFileHash[] = ""; 127 const char DownloadItem::kEmptyFileHash[] = "";
137 128
138 } 129 }
139 130
140 // Our download table ID starts at 1, so we use 0 to represent a download that
141 // has started, but has not yet had its data persisted in the table. We use fake
142 // database handles in incognito mode starting at -1 and progressively getting
143 // more negative.
144
145 // Constructor for reading from the history service. 131 // Constructor for reading from the history service.
146 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 132 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
147 DownloadId download_id, 133 DownloadId download_id,
148 const DownloadPersistentStoreInfo& info, 134 const FilePath& path,
135 const GURL& url,
136 const GURL& referrer_url,
137 const base::Time& start_time,
138 const base::Time& end_time,
139 int64 received_bytes,
140 int64 total_bytes,
141 DownloadItem::DownloadState state,
142 bool opened,
149 const net::BoundNetLog& bound_net_log) 143 const net::BoundNetLog& bound_net_log)
150 : download_id_(download_id), 144 : download_id_(download_id),
151 current_path_(info.path), 145 current_path_(path),
152 target_path_(info.path), 146 target_path_(path),
153 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 147 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
154 url_chain_(1, info.url), 148 url_chain_(1, url),
155 referrer_url_(info.referrer_url), 149 referrer_url_(referrer_url),
156 transition_type_(content::PAGE_TRANSITION_LINK), 150 transition_type_(content::PAGE_TRANSITION_LINK),
157 has_user_gesture_(false), 151 has_user_gesture_(false),
158 total_bytes_(info.total_bytes), 152 total_bytes_(total_bytes),
159 received_bytes_(info.received_bytes), 153 received_bytes_(received_bytes),
160 bytes_per_sec_(0), 154 bytes_per_sec_(0),
161 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 155 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
162 start_tick_(base::TimeTicks()), 156 start_tick_(base::TimeTicks()),
163 state_(info.state), 157 state_(state),
164 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 158 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
165 start_time_(info.start_time), 159 start_time_(start_time),
166 end_time_(info.end_time), 160 end_time_(end_time),
167 db_handle_(info.db_handle),
168 delegate_(delegate), 161 delegate_(delegate),
169 is_paused_(false), 162 is_paused_(false),
170 open_when_complete_(false), 163 open_when_complete_(false),
171 file_externally_removed_(false), 164 file_externally_removed_(false),
172 safety_state_(SAFE), 165 safety_state_(SAFE),
173 auto_opened_(false), 166 auto_opened_(false),
174 is_persisted_(true),
175 is_temporary_(false), 167 is_temporary_(false),
176 all_data_saved_(false), 168 all_data_saved_(false),
177 opened_(info.opened), 169 opened_(opened),
178 open_enabled_(true), 170 open_enabled_(true),
179 delegate_delayed_complete_(false), 171 delegate_delayed_complete_(false),
180 bound_net_log_(bound_net_log), 172 bound_net_log_(bound_net_log),
181 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 173 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
182 delegate_->Attach(); 174 delegate_->Attach();
183 if (IsInProgress()) 175 if (IsInProgress())
184 state_ = CANCELLED; 176 state_ = CANCELLED;
185 if (IsComplete()) 177 if (IsComplete())
186 all_data_saved_ = true; 178 all_data_saved_ = true;
187 Init(false /* not actively downloading */, 179 Init(false /* not actively downloading */,
(...skipping 23 matching lines...) Expand all
211 referrer_charset_(info.referrer_charset), 203 referrer_charset_(info.referrer_charset),
212 remote_address_(info.remote_address), 204 remote_address_(info.remote_address),
213 total_bytes_(info.total_bytes), 205 total_bytes_(info.total_bytes),
214 received_bytes_(0), 206 received_bytes_(0),
215 bytes_per_sec_(0), 207 bytes_per_sec_(0),
216 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 208 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
217 start_tick_(base::TimeTicks::Now()), 209 start_tick_(base::TimeTicks::Now()),
218 state_(IN_PROGRESS), 210 state_(IN_PROGRESS),
219 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 211 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
220 start_time_(info.start_time), 212 start_time_(info.start_time),
221 db_handle_(DownloadItem::kUninitializedHandle),
222 delegate_(delegate), 213 delegate_(delegate),
223 is_paused_(false), 214 is_paused_(false),
224 open_when_complete_(false), 215 open_when_complete_(false),
225 file_externally_removed_(false), 216 file_externally_removed_(false),
226 safety_state_(SAFE), 217 safety_state_(SAFE),
227 auto_opened_(false), 218 auto_opened_(false),
228 is_persisted_(false),
229 is_temporary_(!info.save_info.file_path.empty()), 219 is_temporary_(!info.save_info.file_path.empty()),
230 all_data_saved_(false), 220 all_data_saved_(false),
231 opened_(false), 221 opened_(false),
232 open_enabled_(true), 222 open_enabled_(true),
233 delegate_delayed_complete_(false), 223 delegate_delayed_complete_(false),
234 bound_net_log_(bound_net_log), 224 bound_net_log_(bound_net_log),
235 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 225 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
236 delegate_->Attach(); 226 delegate_->Attach();
237 Init(true /* actively downloading */, 227 Init(true /* actively downloading */,
238 download_net_logs::SRC_NEW_DOWNLOAD); 228 download_net_logs::SRC_NEW_DOWNLOAD);
(...skipping 27 matching lines...) Expand all
266 mime_type_(mime_type), 256 mime_type_(mime_type),
267 original_mime_type_(mime_type), 257 original_mime_type_(mime_type),
268 total_bytes_(0), 258 total_bytes_(0),
269 received_bytes_(0), 259 received_bytes_(0),
270 bytes_per_sec_(0), 260 bytes_per_sec_(0),
271 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 261 last_reason_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
272 start_tick_(base::TimeTicks::Now()), 262 start_tick_(base::TimeTicks::Now()),
273 state_(IN_PROGRESS), 263 state_(IN_PROGRESS),
274 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 264 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
275 start_time_(base::Time::Now()), 265 start_time_(base::Time::Now()),
276 db_handle_(DownloadItem::kUninitializedHandle),
277 delegate_(delegate), 266 delegate_(delegate),
278 is_paused_(false), 267 is_paused_(false),
279 open_when_complete_(false), 268 open_when_complete_(false),
280 file_externally_removed_(false), 269 file_externally_removed_(false),
281 safety_state_(SAFE), 270 safety_state_(SAFE),
282 auto_opened_(false), 271 auto_opened_(false),
283 is_persisted_(false),
284 is_temporary_(false), 272 is_temporary_(false),
285 all_data_saved_(false), 273 all_data_saved_(false),
286 opened_(false), 274 opened_(false),
287 open_enabled_(true), 275 open_enabled_(true),
288 delegate_delayed_complete_(false), 276 delegate_delayed_complete_(false),
289 bound_net_log_(bound_net_log), 277 bound_net_log_(bound_net_log),
290 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 278 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
291 delegate_->Attach(); 279 delegate_->Attach();
292 Init(true /* actively downloading */, 280 Init(true /* actively downloading */,
293 download_net_logs::SRC_SAVE_PAGE_AS); 281 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 436 }
449 437
450 int32 DownloadItemImpl::GetId() const { 438 int32 DownloadItemImpl::GetId() const {
451 return download_id_.local(); 439 return download_id_.local();
452 } 440 }
453 441
454 DownloadId DownloadItemImpl::GetGlobalId() const { 442 DownloadId DownloadItemImpl::GetGlobalId() const {
455 return download_id_; 443 return download_id_;
456 } 444 }
457 445
458 int64 DownloadItemImpl::GetDbHandle() const {
459 return db_handle_;
460 }
461
462 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 446 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
463 return state_; 447 return state_;
464 } 448 }
465 449
466 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 450 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
467 return last_reason_; 451 return last_reason_;
468 } 452 }
469 453
470 bool DownloadItemImpl::IsPaused() const { 454 bool DownloadItemImpl::IsPaused() const {
471 return is_paused_; 455 return is_paused_;
472 } 456 }
473 457
474 bool DownloadItemImpl::IsTemporary() const { 458 bool DownloadItemImpl::IsTemporary() const {
475 return is_temporary_; 459 return is_temporary_;
476 } 460 }
477 461
478 bool DownloadItemImpl::IsPersisted() const {
479 return is_persisted_;
480 }
481
482 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to 462 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to
483 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. 463 // |IsPartialDownload()|, when resuming interrupted downloads is implemented.
484 bool DownloadItemImpl::IsPartialDownload() const { 464 bool DownloadItemImpl::IsPartialDownload() const {
485 return (state_ == IN_PROGRESS); 465 return (state_ == IN_PROGRESS);
486 } 466 }
487 467
488 bool DownloadItemImpl::IsInProgress() const { 468 bool DownloadItemImpl::IsInProgress() const {
489 return (state_ == IN_PROGRESS); 469 return (state_ == IN_PROGRESS);
490 } 470 }
491 471
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 return true; 705 return true;
726 } 706 }
727 707
728 // TODO(asanka): Change this to GetTargetFilePath() once DownloadQuery has 708 // TODO(asanka): Change this to GetTargetFilePath() once DownloadQuery has
729 // been modified to work with target paths. 709 // been modified to work with target paths.
730 string16 path(GetFullPath().LossyDisplayName()); 710 string16 path(GetFullPath().LossyDisplayName());
731 return base::i18n::StringSearchIgnoringCaseAndAccents( 711 return base::i18n::StringSearchIgnoringCaseAndAccents(
732 query, path, NULL, NULL); 712 query, path, NULL, NULL);
733 } 713 }
734 714
735 DownloadPersistentStoreInfo DownloadItemImpl::GetPersistentStoreInfo() const {
736 // TODO(asanka): Persist GetTargetFilePath() as well.
737 return DownloadPersistentStoreInfo(GetFullPath(),
738 GetURL(),
739 GetReferrerUrl(),
740 GetStartTime(),
741 GetEndTime(),
742 GetReceivedBytes(),
743 GetTotalBytes(),
744 GetState(),
745 GetDbHandle(),
746 GetOpened());
747 }
748
749 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const { 715 content::BrowserContext* DownloadItemImpl::GetBrowserContext() const {
750 return delegate_->GetBrowserContext(); 716 return delegate_->GetBrowserContext();
751 } 717 }
752 718
753 WebContents* DownloadItemImpl::GetWebContents() const { 719 WebContents* DownloadItemImpl::GetWebContents() const {
754 // TODO(rdsmith): Remove null check after removing GetWebContents() from 720 // TODO(rdsmith): Remove null check after removing GetWebContents() from
755 // paths that might be used by DownloadItems created from history import. 721 // paths that might be used by DownloadItems created from history import.
756 // Currently such items have null request_handle_s, where other items 722 // Currently such items have null request_handle_s, where other items
757 // (regular and SavePackage downloads) have actual objects off the pointer. 723 // (regular and SavePackage downloads) have actual objects off the pointer.
758 if (request_handle_.get()) 724 if (request_handle_.get())
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 ++iter; 766 ++iter;
801 for ( ; verbose && (iter != last); ++iter) { 767 for ( ; verbose && (iter != last); ++iter) {
802 url_list += " ->\n\t"; 768 url_list += " ->\n\t";
803 const GURL& next_url = *iter; 769 const GURL& next_url = *iter;
804 url_list += next_url.spec(); 770 url_list += next_url.spec();
805 } 771 }
806 } 772 }
807 773
808 if (verbose) { 774 if (verbose) {
809 description += base::StringPrintf( 775 description += base::StringPrintf(
810 " db_handle = %" PRId64
811 " total = %" PRId64 776 " total = %" PRId64
812 " received = %" PRId64 777 " received = %" PRId64
813 " reason = %s" 778 " reason = %s"
814 " paused = %c" 779 " paused = %c"
815 " safety = %s" 780 " safety = %s"
816 " last_modified = '%s'" 781 " last_modified = '%s'"
817 " etag = '%s'" 782 " etag = '%s'"
818 " url_chain = \n\t\"%s\"\n\t" 783 " url_chain = \n\t\"%s\"\n\t"
819 " full_path = \"%" PRFilePath "\"" 784 " full_path = \"%" PRFilePath "\""
820 " target_path = \"%" PRFilePath "\"", 785 " target_path = \"%" PRFilePath "\"",
821 GetDbHandle(),
822 GetTotalBytes(), 786 GetTotalBytes(),
823 GetReceivedBytes(), 787 GetReceivedBytes(),
824 InterruptReasonDebugString(last_reason_).c_str(), 788 InterruptReasonDebugString(last_reason_).c_str(),
825 IsPaused() ? 'T' : 'F', 789 IsPaused() ? 'T' : 'F',
826 DebugSafetyStateString(GetSafetyState()), 790 DebugSafetyStateString(GetSafetyState()),
827 GetLastModifiedTime().c_str(), 791 GetLastModifiedTime().c_str(),
828 GetETag().c_str(), 792 GetETag().c_str(),
829 url_list.c_str(), 793 url_list.c_str(),
830 GetFullPath().value().c_str(), 794 GetFullPath().value().c_str(),
831 GetTargetFilePath().value().c_str()); 795 GetTargetFilePath().value().c_str());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 } 900 }
937 901
938 void DownloadItemImpl::MarkAsComplete() { 902 void DownloadItemImpl::MarkAsComplete() {
939 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 903 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
940 904
941 DCHECK(all_data_saved_); 905 DCHECK(all_data_saved_);
942 end_time_ = base::Time::Now(); 906 end_time_ = base::Time::Now();
943 TransitionTo(COMPLETE); 907 TransitionTo(COMPLETE);
944 } 908 }
945 909
946 void DownloadItemImpl::SetIsPersisted() {
947 is_persisted_ = true;
948 }
949
950 void DownloadItemImpl::SetDbHandle(int64 handle) {
951 db_handle_ = handle;
952
953 bound_net_log_.AddEvent(
954 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY,
955 net::NetLog::Int64Callback("db_handle", db_handle_));
956 }
957
958 // **** Download progression cascade 910 // **** Download progression cascade
959 911
960 void DownloadItemImpl::Init(bool active, 912 void DownloadItemImpl::Init(bool active,
961 download_net_logs::DownloadType download_type) { 913 download_net_logs::DownloadType download_type) {
962 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 914 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
963 915
964 if (active) 916 if (active)
965 download_stats::RecordDownloadCount(download_stats::START_COUNT); 917 download_stats::RecordDownloadCount(download_stats::START_COUNT);
966 918
967 if (target_path_.empty()) 919 if (target_path_.empty())
968 target_path_ = current_path_; 920 target_path_ = current_path_;
969 std::string file_name; 921 std::string file_name;
970 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) { 922 if (download_type == download_net_logs::SRC_HISTORY_IMPORT) {
971 // target_path_ works for History and Save As versions. 923 // target_path_ works for History and Save As versions.
972 file_name = target_path_.AsUTF8Unsafe(); 924 file_name = target_path_.AsUTF8Unsafe();
973 } else { 925 } else {
974 // See if it's set programmatically. 926 // See if it's set programmatically.
975 file_name = forced_file_path_.AsUTF8Unsafe(); 927 file_name = forced_file_path_.AsUTF8Unsafe();
976 // Possibly has a 'download' attribute for the anchor. 928 // Possibly has a 'download' attribute for the anchor.
977 if (file_name.empty()) 929 if (file_name.empty())
978 file_name = suggested_filename_; 930 file_name = suggested_filename_;
979 // From the URL file name. 931 // From the URL file name.
980 if (file_name.empty()) 932 if (file_name.empty())
981 file_name = GetURL().ExtractFileName(); 933 file_name = GetURL().ExtractFileName();
982 } 934 }
983 935
984 bound_net_log_.BeginEvent( 936 if (active) {
Randy Smith (Not in Mondays) 2012/09/13 19:53:19 There's enough duplicated code here (like, all of
benjhayden 2012/09/21 20:45:46 I named the callback instead. How does it look now
Randy Smith (Not in Mondays) 2012/09/24 18:03:25 Looks good.
985 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, 937 bound_net_log_.BeginEvent(
986 base::Bind(&download_net_logs::ItemActivatedCallback, 938 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE,
987 this, download_type, &file_name)); 939 base::Bind(&download_net_logs::ItemActivatedCallback,
988 940 this, download_type, &file_name));
989 // If this is not an active download, end the ACTIVE event now. 941 } else {
990 if (!active) {
991 bound_net_log_.AddEvent( 942 bound_net_log_.AddEvent(
992 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, 943 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE,
993 net::NetLog::Int64Callback("db_handle", db_handle_)); 944 base::Bind(&download_net_logs::ItemActivatedCallback,
994 945 this, download_type, &file_name));
995 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE);
996 } 946 }
997 947
998 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); 948 VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
999 } 949 }
1000 950
1001 // Called by DownloadManagerImpl when the download target path has been 951 // Called by DownloadManagerImpl when the download target path has been
1002 // determined. 952 // determined.
1003 void DownloadItemImpl::OnDownloadTargetDetermined( 953 void DownloadItemImpl::OnDownloadTargetDetermined(
1004 const FilePath& target_path, 954 const FilePath& target_path,
1005 TargetDisposition disposition, 955 TargetDisposition disposition,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 1052
1103 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) { 1053 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
1104 Interrupt(reason); 1054 Interrupt(reason);
1105 return; 1055 return;
1106 } 1056 }
1107 1057
1108 // full_path is now the current and target file path. 1058 // full_path is now the current and target file path.
1109 DCHECK(!full_path.empty()); 1059 DCHECK(!full_path.empty());
1110 target_path_ = full_path; 1060 target_path_ = full_path;
1111 SetFullPath(full_path); 1061 SetFullPath(full_path);
1112 delegate_->DownloadRenamedToFinalName(this); 1062 UpdateObservers();
1113 1063
1114 // Complete the download and release the DownloadFile. 1064 // Complete the download and release the DownloadFile.
1115 BrowserThread::PostTask( 1065 BrowserThread::PostTask(
1116 BrowserThread::FILE, FROM_HERE, 1066 BrowserThread::FILE, FROM_HERE,
1117 base::Bind(&DownloadFileManager::CompleteDownload, 1067 base::Bind(&DownloadFileManager::CompleteDownload,
1118 delegate_->GetDownloadFileManager(), GetGlobalId(), 1068 delegate_->GetDownloadFileManager(), GetGlobalId(),
1119 base::Bind(&DownloadItemImpl::OnDownloadFileReleased, 1069 base::Bind(&DownloadItemImpl::OnDownloadFileReleased,
1120 weak_ptr_factory_.GetWeakPtr()))); 1070 weak_ptr_factory_.GetWeakPtr())));
1121 } 1071 }
1122 1072
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 1196
1247 bound_net_log_.AddEvent( 1197 bound_net_log_.AddEvent(
1248 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, 1198 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED,
1249 base::Bind(&download_net_logs::ItemRenamedCallback, 1199 base::Bind(&download_net_logs::ItemRenamedCallback,
1250 &current_path_, &new_path)); 1200 &current_path_, &new_path));
1251 } 1201 }
1252 1202
1253 1203
1254 1204
1255 1205
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698