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

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 10735089: DownloadManager::Observer::OnDownloadCreated (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 #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"
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // Notify observers if the safety state has changed as a result of the new 597 // Notify observers if the safety state has changed as a result of the new
598 // danger type. 598 // danger type.
599 SafetyState updated_value = IsDangerous() ? 599 SafetyState updated_value = IsDangerous() ?
600 DownloadItem::DANGEROUS : DownloadItem::SAFE; 600 DownloadItem::DANGEROUS : DownloadItem::SAFE;
601 if (updated_value != safety_state_) { 601 if (updated_value != safety_state_) {
602 safety_state_ = updated_value; 602 safety_state_ = updated_value;
603 bound_net_log_.AddEvent( 603 bound_net_log_.AddEvent(
604 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, 604 net::NetLog::TYPE_DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
605 base::Bind(&download_net_logs::ItemCheckedCallback, 605 base::Bind(&download_net_logs::ItemCheckedCallback,
606 GetDangerType(), GetSafetyState())); 606 GetDangerType(), GetSafetyState()));
607 UpdateObservers();
608 } 607 }
609 } 608 }
610 609
611 void DownloadItemImpl::SetFullPath(const FilePath& new_path) { 610 void DownloadItemImpl::SetFullPath(const FilePath& new_path) {
612 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 611 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
613 VLOG(20) << __FUNCTION__ << "()" 612 VLOG(20) << __FUNCTION__ << "()"
614 << " new_path = \"" << new_path.value() << "\"" 613 << " new_path = \"" << new_path.value() << "\""
615 << " " << DebugString(true); 614 << " " << DebugString(true);
616 DCHECK(!new_path.empty()); 615 DCHECK(!new_path.empty());
617 current_path_ = new_path; 616 current_path_ = new_path;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 863 }
865 864
866 DownloadItem::TargetDisposition DownloadItemImpl::GetTargetDisposition() const { 865 DownloadItem::TargetDisposition DownloadItemImpl::GetTargetDisposition() const {
867 return target_disposition_; 866 return target_disposition_;
868 } 867 }
869 868
870 void DownloadItemImpl::OnTargetPathDetermined( 869 void DownloadItemImpl::OnTargetPathDetermined(
871 const FilePath& target_path, 870 const FilePath& target_path,
872 TargetDisposition disposition, 871 TargetDisposition disposition,
873 content::DownloadDangerType danger_type) { 872 content::DownloadDangerType danger_type) {
874 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 873 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
876 target_path_ = target_path; 874 target_path_ = target_path;
877 target_disposition_ = disposition; 875 target_disposition_ = disposition;
876 // SetDangerType() may call UpdateObservers() again.
asanka 2012/07/25 19:36:35 Stale comment?
benjhayden 2012/07/25 21:26:26 Done.
878 SetDangerType(danger_type); 877 SetDangerType(danger_type);
879 } 878 }
880 879
881 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) { 880 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) {
882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 881 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
883 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_); 882 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_);
884 target_path_ = target_path; 883 target_path_ = target_path;
884 UpdateObservers();
885 } 885 }
886 886
887 void DownloadItemImpl::OnContentCheckCompleted( 887 void DownloadItemImpl::OnContentCheckCompleted(
888 content::DownloadDangerType danger_type) { 888 content::DownloadDangerType danger_type) {
889 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 889 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
asanka 2012/07/25 19:36:35 Nit: Remove this comment?
benjhayden 2012/07/25 21:26:26 Done.
890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
891 DCHECK(AllDataSaved()); 891 DCHECK(AllDataSaved());
892 SetDangerType(danger_type); 892 SetDangerType(danger_type);
893 UpdateObservers();
asanka 2012/07/25 19:36:35 I was under the impression that we weren't going t
benjhayden 2012/07/25 21:26:26 I am so far down the rabbit hole, I don't know any
asanka 2012/07/25 21:56:04 Whoa. Apparently I clicked on the wrong UpdateObse
benjhayden 2012/07/26 15:03:42 Thank you! That was very helpful. :-) PTAL
893 } 894 }
894 895
895 void DownloadItemImpl::OnIntermediatePathDetermined( 896 void DownloadItemImpl::OnIntermediatePathDetermined(
896 DownloadFileManager* file_manager, 897 DownloadFileManager* file_manager,
897 const FilePath& intermediate_path) { 898 const FilePath& intermediate_path) {
898 DownloadFileManager::RenameCompletionCallback callback = 899 DownloadFileManager::RenameCompletionCallback callback =
899 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName, 900 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName,
900 weak_ptr_factory_.GetWeakPtr()); 901 weak_ptr_factory_.GetWeakPtr());
901 BrowserThread::PostTask( 902 BrowserThread::PostTask(
902 BrowserThread::FILE, FROM_HERE, 903 BrowserThread::FILE, FROM_HERE,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 std::map<const void*, ExternalData*>::iterator it = 1187 std::map<const void*, ExternalData*>::iterator it =
1187 external_data_map_.find(key); 1188 external_data_map_.find(key);
1188 1189
1189 if (it == external_data_map_.end()) { 1190 if (it == external_data_map_.end()) {
1190 external_data_map_[key] = data; 1191 external_data_map_[key] = data;
1191 } else if (it->second != data) { 1192 } else if (it->second != data) {
1192 delete it->second; 1193 delete it->second;
1193 it->second = data; 1194 it->second = data;
1194 } 1195 }
1195 } 1196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698