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

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, 4 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;
878 SetDangerType(danger_type); 876 SetDangerType(danger_type);
879 } 877 }
880 878
881 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) { 879 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) {
882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 880 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
883 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_); 881 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_);
884 target_path_ = target_path; 882 target_path_ = target_path;
885 } 883 }
886 884
887 void DownloadItemImpl::OnContentCheckCompleted( 885 void DownloadItemImpl::OnContentCheckCompleted(
888 content::DownloadDangerType danger_type) { 886 content::DownloadDangerType danger_type) {
889 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 887 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
891 DCHECK(AllDataSaved()); 888 DCHECK(AllDataSaved());
892 SetDangerType(danger_type); 889 SetDangerType(danger_type);
890 UpdateObservers();
893 } 891 }
894 892
895 void DownloadItemImpl::OnIntermediatePathDetermined( 893 void DownloadItemImpl::OnIntermediatePathDetermined(
896 DownloadFileManager* file_manager, 894 DownloadFileManager* file_manager,
897 const FilePath& intermediate_path) { 895 const FilePath& intermediate_path) {
898 DownloadFileManager::RenameCompletionCallback callback = 896 DownloadFileManager::RenameCompletionCallback callback =
899 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName, 897 base::Bind(&DownloadItemImpl::OnDownloadRenamedToIntermediateName,
900 weak_ptr_factory_.GetWeakPtr()); 898 weak_ptr_factory_.GetWeakPtr());
901 BrowserThread::PostTask( 899 BrowserThread::PostTask(
902 BrowserThread::FILE, FROM_HERE, 900 BrowserThread::FILE, FROM_HERE,
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 std::map<const void*, ExternalData*>::iterator it = 1184 std::map<const void*, ExternalData*>::iterator it =
1187 external_data_map_.find(key); 1185 external_data_map_.find(key);
1188 1186
1189 if (it == external_data_map_.end()) { 1187 if (it == external_data_map_.end()) {
1190 external_data_map_[key] = data; 1188 external_data_map_[key] = data;
1191 } else if (it->second != data) { 1189 } else if (it->second != data) {
1192 delete it->second; 1190 delete it->second;
1193 it->second = data; 1191 it->second = data;
1194 } 1192 }
1195 } 1193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698