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 const net::BoundNetLog& bound_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_(bound_net_log) { | |
189 delegate_->Attach(); | 191 delegate_->Attach(); |
190 if (IsInProgress()) | 192 if (IsInProgress()) |
191 state_ = CANCELLED; | 193 state_ = CANCELLED; |
192 if (IsComplete()) | 194 if (IsComplete()) |
193 all_data_saved_ = true; | 195 all_data_saved_ = true; |
194 Init(false /* not actively downloading */); | 196 Init(false /* not actively downloading */, |
197 download_net_logs::SRC_HISTORY_IMPORT); | |
195 } | 198 } |
196 | 199 |
197 // Constructing for a regular download: | 200 // Constructing for a regular download: |
198 DownloadItemImpl::DownloadItemImpl( | 201 DownloadItemImpl::DownloadItemImpl( |
199 Delegate* delegate, | 202 Delegate* delegate, |
200 const DownloadCreateInfo& info, | 203 const DownloadCreateInfo& info, |
201 DownloadRequestHandleInterface* request_handle, | 204 DownloadRequestHandleInterface* request_handle, |
202 bool is_otr) | 205 bool is_otr) |
203 : state_info_(info.original_name, info.save_info.file_path, | 206 : state_info_(info.original_name, info.save_info.file_path, |
204 info.has_user_gesture, info.transition_type, | 207 info.has_user_gesture, info.transition_type, |
(...skipping 21 matching lines...) Expand all Loading... | |
226 is_paused_(false), | 229 is_paused_(false), |
227 open_when_complete_(false), | 230 open_when_complete_(false), |
228 file_externally_removed_(false), | 231 file_externally_removed_(false), |
229 safety_state_(SAFE), | 232 safety_state_(SAFE), |
230 auto_opened_(false), | 233 auto_opened_(false), |
231 is_otr_(is_otr), | 234 is_otr_(is_otr), |
232 is_temporary_(!info.save_info.file_path.empty()), | 235 is_temporary_(!info.save_info.file_path.empty()), |
233 all_data_saved_(false), | 236 all_data_saved_(false), |
234 opened_(false), | 237 opened_(false), |
235 open_enabled_(true), | 238 open_enabled_(true), |
236 delegate_delayed_complete_(false) { | 239 delegate_delayed_complete_(false), |
240 bound_net_log_(net::BoundNetLog()) { | |
237 delegate_->Attach(); | 241 delegate_->Attach(); |
238 Init(true /* actively downloading */); | 242 Init(true /* actively downloading */, |
243 download_net_logs::SRC_NEW_DOWNLOAD); | |
239 } | 244 } |
240 | 245 |
241 // Constructing for the "Save Page As..." feature: | 246 // Constructing for the "Save Page As..." feature: |
242 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, | 247 DownloadItemImpl::DownloadItemImpl(Delegate* delegate, |
243 const FilePath& path, | 248 const FilePath& path, |
244 const GURL& url, | 249 const GURL& url, |
245 bool is_otr, | 250 bool is_otr, |
246 DownloadId download_id) | 251 DownloadId download_id, |
252 const net::BoundNetLog& bound_net_log) | |
247 : request_handle_(new NullDownloadRequestHandle()), | 253 : request_handle_(new NullDownloadRequestHandle()), |
248 download_id_(download_id), | 254 download_id_(download_id), |
249 full_path_(path), | 255 full_path_(path), |
250 url_chain_(1, url), | 256 url_chain_(1, url), |
251 referrer_url_(GURL()), | 257 referrer_url_(GURL()), |
252 total_bytes_(0), | 258 total_bytes_(0), |
253 received_bytes_(0), | 259 received_bytes_(0), |
254 bytes_per_sec_(0), | 260 bytes_per_sec_(0), |
255 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), | 261 last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE), |
256 start_tick_(base::TimeTicks::Now()), | 262 start_tick_(base::TimeTicks::Now()), |
257 state_(IN_PROGRESS), | 263 state_(IN_PROGRESS), |
258 start_time_(base::Time::Now()), | 264 start_time_(base::Time::Now()), |
259 db_handle_(DownloadItem::kUninitializedHandle), | 265 db_handle_(DownloadItem::kUninitializedHandle), |
260 delegate_(delegate), | 266 delegate_(delegate), |
261 is_paused_(false), | 267 is_paused_(false), |
262 open_when_complete_(false), | 268 open_when_complete_(false), |
263 file_externally_removed_(false), | 269 file_externally_removed_(false), |
264 safety_state_(SAFE), | 270 safety_state_(SAFE), |
265 auto_opened_(false), | 271 auto_opened_(false), |
266 is_otr_(is_otr), | 272 is_otr_(is_otr), |
267 is_temporary_(false), | 273 is_temporary_(false), |
268 all_data_saved_(false), | 274 all_data_saved_(false), |
269 opened_(false), | 275 opened_(false), |
270 open_enabled_(true), | 276 open_enabled_(true), |
271 delegate_delayed_complete_(false) { | 277 delegate_delayed_complete_(false), |
278 bound_net_log_(bound_net_log) { | |
272 delegate_->Attach(); | 279 delegate_->Attach(); |
273 Init(true /* actively downloading */); | 280 Init(true /* actively downloading */, |
281 download_net_logs::SRC_SAVE_PAGE_AS); | |
274 } | 282 } |
275 | 283 |
276 DownloadItemImpl::~DownloadItemImpl() { | 284 DownloadItemImpl::~DownloadItemImpl() { |
277 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 285 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
278 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 286 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
279 | 287 |
280 TransitionTo(REMOVING); | 288 TransitionTo(REMOVING); |
281 STLDeleteContainerPairSecondPointers( | 289 STLDeleteContainerPairSecondPointers( |
282 external_data_map_.begin(), external_data_map_.end()); | 290 external_data_map_.begin(), external_data_map_.end()); |
283 delegate_->AssertStateConsistent(this); | 291 delegate_->AssertStateConsistent(this); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 | 364 |
357 void DownloadItemImpl::DangerousDownloadValidated() { | 365 void DownloadItemImpl::DangerousDownloadValidated() { |
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 366 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
359 DCHECK_EQ(DANGEROUS, GetSafetyState()); | 367 DCHECK_EQ(DANGEROUS, GetSafetyState()); |
360 | 368 |
361 UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated", | 369 UMA_HISTOGRAM_ENUMERATION("Download.DangerousDownloadValidated", |
362 GetDangerType(), | 370 GetDangerType(), |
363 content::DOWNLOAD_DANGER_TYPE_MAX); | 371 content::DOWNLOAD_DANGER_TYPE_MAX); |
364 | 372 |
365 safety_state_ = DANGEROUS_BUT_VALIDATED; | 373 safety_state_ = DANGEROUS_BUT_VALIDATED; |
374 | |
375 bound_net_log_.AddEvent( | |
376 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, | |
377 make_scoped_refptr( | |
378 new download_net_logs::ItemCheckedParameters(safety_state_))); | |
379 | |
366 UpdateObservers(); | 380 UpdateObservers(); |
367 | 381 |
368 delegate_->MaybeCompleteDownload(this); | 382 delegate_->MaybeCompleteDownload(this); |
369 } | 383 } |
370 | 384 |
371 void DownloadItemImpl::ProgressComplete(int64 bytes_so_far, | 385 void DownloadItemImpl::ProgressComplete(int64 bytes_so_far, |
372 const std::string& final_hash) { | 386 const std::string& final_hash) { |
373 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. | 387 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. |
374 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 388 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
375 | 389 |
(...skipping 11 matching lines...) Expand all Loading... | |
387 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, | 401 void DownloadItemImpl::UpdateProgress(int64 bytes_so_far, |
388 const std::string& hash_state) { | 402 const std::string& hash_state) { |
389 hash_state_ = hash_state; | 403 hash_state_ = hash_state; |
390 | 404 |
391 received_bytes_ = bytes_so_far; | 405 received_bytes_ = bytes_so_far; |
392 | 406 |
393 // If we've received more data than we were expecting (bad server info?), | 407 // If we've received more data than we were expecting (bad server info?), |
394 // revert to 'unknown size mode'. | 408 // revert to 'unknown size mode'. |
395 if (received_bytes_ > total_bytes_) | 409 if (received_bytes_ > total_bytes_) |
396 total_bytes_ = 0; | 410 total_bytes_ = 0; |
411 | |
412 if (bound_net_log_.IsLoggingAllEvents()) { | |
413 bound_net_log_.AddEvent( | |
414 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, | |
415 make_scoped_refptr( | |
416 new download_net_logs::ItemUpdatedParameters(received_bytes_, | |
417 hash_state_))); | |
418 } | |
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) | |
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_SAFETY_STATE_UPDATED, | |
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, | |
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 this is not an active download, end the ACTIVE event now. | |
905 if (!active) { | |
906 bound_net_log_.AddEvent( | |
907 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
908 make_scoped_refptr( | |
909 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
910 | |
911 bound_net_log_.EndEvent(net::NetLog::TYPE_DOWNLOAD_ITEM_ACTIVE, NULL); | |
Randy Smith (Not in Mondays)
2012/02/05 23:49:15
Do we want to log the probe to make sure the file
ahendrickson
2012/02/06 21:39:20
Hmm, that's not strictly part of the download proc
Randy Smith (Not in Mondays)
2012/02/06 22:34:59
I'm happy with it being in a separate CL, but the
ahendrickson
2012/02/07 00:16:19
Per our conversation, I see how it could be useful
| |
912 } | |
913 | |
821 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); | 914 VLOG(20) << __FUNCTION__ << "() " << DebugString(true); |
822 } | 915 } |
823 | 916 |
824 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to | 917 // TODO(ahendrickson) -- Move |INTERRUPTED| from |IsCancelled()| to |
825 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. | 918 // |IsPartialDownload()|, when resuming interrupted downloads is implemented. |
826 bool DownloadItemImpl::IsPartialDownload() const { | 919 bool DownloadItemImpl::IsPartialDownload() const { |
827 return (state_ == IN_PROGRESS); | 920 return (state_ == IN_PROGRESS); |
828 } | 921 } |
829 | 922 |
830 bool DownloadItemImpl::IsInProgress() const { | 923 bool DownloadItemImpl::IsInProgress() const { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 } | 1033 } |
941 const std::string& DownloadItemImpl::GetHash() const { return hash_; } | 1034 const std::string& DownloadItemImpl::GetHash() const { return hash_; } |
942 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } | 1035 int64 DownloadItemImpl::GetReceivedBytes() const { return received_bytes_; } |
943 const std::string& DownloadItemImpl::GetHashState() const { | 1036 const std::string& DownloadItemImpl::GetHashState() const { |
944 return hash_state_; | 1037 return hash_state_; |
945 } | 1038 } |
946 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } | 1039 int32 DownloadItemImpl::GetId() const { return download_id_.local(); } |
947 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } | 1040 DownloadId DownloadItemImpl::GetGlobalId() const { return download_id_; } |
948 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } | 1041 base::Time DownloadItemImpl::GetStartTime() const { return start_time_; } |
949 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } | 1042 base::Time DownloadItemImpl::GetEndTime() const { return end_time_; } |
950 void DownloadItemImpl::SetDbHandle(int64 handle) { db_handle_ = handle; } | 1043 |
1044 void DownloadItemImpl::SetDbHandle(int64 handle) { | |
1045 db_handle_ = handle; | |
1046 | |
1047 bound_net_log_.AddEvent( | |
1048 net::NetLog::TYPE_DOWNLOAD_ITEM_IN_HISTORY, | |
1049 make_scoped_refptr( | |
1050 new download_net_logs::ItemInHistoryParameters(db_handle_))); | |
1051 } | |
1052 | |
951 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } | 1053 int64 DownloadItemImpl::GetDbHandle() const { return db_handle_; } |
952 bool DownloadItemImpl::IsPaused() const { return is_paused_; } | 1054 bool DownloadItemImpl::IsPaused() const { return is_paused_; } |
953 bool DownloadItemImpl::GetOpenWhenComplete() const { | 1055 bool DownloadItemImpl::GetOpenWhenComplete() const { |
954 return open_when_complete_; | 1056 return open_when_complete_; |
955 } | 1057 } |
956 void DownloadItemImpl::SetOpenWhenComplete(bool open) { | 1058 void DownloadItemImpl::SetOpenWhenComplete(bool open) { |
957 open_when_complete_ = open; | 1059 open_when_complete_ = open; |
958 } | 1060 } |
959 bool DownloadItemImpl::GetFileExternallyRemoved() const { | 1061 bool DownloadItemImpl::GetFileExternallyRemoved() const { |
960 return file_externally_removed_; | 1062 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 = | 1103 std::map<const void*, ExternalData*>::iterator it = |
1002 external_data_map_.find(key); | 1104 external_data_map_.find(key); |
1003 | 1105 |
1004 if (it == external_data_map_.end()) { | 1106 if (it == external_data_map_.end()) { |
1005 external_data_map_[key] = data; | 1107 external_data_map_[key] = data; |
1006 } else if (it->second != data) { | 1108 } else if (it->second != data) { |
1007 delete it->second; | 1109 delete it->second; |
1008 it->second = data; | 1110 it->second = data; |
1009 } | 1111 } |
1010 } | 1112 } |
OLD | NEW |