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

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

Issue 2029903002: Add token field to ClientSafeBrowsingReportReqeust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak comments Created 4 years, 6 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
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 // File method ordering: Methods in this file are in the same order as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return base::FeatureList::IsEnabled(features::kDownloadResumption); 99 return base::FeatureList::IsEnabled(features::kDownloadResumption);
100 } 100 }
101 101
102 } // namespace 102 } // namespace
103 103
104 const uint32_t DownloadItem::kInvalidId = 0; 104 const uint32_t DownloadItem::kInvalidId = 0;
105 105
106 // The maximum number of attempts we will make to resume automatically. 106 // The maximum number of attempts we will make to resume automatically.
107 const int DownloadItemImpl::kMaxAutoResumeAttempts = 5; 107 const int DownloadItemImpl::kMaxAutoResumeAttempts = 5;
108 108
109 // The default token string for downloads with dangerous URLs.
110 const char kDangerousDownloadUrlToken[] = "DANGEROUS_URL";
111
109 // Constructor for reading from the history service. 112 // Constructor for reading from the history service.
110 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 113 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
111 const std::string& guid, 114 const std::string& guid,
112 uint32_t download_id, 115 uint32_t download_id,
113 const base::FilePath& current_path, 116 const base::FilePath& current_path,
114 const base::FilePath& target_path, 117 const base::FilePath& target_path,
115 const std::vector<GURL>& url_chain, 118 const std::vector<GURL>& url_chain,
116 const GURL& referrer_url, 119 const GURL& referrer_url,
117 const GURL& site_url, 120 const GURL& site_url,
118 const GURL& tab_url, 121 const GURL& tab_url,
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 WebContents* DownloadItemImpl::GetWebContents() const { 747 WebContents* DownloadItemImpl::GetWebContents() const {
745 // TODO(rdsmith): Remove null check after removing GetWebContents() from 748 // TODO(rdsmith): Remove null check after removing GetWebContents() from
746 // paths that might be used by DownloadItems created from history import. 749 // paths that might be used by DownloadItems created from history import.
747 // Currently such items have null request_handle_s, where other items 750 // Currently such items have null request_handle_s, where other items
748 // (regular and SavePackage downloads) have actual objects off the pointer. 751 // (regular and SavePackage downloads) have actual objects off the pointer.
749 if (request_handle_) 752 if (request_handle_)
750 return request_handle_->GetWebContents(); 753 return request_handle_->GetWebContents();
751 return NULL; 754 return NULL;
752 } 755 }
753 756
754 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type) { 757 void DownloadItemImpl::OnContentCheckCompleted(DownloadDangerType danger_type,
758 const std::string& token) {
755 DCHECK_CURRENTLY_ON(BrowserThread::UI); 759 DCHECK_CURRENTLY_ON(BrowserThread::UI);
756 DCHECK(AllDataSaved()); 760 DCHECK(AllDataSaved());
757 761
758 // Danger type is only allowed to be set on an active download after all data 762 // Danger type is only allowed to be set on an active download after all data
759 // has been saved. This excludes all other states. In particular, 763 // has been saved. This excludes all other states. In particular,
760 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since 764 // OnContentCheckCompleted() isn't allowed on an INTERRUPTED download since
761 // such an interruption would need to happen between OnAllDataSaved() and 765 // such an interruption would need to happen between OnAllDataSaved() and
762 // OnContentCheckCompleted() during which no disk or network activity 766 // OnContentCheckCompleted() during which no disk or network activity
763 // should've taken place. 767 // should've taken place.
764 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL); 768 DCHECK_EQ(state_, IN_PROGRESS_INTERNAL);
765 DVLOG(20) << __FUNCTION__ << " danger_type=" << danger_type 769 DVLOG(20) << __FUNCTION__ << " danger_type=" << danger_type
766 << " download=" << DebugString(true); 770 << " download=" << DebugString(true);
767 SetDangerType(danger_type); 771 SetDangerType(danger_type);
772 token_.assign(token);
768 UpdateObservers(); 773 UpdateObservers();
769 } 774 }
770 775
771 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 776 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
772 open_when_complete_ = open; 777 open_when_complete_ = open;
773 } 778 }
774 779
775 void DownloadItemImpl::SetIsTemporary(bool temporary) { 780 void DownloadItemImpl::SetIsTemporary(bool temporary) {
776 is_temporary_ = temporary; 781 is_temporary_ = temporary;
777 } 782 }
778 783
779 void DownloadItemImpl::SetOpened(bool opened) { 784 void DownloadItemImpl::SetOpened(bool opened) {
780 opened_ = opened; 785 opened_ = opened;
781 } 786 }
782 787
783 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { 788 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) {
784 display_name_ = name; 789 display_name_ = name;
785 } 790 }
786 791
792 std::string DownloadItemImpl::GetDownloadPingToken() const {
793 return token_;
794 }
795
787 std::string DownloadItemImpl::DebugString(bool verbose) const { 796 std::string DownloadItemImpl::DebugString(bool verbose) const {
788 std::string description = 797 std::string description =
789 base::StringPrintf("{ id = %d" 798 base::StringPrintf("{ id = %d"
790 " state = %s", 799 " state = %s",
791 download_id_, 800 download_id_,
792 DebugDownloadStateString(state_)); 801 DebugDownloadStateString(state_));
793 802
794 // Construct a string of the URL chain. 803 // Construct a string of the URL chain.
795 std::string url_list("<none>"); 804 std::string url_list("<none>");
796 if (!url_chain_.empty()) { 805 if (!url_chain_.empty()) {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 return; 1280 return;
1272 } 1281 }
1273 1282
1274 DVLOG(20) << __FUNCTION__ << "() target_path:" << target_path.value() 1283 DVLOG(20) << __FUNCTION__ << "() target_path:" << target_path.value()
1275 << " disposition:" << disposition << " danger_type:" << danger_type 1284 << " disposition:" << disposition << " danger_type:" << danger_type
1276 << " this:" << DebugString(true); 1285 << " this:" << DebugString(true);
1277 1286
1278 target_path_ = target_path; 1287 target_path_ = target_path;
1279 target_disposition_ = disposition; 1288 target_disposition_ = disposition;
1280 SetDangerType(danger_type); 1289 SetDangerType(danger_type);
1290 if (danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL)
1291 token_.assign(kDangerousDownloadUrlToken);
1281 1292
1282 // This was an interrupted download that was looking for a filename. Now that 1293 // This was an interrupted download that was looking for a filename. Now that
1283 // it has one, transition to interrupted. 1294 // it has one, transition to interrupted.
1284 if (state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) { 1295 if (state_ == INTERRUPTED_TARGET_PENDING_INTERNAL) {
1285 InterruptWithPartialState( 1296 InterruptWithPartialState(
1286 received_bytes_, std::move(hash_state_), destination_error_); 1297 received_bytes_, std::move(hash_state_), destination_error_);
1287 destination_error_ = DOWNLOAD_INTERRUPT_REASON_NONE; 1298 destination_error_ = DOWNLOAD_INTERRUPT_REASON_NONE;
1288 UpdateObservers(); 1299 UpdateObservers();
1289 return; 1300 return;
1290 } 1301 }
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 case RESUME_MODE_USER_CONTINUE: 2120 case RESUME_MODE_USER_CONTINUE:
2110 return "USER_CONTINUE"; 2121 return "USER_CONTINUE";
2111 case RESUME_MODE_USER_RESTART: 2122 case RESUME_MODE_USER_RESTART:
2112 return "USER_RESTART"; 2123 return "USER_RESTART";
2113 } 2124 }
2114 NOTREACHED() << "Unknown resume mode " << mode; 2125 NOTREACHED() << "Unknown resume mode " << mode;
2115 return "unknown"; 2126 return "unknown";
2116 } 2127 }
2117 2128
2118 } // namespace content 2129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698