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

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

Issue 2758453003: Recording download mime types for normal profile (Closed)
Patch Set: Mime type breakdown Created 3 years, 9 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
« no previous file with comments | « no previous file | content/browser/download/download_request_core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 OnAllDataSaved(total_bytes, std::move(secure_hash)); 1151 OnAllDataSaved(total_bytes, std::move(secure_hash));
1152 MaybeCompleteDownload(); 1152 MaybeCompleteDownload();
1153 } 1153 }
1154 1154
1155 // **** Download progression cascade 1155 // **** Download progression cascade
1156 1156
1157 void DownloadItemImpl::Init(bool active, 1157 void DownloadItemImpl::Init(bool active,
1158 DownloadType download_type) { 1158 DownloadType download_type) {
1159 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1159 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1160 1160
1161 if (active) 1161 if (active) {
1162 RecordDownloadCount(START_COUNT); 1162 RecordDownloadCount(START_COUNT);
1163 if (GetWebContents() &&
asanka 2017/03/22 21:03:02 For a new single resource download, Init() gets ca
shaktisahu 2017/03/22 22:21:36 Done.
1164 !GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
1165 RecordDownloadCount(START_COUNT_NORMAL_PROFILE);
1166 }
1167 }
1163 1168
1164 std::string file_name; 1169 std::string file_name;
1165 if (download_type == SRC_HISTORY_IMPORT) { 1170 if (download_type == SRC_HISTORY_IMPORT) {
1166 // target_path_ works for History and Save As versions. 1171 // target_path_ works for History and Save As versions.
1167 file_name = target_path_.AsUTF8Unsafe(); 1172 file_name = target_path_.AsUTF8Unsafe();
1168 } else { 1173 } else {
1169 // See if it's set programmatically. 1174 // See if it's set programmatically.
1170 file_name = forced_file_path_.AsUTF8Unsafe(); 1175 file_name = forced_file_path_.AsUTF8Unsafe();
1171 // Possibly has a 'download' attribute for the anchor. 1176 // Possibly has a 'download' attribute for the anchor.
1172 if (file_name.empty()) 1177 if (file_name.empty())
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1256
1252 // Otherwise, this was a resumption attempt which ended with an 1257 // Otherwise, this was a resumption attempt which ended with an
1253 // interruption. Continue with current target path. 1258 // interruption. Continue with current target path.
1254 TransitionTo(TARGET_RESOLVED_INTERNAL); 1259 TransitionTo(TARGET_RESOLVED_INTERNAL);
1255 InterruptWithPartialState( 1260 InterruptWithPartialState(
1256 offset, std::move(hash_state), new_create_info.result); 1261 offset, std::move(hash_state), new_create_info.result);
1257 UpdateObservers(); 1262 UpdateObservers();
1258 return; 1263 return;
1259 } 1264 }
1260 1265
1266 RecordDownloadMimeType(mime_type_);
1267 if (GetWebContents() &&
1268 !GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
asanka 2017/03/22 21:03:03 Call DownloadItemImpl::GetBrowserContext() directl
shaktisahu 2017/03/22 22:21:36 Done. Thanks. I am interested in new downloads onl
1269 RecordDownloadMimeTypeForNormalProfile(mime_type_);
1270 }
1271
1261 // Successful download start. 1272 // Successful download start.
1262 DCHECK(download_file_); 1273 DCHECK(download_file_);
1263 DCHECK(job_); 1274 DCHECK(job_);
1264 1275
1265 if (state_ == RESUMING_INTERNAL) 1276 if (state_ == RESUMING_INTERNAL)
1266 UpdateValidatorsOnResumption(new_create_info); 1277 UpdateValidatorsOnResumption(new_create_info);
1267 1278
1268 TransitionTo(TARGET_PENDING_INTERNAL); 1279 TransitionTo(TARGET_PENDING_INTERNAL);
1269 1280
1270 job_->Start(); 1281 job_->Start();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 1557
1547 void DownloadItemImpl::Completed() { 1558 void DownloadItemImpl::Completed() {
1548 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1559 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1549 1560
1550 DVLOG(20) << __func__ << "() " << DebugString(false); 1561 DVLOG(20) << __func__ << "() " << DebugString(false);
1551 1562
1552 DCHECK(all_data_saved_); 1563 DCHECK(all_data_saved_);
1553 end_time_ = base::Time::Now(); 1564 end_time_ = base::Time::Now();
1554 TransitionTo(COMPLETE_INTERNAL); 1565 TransitionTo(COMPLETE_INTERNAL);
1555 RecordDownloadCompleted(start_tick_, received_bytes_); 1566 RecordDownloadCompleted(start_tick_, received_bytes_);
1567 if (GetWebContents() &&
1568 !GetWebContents()->GetBrowserContext()->IsOffTheRecord()) {
1569 RecordDownloadCount(COMPLETED_COUNT_NORMAL_PROFILE);
1570 }
1556 1571
1557 if (auto_opened_) { 1572 if (auto_opened_) {
1558 // If it was already handled by the delegate, do nothing. 1573 // If it was already handled by the delegate, do nothing.
1559 } else if (GetOpenWhenComplete() || 1574 } else if (GetOpenWhenComplete() ||
1560 ShouldOpenFileBasedOnExtension() || 1575 ShouldOpenFileBasedOnExtension() ||
1561 IsTemporary()) { 1576 IsTemporary()) {
1562 // If the download is temporary, like in drag-and-drop, do not open it but 1577 // If the download is temporary, like in drag-and-drop, do not open it but
1563 // we still need to set it auto-opened so that it can be removed from the 1578 // we still need to set it auto-opened so that it can be removed from the
1564 // download shelf. 1579 // download shelf.
1565 if (!IsTemporary()) 1580 if (!IsTemporary())
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 case RESUME_MODE_USER_CONTINUE: 2180 case RESUME_MODE_USER_CONTINUE:
2166 return "USER_CONTINUE"; 2181 return "USER_CONTINUE";
2167 case RESUME_MODE_USER_RESTART: 2182 case RESUME_MODE_USER_RESTART:
2168 return "USER_RESTART"; 2183 return "USER_RESTART";
2169 } 2184 }
2170 NOTREACHED() << "Unknown resume mode " << mode; 2185 NOTREACHED() << "Unknown resume mode " << mode;
2171 return "unknown"; 2186 return "unknown";
2172 } 2187 }
2173 2188
2174 } // namespace content 2189 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_request_core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698