OLD | NEW |
---|---|
1 // Copyright (c) 2011 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 #include "content/browser/download/download_item_impl.h" | 5 #include "content/browser/download/download_item_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 | 154 |
155 // Our download table ID starts at 1, so we use 0 to represent a download that | 155 // Our download table ID starts at 1, so we use 0 to represent a download that |
156 // has started, but has not yet had its data persisted in the table. We use fake | 156 // has started, but has not yet had its data persisted in the table. We use fake |
157 // database handles in incognito mode starting at -1 and progressively getting | 157 // database handles in incognito mode starting at -1 and progressively getting |
158 // more negative. | 158 // more negative. |
159 | 159 |
160 // Constructor for reading from the history service. | 160 // Constructor for reading from the history service. |
161 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, | 161 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, |
162 DownloadId download_id, | 162 DownloadId download_id, |
163 const DownloadPersistentStoreInfo& info) | 163 const DownloadPersistentStoreInfo& info, |
164 net::NetLog* net_log) | |
164 : download_id_(download_id), | 165 : download_id_(download_id), |
165 full_path_(info.path), | 166 full_path_(info.path), |
166 url_chain_(1, info.url), | 167 url_chain_(1, info.url), |
167 referrer_url_(info.referrer_url), | 168 referrer_url_(info.referrer_url), |
168 total_bytes_(info.total_bytes), | 169 total_bytes_(info.total_bytes), |
169 received_bytes_(info.received_bytes), | 170 received_bytes_(info.received_bytes), |
170 bytes_per_sec_(0), | 171 bytes_per_sec_(0), |
171 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), | 172 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), |
172 start_tick_(base::TimeTicks()), | 173 start_tick_(base::TimeTicks()), |
173 state_(static_cast<DownloadState>(info.state)), | 174 state_(static_cast<DownloadState>(info.state)), |
174 start_time_(info.start_time), | 175 start_time_(info.start_time), |
175 end_time_(info.end_time), | 176 end_time_(info.end_time), |
176 db_handle_(info.db_handle), | 177 db_handle_(info.db_handle), |
177 delegate_(delegate), | 178 delegate_(delegate), |
178 is_paused_(false), | 179 is_paused_(false), |
179 open_when_complete_(false), | 180 open_when_complete_(false), |
180 file_externally_removed_(false), | 181 file_externally_removed_(false), |
181 safety_state_(SAFE), | 182 safety_state_(SAFE), |
182 auto_opened_(false), | 183 auto_opened_(false), |
183 is_otr_(false), | 184 is_otr_(false), |
184 is_temporary_(false), | 185 is_temporary_(false), |
185 all_data_saved_(false), | 186 all_data_saved_(false), |
186 opened_(info.opened), | 187 opened_(info.opened), |
187 open_enabled_(true), | 188 open_enabled_(true), |
188 delegate_delayed_complete_(false) { | 189 delegate_delayed_complete_(false), |
190 bound_net_log_(net::BoundNetLog::Make(net_log, | |
191 net::NetLog::SOURCE_DOWNLOAD)) { | |
189 delegate_->Attach(); | 192 delegate_->Attach(); |
190 if (IsInProgress()) | 193 if (IsInProgress()) |
191 state_ = CANCELLED; | 194 state_ = CANCELLED; |
192 if (IsComplete()) | 195 if (IsComplete()) |
193 all_data_saved_ = true; | 196 all_data_saved_ = true; |
194 Init(false /* not actively downloading */); | 197 Init(false /* not actively downloading */, |
198 download_net_logs::SRC_HISTORY_IMPORT); | |
195 } | 199 } |
196 | 200 |
197 // Constructing for a regular download: | 201 // Constructing for a regular download: |
198 DownloadItemImpl::DownloadItemImpl( | 202 DownloadItemImpl::DownloadItemImpl( |
199 Delegate* delegate, | 203 Delegate* delegate, |
200 const DownloadCreateInfo& info, | 204 const DownloadCreateInfo& info, |
201 DownloadRequestHandleInterface* request_handle, | 205 DownloadRequestHandleInterface* request_handle, |
202 bool is_otr) | 206 bool is_otr) |
203 : state_info_(info.original_name, info.save_info.file_path, | 207 : state_info_(info.original_name, info.save_info.file_path, |
204 info.has_user_gesture, info.transition_type, | 208 info.has_user_gesture, info.transition_type, |
(...skipping 21 matching lines...) Expand all Loading... | |
226 is_paused_(false), | 230 is_paused_(false), |
227 open_when_complete_(false), | 231 open_when_complete_(false), |
228 file_externally_removed_(false), | 232 file_externally_removed_(false), |
229 safety_state_(SAFE), | 233 safety_state_(SAFE), |
230 auto_opened_(false), | 234 auto_opened_(false), |
231 is_otr_(is_otr), | 235 is_otr_(is_otr), |
232 is_temporary_(!info.save_info.file_path.empty()), | 236 is_temporary_(!info.save_info.file_path.empty()), |
233 all_data_saved_(false), | 237 all_data_saved_(false), |
234 opened_(false), | 238 opened_(false), |
235 open_enabled_(true), | 239 open_enabled_(true), |
236 delegate_delayed_complete_(false) { | 240 delegate_delayed_complete_(false), |
241 bound_net_log_(net::BoundNetLog()) { | |
Randy Smith (Not in Mondays)
2012/02/06 22:34:59
Put a TODO comment in here explaining why we're no
ahendrickson
2012/02/07 00:16:19
Done.
Randy Smith (Not in Mondays)
2012/02/07 15:09:45
I don't feel like that comment explains why; do yo
ahendrickson
2012/02/07 17:18:35
Changed the comment.
| |
237 delegate_->Attach(); | 242 delegate_->Attach(); |
238 Init(true /* actively downloading */); | 243 Init(true /* actively downloading */, |
244 download_net_logs::SRC_NEW_DOWNLOAD); | |
239 } | 245 } |
240 | 246 |
241 // Constructing for the "Save Page As..." feature: | 247 // Constructing for the "Save Page As..." feature: |
242 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, | 248 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, |
243 const FilePath& path, | 249 const FilePath& path, |
244 const GURL& url, | 250 const GURL& url, |
245 bool is_otr, | 251 bool is_otr, |
246 DownloadId download_id) | 252 DownloadId download_id, |
253 net::NetLog* net_log) | |
247 : request_handle_(new NullDownloadRequestHandle()), | 254 : request_handle_(new NullDownloadRequestHandle()), |
248 download_id_(download_id), | 255 download_id_(download_id), |
249 full_path_(path), | 256 full_path_(path), |
250 url_chain_(1, url), | 257 url_chain_(1, url), |
251 referrer_url_(GURL()), | 258 referrer_url_(GURL()), |
252 total_bytes_(0), | 259 total_bytes_(0), |
253 received_bytes_(0), | 260 received_bytes_(0), |
254 bytes_per_sec_(0), | 261 bytes_per_sec_(0), |
255 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), | 262 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), |
256 start_tick_(base::TimeTicks::Now()), | 263 start_tick_(base::TimeTicks::Now()), |
257 state_(IN_PROGRESS), | 264 state_(IN_PROGRESS), |
258 start_time_(base::Time::Now()), | 265 start_time_(base::Time::Now()), |
259 db_handle_(DownloadItem::kUninitializedHandle), | 266 db_handle_(DownloadItem::kUninitializedHandle), |
260 delegate_(delegate), | 267 delegate_(delegate), |
261 is_paused_(false), | 268 is_paused_(false), |
262 open_when_complete_(false), | 269 open_when_complete_(false), |
263 file_externally_removed_(false), | 270 file_externally_removed_(false), |
264 safety_state_(SAFE), | 271 safety_state_(SAFE), |
265 auto_opened_(false), | 272 auto_opened_(false), |
266 is_otr_(is_otr), | 273 is_otr_(is_otr), |
267 is_temporary_(false), | 274 is_temporary_(false), |
268 all_data_saved_(false), | 275 all_data_saved_(false), |
269 opened_(false), | 276 opened_(false), |
270 open_enabled_(true), | 277 open_enabled_(true), |
271 delegate_delayed_complete_(false) { | 278 delegate_delayed_complete_(false), |
279 bound_net_log_(net::BoundNetLog::Make(net_log, | |
280 net::NetLog::SOURCE_DOWNLOAD)) { | |
272 delegate_->Attach(); | 281 delegate_->Attach(); |
273 Init(true /* actively downloading */); | 282 Init(true /* actively downloading */, |
283 download_net_logs::SRC_SAVE_PAGE_AS); | |
274 } | 284 } |
275 | 285 |
276 DownloadItemImpl::~DownloadItemImpl() { | 286 DownloadItemImpl::~DownloadItemImpl() { |
277 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 287 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
278 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 288 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
279 | 289 |
280 TransitionTo(REMOVING); | 290 TransitionTo(REMOVING); |
281 STLDeleteContainerPairSecondPointers( | 291 STLDeleteContainerPairSecondPointers( |
282 external_data_map_.begin(), external_data_map_.end()); | 292 external_data_map_.begin(), external_data_map_.end()); |
283 delegate_->AssertStateConsistent(this); | 293 delegate_->AssertStateConsistent(this); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 | 366 |
357 void DownloadItemImpl::DangerousDownloadValidated() { | 367 void DownloadItemImpl::DangerousDownloadValidated() { |
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
359 DCHECK_EQ(DANGEROUS, GetSafetyState()); | 369 DCHECK_EQ(DANGEROUS, GetSafetyState()); |
360 | 370 |
361 UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated", | 371 UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated", |
362 GetDangerType(), | 372 GetDangerType(), |
363 content::DOWNLOAD_DANGER_TYPE_MAX); | 373 content::DOWNLOAD_DANGER_TYPE_MAX); |
364 | 374 |
365 safety_state_ = DANGEROUS_BUT_VALIDATED; | 375 safety_state_ = DANGEROUS_BUT_VALIDATED; |
376 | |
377 bound_net_log_.AddEvent( | |
378 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, | |
379 make_scoped_refptr( | |
380 new download_net_logs::ItemCheckedParameters(safety_state_))); | |
381 | |
366 UpdateObservers(); | 382 UpdateObservers(); |
367 | 383 |
368 delegate_->MaybeCompleteDownload(this); | 384 delegate_->MaybeCompleteDownload(this); |
369 } | 385 } |
370 | 386 |
371 void DownloadItemImpl::ProgressComplete(int64 bytes_so_far, | 387 void DownloadItemImpl::ProgressComplete(int64 bytes_so_far, |
372 const std::string& final_hash) { | 388 const std::string& final_hash) { |
373 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 389 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
374 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 390 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
375 | 391 |
(...skipping 11 matching lines...) Expand all Loading... | |
387 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, | 403 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, |
388 const std::string& hash_state) { | 404 const std::string& hash_state) { |
389 hash_state_ = hash_state; | 405 hash_state_ = hash_state; |
390 | 406 |
391 received_bytes_ = bytes_so_far; | 407 received_bytes_ = bytes_so_far; |
392 | 408 |
393 // If we've received more data than we were expecting (bad server info?), | 409 // If we've received more data than we were expecting (bad server info?), |
394 // revert to 'unknown size mode'. | 410 // revert to 'unknown size mode'. |
395 if (received_bytes_ > total_bytes_) | 411 if (received_bytes_ > total_bytes_) |
396 total_bytes_ = 0; | 412 total_bytes_ = 0; |
413 | |
414 if (bound_net_log_.IsLoggingAllEvents()) { | |
415 bound_net_log_.AddEvent( | |
416 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, | |
417 make_scoped_refptr( | |
418 new download_net_logs::ItemUpdatedParameters(received_bytes_))); | |
419 } | |
397 } | 420 } |
398 | 421 |
399 // Updates from the download thread may have been posted while this download | 422 // Updates from the download thread may have been posted while this download |
400 // was being cancelled in the UI thread, so we'll accept them unless we're | 423 // was being cancelled in the UI thread, so we'll accept them unless we're |
401 // complete. | 424 // complete. |
402 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, | 425 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, |
403 int64 bytes_per_sec, | 426 int64 bytes_per_sec, |
404 const std::string& hash_state) { | 427 const std::string& hash_state) { |
405 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 428 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 429 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 519 |
497 auto_opened_ = true; | 520 auto_opened_ = true; |
498 UpdateObservers(); | 521 UpdateObservers(); |
499 } | 522 } |
500 } | 523 } |
501 | 524 |
502 void DownloadItemImpl::TransitionTo(DownloadState new_state) { | 525 void DownloadItemImpl::TransitionTo(DownloadState new_state) { |
503 if (state_ == new_state) | 526 if (state_ == new_state) |
504 return; | 527 return; |
505 | 528 |
529 DownloadState old_state = state_; | |
506 state_ = new_state; | 530 state_ = new_state; |
531 | |
532 switch (state_) { | |
533 case COMPLETE: | |
534 bound_net_log_.AddEvent( | |
535 net::NetLog::TYPE_DOWNLOAD_ITEM_FINISHED, | |
536 make_scoped_refptr( | |
537 new download_net_logs::ItemFinishedParameters(received_bytes_, | |
538 hash_))); | |
539 break; | |
540 case INTERRUPTED: | |
541 bound_net_log_.AddEvent( | |
542 net::NetLog::TYPE_DOWNLOAD_ITEM_INTERRUPTED, | |
543 make_scoped_refptr( | |
544 new download_net_logs::ItemInterruptedParameters(last_reason_, | |
545 received_bytes_, | |
546 hash_state_))); | |
547 break; | |
548 case CANCELLED: | |
549 bound_net_log_.AddEvent( | |
550 net::NetLog::TYPE_DOWNLOAD_ITEM_CANCELED, | |
551 make_scoped_refptr( | |
552 new download_net_logs::ItemCanceledParameters(received_bytes_, | |
553 hash_state_))); | |
554 break; | |
555 default: | |
556 break; | |
557 } | |
558 | |
507 UpdateObservers(); | 559 UpdateObservers(); |
560 | |
561 bool is_done = (state_ != IN_PROGRESS); | |
562 bool was_done = (old_state != IN_PROGRESS); | |
563 if (is_done && !was_done) | |
564 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, NULL); | |
508 } | 565 } |
509 | 566 |
510 void DownloadItemImpl::UpdateSafetyState() { | 567 void DownloadItemImpl::UpdateSafetyState() { |
511 SafetyState updated_value = state_info_.IsDangerous() ? | 568 SafetyState updated_value = state_info_.IsDangerous() ? |
512 DownloadItem::DANGEROUS : DownloadItem::SAFE; | 569 DownloadItem::DANGEROUS : DownloadItem::SAFE; |
513 if (updated_value != safety_state_) { | 570 if (updated_value != safety_state_) { |
514 safety_state_ = updated_value; | 571 safety_state_ = updated_value; |
572 | |
573 bound_net_log_.AddEvent( | |
574 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, | |
575 make_scoped_refptr( | |
576 new download_net_logs::ItemCheckedParameters(safety_state_))); | |
577 | |
515 UpdateObservers(); | 578 UpdateObservers(); |
516 } | 579 } |
517 } | 580 } |
518 | 581 |
519 void DownloadItemImpl::UpdateTarget() { | 582 void DownloadItemImpl::UpdateTarget() { |
520 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 583 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
521 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 584 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
522 | 585 |
523 if (state_info_.target_name.value().empty()) | 586 if (state_info_.target_name.value().empty()) |
524 state_info_.target_name = full_path_.BaseName(); | 587 state_info_.target_name = full_path_.BaseName(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 } | 680 } |
618 | 681 |
619 void DownloadItemImpl::Rename(const FilePath& full_path) { | 682 void DownloadItemImpl::Rename(const FilePath& full_path) { |
620 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 683 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
621 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 684 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
622 | 685 |
623 VLOG(20) << __FUNCTION__ << "()" | 686 VLOG(20) << __FUNCTION__ << "()" |
624 << " full_path = \"" << full_path.value() << "\"" | 687 << " full_path = \"" << full_path.value() << "\"" |
625 << " " << DebugString(true); | 688 << " " << DebugString(true); |
626 DCHECK(!full_path.empty()); | 689 DCHECK(!full_path.empty()); |
690 | |
691 bound_net_log_.AddEvent( | |
692 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, | |
693 make_scoped_refptr( | |
694 new download_net_logs::ItemRenamedParameters( | |
695 full_path_.AsUTF8Unsafe(), full_path.AsUTF8Unsafe()))); | |
696 | |
627 full_path_ = full_path; | 697 full_path_ = full_path; |
628 } | 698 } |
629 | 699 |
630 void DownloadItemImpl::TogglePause() { | 700 void DownloadItemImpl::TogglePause() { |
631 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 701 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
632 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 702 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
633 | 703 |
634 DCHECK(IsInProgress()); | 704 DCHECK(IsInProgress()); |
635 if (is_paused_) | 705 if (is_paused_) |
636 request_handle_->ResumeRequest(); | 706 request_handle_->ResumeRequest(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) { | 874 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) { |
805 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
806 request_handle_->CancelRequest(); | 876 request_handle_->CancelRequest(); |
807 | 877 |
808 BrowserThread::PostTask( | 878 BrowserThread::PostTask( |
809 BrowserThread::FILE, FROM_HERE, | 879 BrowserThread::FILE, FROM_HERE, |
810 base::Bind(&DownloadFileManager::CancelDownload, | 880 base::Bind(&DownloadFileManager::CancelDownload, |
811 file_manager, download_id_)); | 881 file_manager, download_id_)); |
812 } | 882 } |
813 | 883 |
814 void DownloadItemImpl::Init(bool active) { | 884 void DownloadItemImpl::Init(bool active, |
885 download_net_logs::DownloadType download_type) { | |
815 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 886 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
816 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 887 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
817 | 888 |
818 UpdateTarget(); | 889 UpdateTarget(); |
819 if (active) | 890 if (active) |
820 download_stats::RecordDownloadCount(download_stats::START_COUNT); | 891 download_stats::RecordDownloadCount(download_stats::START_COUNT); |
892 | |
893 // full_path_ works for History and Save As versions. | |
894 std::string file_name = full_path_.AsUTF8Unsafe(); | |
895 if (file_name.empty()) | |
896 file_name = suggested_filename_; // From 'download' attribute of anchor. | |
897 if (file_name.empty()) | |
898 file_name = GetURL().ExtractFileName(); // URL file name. | |
899 | |
900 bound_net_log_.BeginEvent( | |
901 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, | |
902 make_scoped_refptr(new download_net_logs::ItemActivatedParameters( | |
903 download_type, | |
904 download_id_.local(), | |
905 GetOriginalUrl().spec(), | |
906 GetURL().spec(), | |
907 file_name, | |
908 safety_state_, | |
909 received_bytes_))); | |
910 | |
911 // If this is not an active download, end the ACTIVE event now. | |
912 if (!active) { | |
913 bound_net_log_.AddEvent( | |
914 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
915 make_scoped_refptr( | |
916 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
917 | |
918 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, NULL); | |
919 } | |
920 | |
821 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 921 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); |
822 } | 922 } |
823 | 923 |
824 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to | 924 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to |
825 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. | 925 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. |
826 bool DownloadItemImpl::IsPartialDownload() const { | 926 bool DownloadItemImpl::IsPartialDownload() const { |
827 return (state_ == IN_PROGRESS); | 927 return (state_ == IN_PROGRESS); |
828 } | 928 } |
829 | 929 |
830 bool DownloadItemImpl::IsInProgress() const { | 930 bool DownloadItemImpl::IsInProgress() const { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 } | 1040 } |
941 const std::string& DownloadItemImpl::GetHash() const { return hash_; } | 1041 const std::string& DownloadItemImpl::GetHash() const { return hash_; } |
942 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } | 1042 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } |
943 const std::string& DownloadItemImpl::GetHashState() const { | 1043 const std::string& DownloadItemImpl::GetHashState() const { |
944 return hash_state_; | 1044 return hash_state_; |
945 } | 1045 } |
946 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } | 1046 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } |
947 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } | 1047 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } |
948 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } | 1048 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } |
949 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } | 1049 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } |
950 void DownloadItemImpl::SetDbHandle(int64 handle) { db_handle_ = handle; } | 1050 |
1051 void DownloadItemImpl::SetDbHandle(int64 handle) { | |
1052 db_handle_ = handle; | |
1053 | |
1054 bound_net_log_.AddEvent( | |
1055 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
1056 make_scoped_refptr( | |
1057 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
1058 } | |
1059 | |
951 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } | 1060 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } |
952 bool DownloadItemImpl::IsPaused() const { return is_paused_; } | 1061 bool DownloadItemImpl::IsPaused() const { return is_paused_; } |
953 bool DownloadItemImpl::GetOpenWhenComplete() const { | 1062 bool DownloadItemImpl::GetOpenWhenComplete() const { |
954 return open_when_complete_; | 1063 return open_when_complete_; |
955 } | 1064 } |
956 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 1065 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
957 open_when_complete_ = open; | 1066 open_when_complete_ = open; |
958 } | 1067 } |
959 bool DownloadItemImpl::GetFileExternallyRemoved() const { | 1068 bool DownloadItemImpl::GetFileExternallyRemoved() const { |
960 return file_externally_removed_; | 1069 return file_externally_removed_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 std::map<const void*, ExternalData*>::iterator it = | 1110 std::map<const void*, ExternalData*>::iterator it = |
1002 external_data_map_.find(key); | 1111 external_data_map_.find(key); |
1003 | 1112 |
1004 if (it == external_data_map_.end()) { | 1113 if (it == external_data_map_.end()) { |
1005 external_data_map_[key] = data; | 1114 external_data_map_[key] = data; |
1006 } else if (it->second != data) { | 1115 } else if (it->second != data) { |
1007 delete it->second; | 1116 delete it->second; |
1008 it->second = data; | 1117 it->second = data; |
1009 } | 1118 } |
1010 } | 1119 } |
OLD | NEW |