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()) { | |
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_CHECKED, | |
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 bound_net_log_.AddEvent( | |
mmenke
2012/02/03 17:59:45
nit: If this is called a lot, should give it the
ahendrickson
2012/02/04 05:24:04
It's called roughly twice a second, which doesn't
mmenke
2012/02/04 05:35:28
Given that the memory from a download's passive lo
mmenke
2012/02/04 05:57:04
Actually, forgot we had a max number of entries we
ahendrickson
2012/02/04 23:20:57
You've convinced me!
Filtered these events out in
| |
415 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, | |
416 make_scoped_refptr( | |
417 new download_net_logs::ItemUpdatedParameters(received_bytes_, | |
418 hash_state_))); | |
397 } | 419 } |
398 | 420 |
399 // Updates from the download thread may have been posted while this download | 421 // 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 | 422 // was being cancelled in the UI thread, so we'll accept them unless we're |
401 // complete. | 423 // complete. |
402 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, | 424 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, |
403 int64 bytes_per_sec, | 425 int64 bytes_per_sec, |
404 const std::string& hash_state) { | 426 const std::string& hash_state) { |
405 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 427 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
406 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 428 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 518 |
497 auto_opened_ = true; | 519 auto_opened_ = true; |
498 UpdateObservers(); | 520 UpdateObservers(); |
499 } | 521 } |
500 } | 522 } |
501 | 523 |
502 void DownloadItemImpl::TransitionTo(DownloadState new_state) { | 524 void DownloadItemImpl::TransitionTo(DownloadState new_state) { |
503 if (state_ == new_state) | 525 if (state_ == new_state) |
504 return; | 526 return; |
505 | 527 |
528 DownloadState old_state = state_; | |
506 state_ = new_state; | 529 state_ = new_state; |
530 | |
531 switch (state_) { | |
532 case COMPLETE: | |
533 bound_net_log_.AddEvent( | |
534 net::NetLog::TYPE_DOWNLOAD_ITEM_FINISHED, | |
535 make_scoped_refptr( | |
536 new download_net_logs::ItemFinishedParameters(received_bytes_, | |
537 hash_))); | |
538 break; | |
539 case INTERRUPTED: | |
540 bound_net_log_.AddEvent( | |
541 net::NetLog::TYPE_DOWNLOAD_ITEM_INTERRUPTED, | |
542 make_scoped_refptr( | |
543 new download_net_logs::ItemInterruptedParameters(last_reason_, | |
544 received_bytes_, | |
545 hash_state_))); | |
546 break; | |
547 case CANCELLED: | |
548 bound_net_log_.AddEvent( | |
549 net::NetLog::TYPE_DOWNLOAD_ITEM_CANCELED, | |
550 make_scoped_refptr( | |
551 new download_net_logs::ItemCanceledParameters(received_bytes_, | |
552 hash_state_))); | |
553 break; | |
554 default: | |
555 break; | |
556 } | |
557 | |
507 UpdateObservers(); | 558 UpdateObservers(); |
559 | |
560 bool is_done = (state_ != IN_PROGRESS); | |
561 bool was_done = (old_state != IN_PROGRESS); | |
562 if (is_done && !was_done) | |
Randy Smith (Not in Mondays)
2012/02/03 18:05:30
nit: I think this would be easier to read if you c
ahendrickson
2012/02/04 05:24:04
Really? I took them out because I thought *this*
Randy Smith (Not in Mondays)
2012/02/05 23:49:15
I think it depends on how you're thinking about it
| |
563 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, NULL); | |
508 } | 564 } |
509 | 565 |
510 void DownloadItemImpl::UpdateSafetyState() { | 566 void DownloadItemImpl::UpdateSafetyState() { |
511 SafetyState updated_value = state_info_.IsDangerous() ? | 567 SafetyState updated_value = state_info_.IsDangerous() ? |
512 DownloadItem::DANGEROUS : DownloadItem::SAFE; | 568 DownloadItem::DANGEROUS : DownloadItem::SAFE; |
513 if (updated_value != safety_state_) { | 569 if (updated_value != safety_state_) { |
514 safety_state_ = updated_value; | 570 safety_state_ = updated_value; |
571 | |
572 bound_net_log_.AddEvent( | |
573 net::NetLog::TYPE_DOWNLOAD_ITEM_CHECKED, | |
Randy Smith (Not in Mondays)
2012/02/03 18:23:37
If you want to say "SAFETY_STATE_UPDATED", I'm goo
ahendrickson
2012/02/04 05:24:04
Agreed. Changed the name.
| |
574 make_scoped_refptr( | |
575 new download_net_logs::ItemCheckedParameters(safety_state_))); | |
576 | |
515 UpdateObservers(); | 577 UpdateObservers(); |
516 } | 578 } |
517 } | 579 } |
518 | 580 |
519 void DownloadItemImpl::UpdateTarget() { | 581 void DownloadItemImpl::UpdateTarget() { |
520 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 582 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
521 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 583 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
522 | 584 |
523 if (state_info_.target_name.value().empty()) | 585 if (state_info_.target_name.value().empty()) |
524 state_info_.target_name = full_path_.BaseName(); | 586 state_info_.target_name = full_path_.BaseName(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 } | 679 } |
618 | 680 |
619 void DownloadItemImpl::Rename(const FilePath& full_path) { | 681 void DownloadItemImpl::Rename(const FilePath& full_path) { |
620 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 682 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
621 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 683 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
622 | 684 |
623 VLOG(20) << __FUNCTION__ << "()" | 685 VLOG(20) << __FUNCTION__ << "()" |
624 << " full_path = \"" << full_path.value() << "\"" | 686 << " full_path = \"" << full_path.value() << "\"" |
625 << " " << DebugString(true); | 687 << " " << DebugString(true); |
626 DCHECK(!full_path.empty()); | 688 DCHECK(!full_path.empty()); |
689 | |
690 bound_net_log_.AddEvent( | |
691 net::NetLog::TYPE_DOWNLOAD_ITEM_RENAMED, | |
692 make_scoped_refptr( | |
693 new download_net_logs::ItemRenamedParameters( | |
694 full_path_.AsUTF8Unsafe(), full_path.AsUTF8Unsafe()))); | |
695 | |
627 full_path_ = full_path; | 696 full_path_ = full_path; |
628 } | 697 } |
629 | 698 |
630 void DownloadItemImpl::TogglePause() { | 699 void DownloadItemImpl::TogglePause() { |
631 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 700 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
632 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 701 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
633 | 702 |
634 DCHECK(IsInProgress()); | 703 DCHECK(IsInProgress()); |
635 if (is_paused_) | 704 if (is_paused_) |
636 request_handle_->ResumeRequest(); | 705 request_handle_->ResumeRequest(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
804 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) { | 873 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) { |
805 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 874 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
806 request_handle_->CancelRequest(); | 875 request_handle_->CancelRequest(); |
807 | 876 |
808 BrowserThread::PostTask( | 877 BrowserThread::PostTask( |
809 BrowserThread::FILE, FROM_HERE, | 878 BrowserThread::FILE, FROM_HERE, |
810 base::Bind(&DownloadFileManager::CancelDownload, | 879 base::Bind(&DownloadFileManager::CancelDownload, |
811 file_manager, download_id_)); | 880 file_manager, download_id_)); |
812 } | 881 } |
813 | 882 |
814 void DownloadItemImpl::Init(bool active) { | 883 void DownloadItemImpl::Init(bool active, |
884 download_net_logs::DownloadType download_type) { | |
815 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 885 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
816 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 886 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
817 | 887 |
818 UpdateTarget(); | 888 UpdateTarget(); |
819 if (active) | 889 if (active) |
820 download_stats::RecordDownloadCount(download_stats::START_COUNT); | 890 download_stats::RecordDownloadCount(download_stats::START_COUNT); |
891 | |
892 bound_net_log_.BeginEvent( | |
893 net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, | |
Randy Smith (Not in Mondays)
2012/02/03 18:23:37
nit: I'm a bit worried about the confusion of term
ahendrickson
2012/02/04 05:24:04
Commented.
| |
894 make_scoped_refptr(new download_net_logs::ItemActivatedParameters( | |
895 download_type, | |
896 download_id_.local(), | |
897 GetOriginalUrl().spec(), | |
898 GetURL().spec(), | |
899 full_path_.AsUTF8Unsafe(), | |
900 suggested_filename_, | |
901 safety_state_, | |
902 received_bytes_))); | |
903 | |
904 if (!active) { | |
905 bound_net_log_.AddEvent( | |
906 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
907 make_scoped_refptr( | |
908 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
909 | |
910 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, NULL); | |
911 } | |
912 | |
821 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 913 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); |
822 } | 914 } |
823 | 915 |
824 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to | 916 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to |
825 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. | 917 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. |
826 bool DownloadItemImpl::IsPartialDownload() const { | 918 bool DownloadItemImpl::IsPartialDownload() const { |
827 return (state_ == IN_PROGRESS); | 919 return (state_ == IN_PROGRESS); |
828 } | 920 } |
829 | 921 |
830 bool DownloadItemImpl::IsInProgress() const { | 922 bool DownloadItemImpl::IsInProgress() const { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 } | 1032 } |
941 const std::string& DownloadItemImpl::GetHash() const { return hash_; } | 1033 const std::string& DownloadItemImpl::GetHash() const { return hash_; } |
942 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } | 1034 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } |
943 const std::string& DownloadItemImpl::GetHashState() const { | 1035 const std::string& DownloadItemImpl::GetHashState() const { |
944 return hash_state_; | 1036 return hash_state_; |
945 } | 1037 } |
946 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } | 1038 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } |
947 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } | 1039 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } |
948 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } | 1040 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } |
949 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } | 1041 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } |
950 void DownloadItemImpl::SetDbHandle(int64 handle) { db_handle_ = handle; } | 1042 |
1043 void DownloadItemImpl::SetDbHandle(int64 handle) { | |
1044 db_handle_ = handle; | |
1045 | |
1046 bound_net_log_.AddEvent( | |
1047 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
1048 make_scoped_refptr( | |
1049 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
1050 } | |
1051 | |
951 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } | 1052 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } |
952 bool DownloadItemImpl::IsPaused() const { return is_paused_; } | 1053 bool DownloadItemImpl::IsPaused() const { return is_paused_; } |
953 bool DownloadItemImpl::GetOpenWhenComplete() const { | 1054 bool DownloadItemImpl::GetOpenWhenComplete() const { |
954 return open_when_complete_; | 1055 return open_when_complete_; |
955 } | 1056 } |
956 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 1057 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
957 open_when_complete_ = open; | 1058 open_when_complete_ = open; |
958 } | 1059 } |
959 bool DownloadItemImpl::GetFileExternallyRemoved() const { | 1060 bool DownloadItemImpl::GetFileExternallyRemoved() const { |
960 return file_externally_removed_; | 1061 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 = | 1102 std::map<const void*, ExternalData*>::iterator it = |
1002 external_data_map_.find(key); | 1103 external_data_map_.find(key); |
1003 | 1104 |
1004 if (it == external_data_map_.end()) { | 1105 if (it == external_data_map_.end()) { |
1005 external_data_map_[key] = data; | 1106 external_data_map_[key] = data; |
1006 } else if (it->second != data) { | 1107 } else if (it->second != data) { |
1007 delete it->second; | 1108 delete it->second; |
1008 it->second = data; | 1109 it->second = data; |
1009 } | 1110 } |
1010 } | 1111 } |
OLD | NEW |