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

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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) { 746 if (content::DOWNLOAD_INTERRUPT_REASON_NONE != reason) {
747 Interrupt(reason); 747 Interrupt(reason);
748 return; 748 return;
749 } 749 }
750 750
751 // full_path is now the current and target file path. 751 // full_path is now the current and target file path.
752 DCHECK(!full_path.empty()); 752 DCHECK(!full_path.empty());
753 target_path_ = full_path; 753 target_path_ = full_path;
754 SetFullPath(full_path); 754 SetFullPath(full_path);
755 delegate_->DownloadRenamedToFinalName(this); 755 delegate_->DownloadRenamedToFinalName(this);
756 UpdateObservers();
Randy Smith (Not in Mondays) 2012/07/19 17:25:36 I don't think this is necessary--the notification
benjhayden 2012/07/23 15:58:42 Done.
756 757
757 // Complete the download and release the DownloadFile. 758 // Complete the download and release the DownloadFile.
758 BrowserThread::PostTask( 759 BrowserThread::PostTask(
759 BrowserThread::FILE, FROM_HERE, 760 BrowserThread::FILE, FROM_HERE,
760 base::Bind(&DownloadFileManager::CompleteDownload, 761 base::Bind(&DownloadFileManager::CompleteDownload,
761 file_manager, GetGlobalId(), 762 file_manager, GetGlobalId(),
762 base::Bind(&DownloadItemImpl::OnDownloadFileReleased, 763 base::Bind(&DownloadItemImpl::OnDownloadFileReleased,
763 weak_ptr_factory_.GetWeakPtr()))); 764 weak_ptr_factory_.GetWeakPtr())));
764 } 765 }
765 766
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 865 }
865 866
866 DownloadItem::TargetDisposition DownloadItemImpl::GetTargetDisposition() const { 867 DownloadItem::TargetDisposition DownloadItemImpl::GetTargetDisposition() const {
867 return target_disposition_; 868 return target_disposition_;
868 } 869 }
869 870
870 void DownloadItemImpl::OnTargetPathDetermined( 871 void DownloadItemImpl::OnTargetPathDetermined(
871 const FilePath& target_path, 872 const FilePath& target_path,
872 TargetDisposition disposition, 873 TargetDisposition disposition,
873 content::DownloadDangerType danger_type) { 874 content::DownloadDangerType danger_type) {
874 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 875 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
876 target_path_ = target_path; 876 target_path_ = target_path;
877 target_disposition_ = disposition; 877 target_disposition_ = disposition;
878 UpdateObservers();
879 // SetDangerType() may call UpdateObservers() again.
Randy Smith (Not in Mondays) 2012/07/19 17:25:36 This seems like avoidable redundancy; would it mak
asanka 2012/07/19 18:14:07 +1 to avoiding an additional UpdateObservers() cal
Randy Smith (Not in Mondays) 2012/07/19 18:16:51 I'm thinking this means we should hoist the Update
benjhayden 2012/07/23 15:58:42 Pending discussion with Asanka re FND3.
asanka 2012/07/23 19:10:21 My suggestion is to pull the UpdateObservers() cal
benjhayden 2012/07/25 16:24:38 Done.
878 SetDangerType(danger_type); 880 SetDangerType(danger_type);
879 } 881 }
880 882
881 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) { 883 void DownloadItemImpl::OnTargetPathSelected(const FilePath& target_path) {
882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 884 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
883 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_); 885 DCHECK_EQ(TARGET_DISPOSITION_PROMPT, target_disposition_);
884 target_path_ = target_path; 886 target_path_ = target_path;
887 UpdateObservers();
Randy Smith (Not in Mondays) 2012/07/19 17:25:36 This also seems redundant, especially since when A
asanka 2012/07/19 18:14:07 I think the UpdateObservers() call in OnDownloadRe
benjhayden 2012/07/23 15:58:42 Pending discussion with Asanka re FND3.
asanka 2012/07/23 19:10:21 As above, I think we shouldn't call UpdateObserver
benjhayden 2012/07/25 16:24:38 Done.
885 } 888 }
886 889
887 void DownloadItemImpl::OnContentCheckCompleted( 890 void DownloadItemImpl::OnContentCheckCompleted(
888 content::DownloadDangerType danger_type) { 891 content::DownloadDangerType danger_type) {
889 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved. 892 // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
890 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 893 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
891 DCHECK(AllDataSaved()); 894 DCHECK(AllDataSaved());
892 SetDangerType(danger_type); 895 SetDangerType(danger_type);
893 } 896 }
894 897
(...skipping 15 matching lines...) Expand all
910 } 913 }
911 914
912 FilePath DownloadItemImpl::GetFileNameToReportUser() const { 915 FilePath DownloadItemImpl::GetFileNameToReportUser() const {
913 if (!display_name_.empty()) 916 if (!display_name_.empty())
914 return display_name_; 917 return display_name_;
915 return target_path_.BaseName(); 918 return target_path_.BaseName();
916 } 919 }
917 920
918 void DownloadItemImpl::SetDisplayName(const FilePath& name) { 921 void DownloadItemImpl::SetDisplayName(const FilePath& name) {
919 display_name_ = name; 922 display_name_ = name;
923 UpdateObservers();
asanka 2012/07/19 18:14:07 Same as above. This is an intermediate state that
benjhayden 2012/07/23 15:58:42 Done.
920 } 924 }
921 925
922 FilePath DownloadItemImpl::GetUserVerifiedFilePath() const { 926 FilePath DownloadItemImpl::GetUserVerifiedFilePath() const {
923 return (safety_state_ == DownloadItem::SAFE) ? 927 return (safety_state_ == DownloadItem::SAFE) ?
924 GetTargetFilePath() : GetFullPath(); 928 GetTargetFilePath() : GetFullPath();
925 } 929 }
926 930
927 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) { 931 void DownloadItemImpl::OffThreadCancel(DownloadFileManager* file_manager) {
928 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 932 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
929 request_handle_->CancelRequest(); 933 request_handle_->CancelRequest();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 std::map<const void*, ExternalData*>::iterator it = 1190 std::map<const void*, ExternalData*>::iterator it =
1187 external_data_map_.find(key); 1191 external_data_map_.find(key);
1188 1192
1189 if (it == external_data_map_.end()) { 1193 if (it == external_data_map_.end()) {
1190 external_data_map_[key] = data; 1194 external_data_map_[key] = data;
1191 } else if (it->second != data) { 1195 } else if (it->second != data) {
1192 delete it->second; 1196 delete it->second;
1193 it->second = data; 1197 it->second = data;
1194 } 1198 }
1195 } 1199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698