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

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

Issue 2351513002: net: rename BoundNetLog to NetLogWithSource (Closed)
Patch Set: one more fix, content bound_net_log_ Created 4 years, 3 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const base::Time& end_time, 119 const base::Time& end_time,
120 const std::string& etag, 120 const std::string& etag,
121 const std::string& last_modified, 121 const std::string& last_modified,
122 int64_t received_bytes, 122 int64_t received_bytes,
123 int64_t total_bytes, 123 int64_t total_bytes,
124 const std::string& hash, 124 const std::string& hash,
125 DownloadItem::DownloadState state, 125 DownloadItem::DownloadState state,
126 DownloadDangerType danger_type, 126 DownloadDangerType danger_type,
127 DownloadInterruptReason interrupt_reason, 127 DownloadInterruptReason interrupt_reason,
128 bool opened, 128 bool opened,
129 const net::BoundNetLog& bound_net_log) 129 const net::NetLogWithSource& net_log)
130 : guid_(base::ToUpperASCII(guid)), 130 : guid_(base::ToUpperASCII(guid)),
131 download_id_(download_id), 131 download_id_(download_id),
132 target_path_(target_path), 132 target_path_(target_path),
133 url_chain_(url_chain), 133 url_chain_(url_chain),
134 referrer_url_(referrer_url), 134 referrer_url_(referrer_url),
135 site_url_(site_url), 135 site_url_(site_url),
136 tab_url_(tab_url), 136 tab_url_(tab_url),
137 tab_referrer_url_(tab_refererr_url), 137 tab_referrer_url_(tab_refererr_url),
138 mime_type_(mime_type), 138 mime_type_(mime_type),
139 original_mime_type_(original_mime_type), 139 original_mime_type_(original_mime_type),
140 total_bytes_(total_bytes), 140 total_bytes_(total_bytes),
141 last_reason_(interrupt_reason), 141 last_reason_(interrupt_reason),
142 start_tick_(base::TimeTicks()), 142 start_tick_(base::TimeTicks()),
143 state_(ExternalToInternalState(state)), 143 state_(ExternalToInternalState(state)),
144 danger_type_(danger_type), 144 danger_type_(danger_type),
145 start_time_(start_time), 145 start_time_(start_time),
146 end_time_(end_time), 146 end_time_(end_time),
147 delegate_(delegate), 147 delegate_(delegate),
148 opened_(opened), 148 opened_(opened),
149 current_path_(current_path), 149 current_path_(current_path),
150 received_bytes_(received_bytes), 150 received_bytes_(received_bytes),
151 all_data_saved_(state == COMPLETE), 151 all_data_saved_(state == COMPLETE),
152 hash_(hash), 152 hash_(hash),
153 last_modified_time_(last_modified), 153 last_modified_time_(last_modified),
154 etag_(etag), 154 etag_(etag),
155 bound_net_log_(bound_net_log), 155 net_log_(net_log),
156 weak_ptr_factory_(this) { 156 weak_ptr_factory_(this) {
157 delegate_->Attach(); 157 delegate_->Attach();
158 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || 158 DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL ||
159 state_ == CANCELLED_INTERNAL); 159 state_ == CANCELLED_INTERNAL);
160 DCHECK(base::IsValidGUID(guid_)); 160 DCHECK(base::IsValidGUID(guid_));
161 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT); 161 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT);
162 } 162 }
163 163
164 // Constructing for a regular download: 164 // Constructing for a regular download:
165 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 165 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
166 uint32_t download_id, 166 uint32_t download_id,
167 const DownloadCreateInfo& info, 167 const DownloadCreateInfo& info,
168 const net::BoundNetLog& bound_net_log) 168 const net::NetLogWithSource& net_log)
169 : guid_(base::ToUpperASCII(base::GenerateGUID())), 169 : guid_(base::ToUpperASCII(base::GenerateGUID())),
170 download_id_(download_id), 170 download_id_(download_id),
171 target_disposition_((info.save_info->prompt_for_save_location) 171 target_disposition_((info.save_info->prompt_for_save_location)
172 ? TARGET_DISPOSITION_PROMPT 172 ? TARGET_DISPOSITION_PROMPT
173 : TARGET_DISPOSITION_OVERWRITE), 173 : TARGET_DISPOSITION_OVERWRITE),
174 url_chain_(info.url_chain), 174 url_chain_(info.url_chain),
175 referrer_url_(info.referrer_url), 175 referrer_url_(info.referrer_url),
176 site_url_(info.site_url), 176 site_url_(info.site_url),
177 tab_url_(info.tab_url), 177 tab_url_(info.tab_url),
178 tab_referrer_url_(info.tab_referrer_url), 178 tab_referrer_url_(info.tab_referrer_url),
179 suggested_filename_(base::UTF16ToUTF8(info.save_info->suggested_name)), 179 suggested_filename_(base::UTF16ToUTF8(info.save_info->suggested_name)),
180 forced_file_path_(info.save_info->file_path), 180 forced_file_path_(info.save_info->file_path),
181 transition_type_(info.transition_type), 181 transition_type_(info.transition_type),
182 has_user_gesture_(info.has_user_gesture), 182 has_user_gesture_(info.has_user_gesture),
183 content_disposition_(info.content_disposition), 183 content_disposition_(info.content_disposition),
184 mime_type_(info.mime_type), 184 mime_type_(info.mime_type),
185 original_mime_type_(info.original_mime_type), 185 original_mime_type_(info.original_mime_type),
186 remote_address_(info.remote_address), 186 remote_address_(info.remote_address),
187 total_bytes_(info.total_bytes), 187 total_bytes_(info.total_bytes),
188 last_reason_(info.result), 188 last_reason_(info.result),
189 start_tick_(base::TimeTicks::Now()), 189 start_tick_(base::TimeTicks::Now()),
190 state_(INITIAL_INTERNAL), 190 state_(INITIAL_INTERNAL),
191 start_time_(info.start_time), 191 start_time_(info.start_time),
192 delegate_(delegate), 192 delegate_(delegate),
193 is_temporary_(!info.save_info->file_path.empty()), 193 is_temporary_(!info.save_info->file_path.empty()),
194 last_modified_time_(info.last_modified), 194 last_modified_time_(info.last_modified),
195 etag_(info.etag), 195 etag_(info.etag),
196 bound_net_log_(bound_net_log), 196 net_log_(net_log),
197 weak_ptr_factory_(this) { 197 weak_ptr_factory_(this) {
198 delegate_->Attach(); 198 delegate_->Attach();
199 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD); 199 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD);
200 200
201 // Link the event sources. 201 // Link the event sources.
202 bound_net_log_.AddEvent( 202 net_log_.AddEvent(
203 net::NetLogEventType::DOWNLOAD_URL_REQUEST, 203 net::NetLogEventType::DOWNLOAD_URL_REQUEST,
204 info.request_bound_net_log.source().ToEventParametersCallback()); 204 info.request_net_log.source().ToEventParametersCallback());
205 205
206 info.request_bound_net_log.AddEvent( 206 info.request_net_log.AddEvent(
207 net::NetLogEventType::DOWNLOAD_STARTED, 207 net::NetLogEventType::DOWNLOAD_STARTED,
208 bound_net_log_.source().ToEventParametersCallback()); 208 net_log_.source().ToEventParametersCallback());
209 } 209 }
210 210
211 // Constructing for the "Save Page As..." feature: 211 // Constructing for the "Save Page As..." feature:
212 DownloadItemImpl::DownloadItemImpl( 212 DownloadItemImpl::DownloadItemImpl(
213 DownloadItemImplDelegate* delegate, 213 DownloadItemImplDelegate* delegate,
214 uint32_t download_id, 214 uint32_t download_id,
215 const base::FilePath& path, 215 const base::FilePath& path,
216 const GURL& url, 216 const GURL& url,
217 const std::string& mime_type, 217 const std::string& mime_type,
218 std::unique_ptr<DownloadRequestHandleInterface> request_handle, 218 std::unique_ptr<DownloadRequestHandleInterface> request_handle,
219 const net::BoundNetLog& bound_net_log) 219 const net::NetLogWithSource& net_log)
220 : is_save_package_download_(true), 220 : is_save_package_download_(true),
221 request_handle_(std::move(request_handle)), 221 request_handle_(std::move(request_handle)),
222 guid_(base::ToUpperASCII(base::GenerateGUID())), 222 guid_(base::ToUpperASCII(base::GenerateGUID())),
223 download_id_(download_id), 223 download_id_(download_id),
224 target_path_(path), 224 target_path_(path),
225 url_chain_(1, url), 225 url_chain_(1, url),
226 mime_type_(mime_type), 226 mime_type_(mime_type),
227 original_mime_type_(mime_type), 227 original_mime_type_(mime_type),
228 start_tick_(base::TimeTicks::Now()), 228 start_tick_(base::TimeTicks::Now()),
229 state_(IN_PROGRESS_INTERNAL), 229 state_(IN_PROGRESS_INTERNAL),
230 start_time_(base::Time::Now()), 230 start_time_(base::Time::Now()),
231 delegate_(delegate), 231 delegate_(delegate),
232 current_path_(path), 232 current_path_(path),
233 bound_net_log_(bound_net_log), 233 net_log_(net_log),
234 weak_ptr_factory_(this) { 234 weak_ptr_factory_(this) {
235 delegate_->Attach(); 235 delegate_->Attach();
236 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS); 236 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS);
237 } 237 }
238 238
239 DownloadItemImpl::~DownloadItemImpl() { 239 DownloadItemImpl::~DownloadItemImpl() {
240 DCHECK_CURRENTLY_ON(BrowserThread::UI); 240 DCHECK_CURRENTLY_ON(BrowserThread::UI);
241 241
242 // Should always have been nuked before now, at worst in 242 // Should always have been nuked before now, at worst in
243 // DownloadManager shutdown. 243 // DownloadManager shutdown.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 DVLOG(20) << __func__ << "() download=" << DebugString(true); 275 DVLOG(20) << __func__ << "() download=" << DebugString(true);
276 276
277 if (IsDone() || !IsDangerous()) 277 if (IsDone() || !IsDangerous())
278 return; 278 return;
279 279
280 RecordDangerousDownloadAccept(GetDangerType(), 280 RecordDangerousDownloadAccept(GetDangerType(),
281 GetTargetFilePath()); 281 GetTargetFilePath());
282 282
283 danger_type_ = DOWNLOAD_DANGER_TYPE_USER_VALIDATED; 283 danger_type_ = DOWNLOAD_DANGER_TYPE_USER_VALIDATED;
284 284
285 bound_net_log_.AddEvent( 285 net_log_.AddEvent(
286 net::NetLogEventType::DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, 286 net::NetLogEventType::DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
287 base::Bind(&ItemCheckedNetLogCallback, GetDangerType())); 287 base::Bind(&ItemCheckedNetLogCallback, GetDangerType()));
288 288
289 UpdateObservers(); // TODO(asanka): This is potentially unsafe. The download 289 UpdateObservers(); // TODO(asanka): This is potentially unsafe. The download
290 // may not be in a consistent state or around at all after 290 // may not be in a consistent state or around at all after
291 // invoking observers. http://crbug.com/586610 291 // invoking observers. http://crbug.com/586610
292 292
293 MaybeCompleteDownload(); 293 MaybeCompleteDownload();
294 } 294 }
295 295
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 file_externally_removed_ = true; 978 file_externally_removed_ = true;
979 DVLOG(20) << __func__ << "() download=" << DebugString(true); 979 DVLOG(20) << __func__ << "() download=" << DebugString(true);
980 UpdateObservers(); 980 UpdateObservers();
981 } 981 }
982 982
983 base::WeakPtr<DownloadDestinationObserver> 983 base::WeakPtr<DownloadDestinationObserver>
984 DownloadItemImpl::DestinationObserverAsWeakPtr() { 984 DownloadItemImpl::DestinationObserverAsWeakPtr() {
985 return weak_ptr_factory_.GetWeakPtr(); 985 return weak_ptr_factory_.GetWeakPtr();
986 } 986 }
987 987
988 const net::BoundNetLog& DownloadItemImpl::GetBoundNetLog() const { 988 const net::NetLogWithSource& DownloadItemImpl::GetNetLogWithSource() const {
989 return bound_net_log_; 989 return net_log_;
990 } 990 }
991 991
992 void DownloadItemImpl::SetTotalBytes(int64_t total_bytes) { 992 void DownloadItemImpl::SetTotalBytes(int64_t total_bytes) {
993 total_bytes_ = total_bytes; 993 total_bytes_ = total_bytes;
994 } 994 }
995 995
996 void DownloadItemImpl::OnAllDataSaved( 996 void DownloadItemImpl::OnAllDataSaved(
997 int64_t total_bytes, 997 int64_t total_bytes,
998 std::unique_ptr<crypto::SecureHash> hash_state) { 998 std::unique_ptr<crypto::SecureHash> hash_state) {
999 DCHECK_CURRENTLY_ON(BrowserThread::UI); 999 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 30 matching lines...) Expand all
1030 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL); 1030 DCHECK(state_ == TARGET_PENDING_INTERNAL || state_ == IN_PROGRESS_INTERNAL);
1031 1031
1032 // There must be no pending destination_error_. 1032 // There must be no pending destination_error_.
1033 DCHECK_EQ(destination_error_, DOWNLOAD_INTERRUPT_REASON_NONE); 1033 DCHECK_EQ(destination_error_, DOWNLOAD_INTERRUPT_REASON_NONE);
1034 1034
1035 DVLOG(20) << __func__ << "() so_far=" << bytes_so_far 1035 DVLOG(20) << __func__ << "() so_far=" << bytes_so_far
1036 << " per_sec=" << bytes_per_sec 1036 << " per_sec=" << bytes_per_sec
1037 << " download=" << DebugString(true); 1037 << " download=" << DebugString(true);
1038 1038
1039 UpdateProgress(bytes_so_far, bytes_per_sec); 1039 UpdateProgress(bytes_so_far, bytes_per_sec);
1040 if (bound_net_log_.IsCapturing()) { 1040 if (net_log_.IsCapturing()) {
1041 bound_net_log_.AddEvent( 1041 net_log_.AddEvent(
1042 net::NetLogEventType::DOWNLOAD_ITEM_UPDATED, 1042 net::NetLogEventType::DOWNLOAD_ITEM_UPDATED,
1043 net::NetLog::Int64Callback("bytes_so_far", received_bytes_)); 1043 net::NetLog::Int64Callback("bytes_so_far", received_bytes_));
1044 } 1044 }
1045 1045
1046 UpdateObservers(); 1046 UpdateObservers();
1047 } 1047 }
1048 1048
1049 void DownloadItemImpl::DestinationError( 1049 void DownloadItemImpl::DestinationError(
1050 DownloadInterruptReason reason, 1050 DownloadInterruptReason reason,
1051 int64_t bytes_so_far, 1051 int64_t bytes_so_far,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 if (file_name.empty()) 1110 if (file_name.empty())
1111 file_name = suggested_filename_; 1111 file_name = suggested_filename_;
1112 // From the URL file name. 1112 // From the URL file name.
1113 if (file_name.empty()) 1113 if (file_name.empty())
1114 file_name = GetURL().ExtractFileName(); 1114 file_name = GetURL().ExtractFileName();
1115 } 1115 }
1116 1116
1117 net::NetLog::ParametersCallback active_data = 1117 net::NetLog::ParametersCallback active_data =
1118 base::Bind(&ItemActivatedNetLogCallback, this, download_type, &file_name); 1118 base::Bind(&ItemActivatedNetLogCallback, this, download_type, &file_name);
1119 if (active) { 1119 if (active) {
1120 bound_net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE, 1120 net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE,
1121 active_data); 1121 active_data);
1122 } else { 1122 } else {
1123 bound_net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE, 1123 net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE,
1124 active_data); 1124 active_data);
1125 } 1125 }
1126 1126
1127 DVLOG(20) << __func__ << "() " << DebugString(true); 1127 DVLOG(20) << __func__ << "() " << DebugString(true);
1128 } 1128 }
1129 1129
1130 // We're starting the download. 1130 // We're starting the download.
1131 void DownloadItemImpl::Start( 1131 void DownloadItemImpl::Start(
1132 std::unique_ptr<DownloadFile> file, 1132 std::unique_ptr<DownloadFile> file,
1133 std::unique_ptr<DownloadRequestHandleInterface> req_handle, 1133 std::unique_ptr<DownloadRequestHandleInterface> req_handle,
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 break; 1748 break;
1749 1749
1750 case COMPLETING_INTERNAL: 1750 case COMPLETING_INTERNAL:
1751 DCHECK(all_data_saved_) << "All data must be saved prior to completion."; 1751 DCHECK(all_data_saved_) << "All data must be saved prior to completion.";
1752 DCHECK(!download_file_) 1752 DCHECK(!download_file_)
1753 << "Download file must be released prior to completion."; 1753 << "Download file must be released prior to completion.";
1754 DCHECK(!target_path_.empty()) << "Target path must be known."; 1754 DCHECK(!target_path_.empty()) << "Target path must be known.";
1755 DCHECK(current_path_ == target_path_) 1755 DCHECK(current_path_ == target_path_)
1756 << "Current output path must match target path."; 1756 << "Current output path must match target path.";
1757 1757
1758 bound_net_log_.AddEvent( 1758 net_log_.AddEvent(
1759 net::NetLogEventType::DOWNLOAD_ITEM_COMPLETING, 1759 net::NetLogEventType::DOWNLOAD_ITEM_COMPLETING,
1760 base::Bind(&ItemCompletingNetLogCallback, received_bytes_, &hash_)); 1760 base::Bind(&ItemCompletingNetLogCallback, received_bytes_, &hash_));
1761 break; 1761 break;
1762 1762
1763 case COMPLETE_INTERNAL: 1763 case COMPLETE_INTERNAL:
1764 bound_net_log_.AddEvent( 1764 net_log_.AddEvent(
1765 net::NetLogEventType::DOWNLOAD_ITEM_FINISHED, 1765 net::NetLogEventType::DOWNLOAD_ITEM_FINISHED,
1766 base::Bind(&ItemFinishedNetLogCallback, auto_opened_)); 1766 base::Bind(&ItemFinishedNetLogCallback, auto_opened_));
1767 break; 1767 break;
1768 1768
1769 case INTERRUPTED_INTERNAL: 1769 case INTERRUPTED_INTERNAL:
1770 bound_net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_INTERRUPTED, 1770 net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_INTERRUPTED,
1771 base::Bind(&ItemInterruptedNetLogCallback, 1771 base::Bind(&ItemInterruptedNetLogCallback,
1772 last_reason_, received_bytes_)); 1772 last_reason_, received_bytes_));
1773 break; 1773 break;
1774 1774
1775 case RESUMING_INTERNAL: 1775 case RESUMING_INTERNAL:
1776 bound_net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_RESUMED, 1776 net_log_.AddEvent(net::NetLogEventType::DOWNLOAD_ITEM_RESUMED,
1777 base::Bind(&ItemResumingNetLogCallback, false, 1777 base::Bind(&ItemResumingNetLogCallback, false,
1778 last_reason_, received_bytes_)); 1778 last_reason_, received_bytes_));
1779 break; 1779 break;
1780 1780
1781 case CANCELLED_INTERNAL: 1781 case CANCELLED_INTERNAL:
1782 bound_net_log_.AddEvent( 1782 net_log_.AddEvent(
1783 net::NetLogEventType::DOWNLOAD_ITEM_CANCELED, 1783 net::NetLogEventType::DOWNLOAD_ITEM_CANCELED,
1784 base::Bind(&ItemCanceledNetLogCallback, received_bytes_)); 1784 base::Bind(&ItemCanceledNetLogCallback, received_bytes_));
1785 break; 1785 break;
1786 1786
1787 case MAX_DOWNLOAD_INTERNAL_STATE: 1787 case MAX_DOWNLOAD_INTERNAL_STATE:
1788 NOTREACHED(); 1788 NOTREACHED();
1789 break; 1789 break;
1790 } 1790 }
1791 1791
1792 DVLOG(20) << __func__ << "() from:" << DebugDownloadStateString(old_state) 1792 DVLOG(20) << __func__ << "() from:" << DebugDownloadStateString(old_state)
1793 << " to:" << DebugDownloadStateString(state_) 1793 << " to:" << DebugDownloadStateString(state_)
1794 << " this = " << DebugString(true); 1794 << " this = " << DebugString(true);
1795 bool is_done = 1795 bool is_done =
1796 (state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || 1796 (state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL ||
1797 state_ == RESUMING_INTERNAL || state_ == CANCELLED_INTERNAL); 1797 state_ == RESUMING_INTERNAL || state_ == CANCELLED_INTERNAL);
1798 bool was_done = 1798 bool was_done =
1799 (old_state == COMPLETE_INTERNAL || old_state == INTERRUPTED_INTERNAL || 1799 (old_state == COMPLETE_INTERNAL || old_state == INTERRUPTED_INTERNAL ||
1800 old_state == RESUMING_INTERNAL || old_state == CANCELLED_INTERNAL); 1800 old_state == RESUMING_INTERNAL || old_state == CANCELLED_INTERNAL);
1801 1801
1802 // Termination 1802 // Termination
1803 if (is_done && !was_done) 1803 if (is_done && !was_done)
1804 bound_net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE); 1804 net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE);
1805 1805
1806 // Resumption 1806 // Resumption
1807 if (was_done && !is_done) { 1807 if (was_done && !is_done) {
1808 std::string file_name(target_path_.BaseName().AsUTF8Unsafe()); 1808 std::string file_name(target_path_.BaseName().AsUTF8Unsafe());
1809 bound_net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE, 1809 net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_ITEM_ACTIVE,
1810 base::Bind(&ItemActivatedNetLogCallback, this, 1810 base::Bind(&ItemActivatedNetLogCallback, this,
1811 SRC_ACTIVE_DOWNLOAD, &file_name)); 1811 SRC_ACTIVE_DOWNLOAD, &file_name));
1812 } 1812 }
1813 } 1813 }
1814 1814
1815 void DownloadItemImpl::SetDangerType(DownloadDangerType danger_type) { 1815 void DownloadItemImpl::SetDangerType(DownloadDangerType danger_type) {
1816 if (danger_type != danger_type_) { 1816 if (danger_type != danger_type_) {
1817 bound_net_log_.AddEvent( 1817 net_log_.AddEvent(
1818 net::NetLogEventType::DOWNLOAD_ITEM_SAFETY_STATE_UPDATED, 1818 net::NetLogEventType::DOWNLOAD_ITEM_SAFETY_STATE_UPDATED,
1819 base::Bind(&ItemCheckedNetLogCallback, danger_type)); 1819 base::Bind(&ItemCheckedNetLogCallback, danger_type));
1820 } 1820 }
1821 // Only record the Malicious UMA stat if it's going from {not malicious} -> 1821 // Only record the Malicious UMA stat if it's going from {not malicious} ->
1822 // {malicious}. 1822 // {malicious}.
1823 if ((danger_type_ == DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || 1823 if ((danger_type_ == DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS ||
1824 danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || 1824 danger_type_ == DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
1825 danger_type_ == DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || 1825 danger_type_ == DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT ||
1826 danger_type_ == DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) && 1826 danger_type_ == DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) &&
1827 (danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || 1827 (danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST ||
1828 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 1828 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
1829 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || 1829 danger_type == DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
1830 danger_type == DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED)) { 1830 danger_type == DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED)) {
1831 RecordMaliciousDownloadClassified(danger_type); 1831 RecordMaliciousDownloadClassified(danger_type);
1832 } 1832 }
1833 danger_type_ = danger_type; 1833 danger_type_ = danger_type;
1834 } 1834 }
1835 1835
1836 void DownloadItemImpl::SetFullPath(const base::FilePath& new_path) { 1836 void DownloadItemImpl::SetFullPath(const base::FilePath& new_path) {
1837 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1837 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1838 DVLOG(20) << __func__ << "() new_path = \"" << new_path.value() << "\" " 1838 DVLOG(20) << __func__ << "() new_path = \"" << new_path.value() << "\" "
1839 << DebugString(true); 1839 << DebugString(true);
1840 DCHECK(!new_path.empty()); 1840 DCHECK(!new_path.empty());
1841 1841
1842 bound_net_log_.AddEvent( 1842 net_log_.AddEvent(
1843 net::NetLogEventType::DOWNLOAD_ITEM_RENAMED, 1843 net::NetLogEventType::DOWNLOAD_ITEM_RENAMED,
1844 base::Bind(&ItemRenamedNetLogCallback, &current_path_, &new_path)); 1844 base::Bind(&ItemRenamedNetLogCallback, &current_path_, &new_path));
1845 1845
1846 current_path_ = new_path; 1846 current_path_ = new_path;
1847 } 1847 }
1848 1848
1849 void DownloadItemImpl::AutoResumeIfValid() { 1849 void DownloadItemImpl::AutoResumeIfValid() {
1850 DVLOG(20) << __func__ << "() " << DebugString(true); 1850 DVLOG(20) << __func__ << "() " << DebugString(true);
1851 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1851 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1852 ResumeMode mode = GetResumeMode(); 1852 ResumeMode mode = GetResumeMode();
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 case RESUME_MODE_USER_CONTINUE: 2086 case RESUME_MODE_USER_CONTINUE:
2087 return "USER_CONTINUE"; 2087 return "USER_CONTINUE";
2088 case RESUME_MODE_USER_RESTART: 2088 case RESUME_MODE_USER_RESTART:
2089 return "USER_RESTART"; 2089 return "USER_RESTART";
2090 } 2090 }
2091 NOTREACHED() << "Unknown resume mode " << mode; 2091 NOTREACHED() << "Unknown resume mode " << mode;
2092 return "unknown"; 2092 return "unknown";
2093 } 2093 }
2094 2094
2095 } // namespace content 2095 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698