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

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

Issue 1538773002: Reduce CPU usage of download shelf UI. (both MD and pre-MD shelves) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 // Cancel on the UI thread with an update on the FILE thread. 1031 // Cancel on the UI thread with an update on the FILE thread.
1032 // 1032 //
1033 // TODO(rdsmith): Arguably we should let this go through, as this means 1033 // TODO(rdsmith): Arguably we should let this go through, as this means
1034 // the download really did get further than we know before it was 1034 // the download really did get further than we know before it was
1035 // cancelled. But the gain isn't very large, and the code is more 1035 // cancelled. But the gain isn't very large, and the code is more
1036 // fragile if it has to support in progress updates in a non-in-progress 1036 // fragile if it has to support in progress updates in a non-in-progress
1037 // state. This issue should be readdressed when we revamp performance 1037 // state. This issue should be readdressed when we revamp performance
1038 // reporting. 1038 // reporting.
1039 return; 1039 return;
1040 } 1040 }
1041
1042 int previous_progress = PercentComplete();
1041 bytes_per_sec_ = bytes_per_sec; 1043 bytes_per_sec_ = bytes_per_sec;
1042 hash_state_ = hash_state; 1044 hash_state_ = hash_state;
1043 received_bytes_ = bytes_so_far; 1045 received_bytes_ = bytes_so_far;
1044 1046
1045 // If we've received more data than we were expecting (bad server info?), 1047 // If we've received more data than we were expecting (bad server info?),
1046 // revert to 'unknown size mode'. 1048 // revert to 'unknown size mode'.
1047 if (received_bytes_ > total_bytes_) 1049 if (received_bytes_ > total_bytes_)
1048 total_bytes_ = 0; 1050 total_bytes_ = 0;
1049 1051
1050 if (bound_net_log_.IsCapturing()) { 1052 if (bound_net_log_.IsCapturing()) {
1051 bound_net_log_.AddEvent( 1053 bound_net_log_.AddEvent(
1052 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED, 1054 net::NetLog::TYPE_DOWNLOAD_ITEM_UPDATED,
1053 net::NetLog::Int64Callback("bytes_so_far", received_bytes_)); 1055 net::NetLog::Int64Callback("bytes_so_far", received_bytes_));
1054 } 1056 }
1055 1057
1056 UpdateObservers(); 1058 // Don't bother to update observers unless the progress percentage has
1059 // actually changed.
1060 if (previous_progress != -1 && PercentComplete() != previous_progress)
asanka 2015/12/18 03:39:16 This change places the responsibility of throttlin
Evan Stade 2015/12/18 19:01:38 My justification for putting the responsibility he
Evan Stade 2015/12/29 18:57:03 reverted this change
1061 UpdateObservers();
1057 } 1062 }
1058 1063
1059 void DownloadItemImpl::DestinationError(DownloadInterruptReason reason) { 1064 void DownloadItemImpl::DestinationError(DownloadInterruptReason reason) {
1060 // Postpone recognition of this error until after file name determination 1065 // Postpone recognition of this error until after file name determination
1061 // has completed and the intermediate file has been renamed to simplify 1066 // has completed and the intermediate file has been renamed to simplify
1062 // resumption conditions. 1067 // resumption conditions.
1063 if (current_path_.empty() || target_path_.empty()) 1068 if (current_path_.empty() || target_path_.empty())
1064 destination_error_ = reason; 1069 destination_error_ = reason;
1065 else 1070 else
1066 Interrupt(reason); 1071 Interrupt(reason);
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 case RESUME_MODE_USER_CONTINUE: 1799 case RESUME_MODE_USER_CONTINUE:
1795 return "USER_CONTINUE"; 1800 return "USER_CONTINUE";
1796 case RESUME_MODE_USER_RESTART: 1801 case RESUME_MODE_USER_RESTART:
1797 return "USER_RESTART"; 1802 return "USER_RESTART";
1798 } 1803 }
1799 NOTREACHED() << "Unknown resume mode " << mode; 1804 NOTREACHED() << "Unknown resume mode " << mode;
1800 return "unknown"; 1805 return "unknown";
1801 } 1806 }
1802 1807
1803 } // namespace content 1808 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698