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

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

Issue 10695062: Improve download performance statistics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid division by zero errors. 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
« no previous file with comments | « no previous file | content/browser/download/download_resource_handler.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 #include "content/browser/download/download_file_impl.h" 5 #include "content/browser/download/download_file_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 switch (state) { 176 switch (state) {
177 case content::ByteStreamReader::STREAM_EMPTY: 177 case content::ByteStreamReader::STREAM_EMPTY:
178 break; 178 break;
179 case content::ByteStreamReader::STREAM_HAS_DATA: 179 case content::ByteStreamReader::STREAM_HAS_DATA:
180 { 180 {
181 ++num_buffers; 181 ++num_buffers;
182 base::TimeTicks write_start(base::TimeTicks::Now()); 182 base::TimeTicks write_start(base::TimeTicks::Now());
183 result = AppendDataToFile( 183 result = AppendDataToFile(
184 incoming_data.get()->data(), incoming_data_size); 184 incoming_data.get()->data(), incoming_data_size);
185 disk_writes_time_ += (base::TimeTicks::Now() - write_start); 185 disk_writes_time_ += (base::TimeTicks::Now() - write_start);
186 bytes_seen_ += incoming_data_size;
186 total_incoming_data_size += incoming_data_size; 187 total_incoming_data_size += incoming_data_size;
187 reason = content::ConvertNetErrorToInterruptReason( 188 reason = content::ConvertNetErrorToInterruptReason(
188 result, content::DOWNLOAD_INTERRUPT_FROM_DISK); 189 result, content::DOWNLOAD_INTERRUPT_FROM_DISK);
189 } 190 }
190 break; 191 break;
191 case content::ByteStreamReader::STREAM_COMPLETE: 192 case content::ByteStreamReader::STREAM_COMPLETE:
192 { 193 {
193 reason = stream_reader_->GetStatus(); 194 reason = stream_reader_->GetStatus();
194 SendUpdate(); 195 SendUpdate();
195 base::TimeTicks close_start(base::TimeTicks::Now()); 196 base::TimeTicks close_start(base::TimeTicks::Now());
(...skipping 18 matching lines...) Expand all
214 if (state == content::ByteStreamReader::STREAM_HAS_DATA && 215 if (state == content::ByteStreamReader::STREAM_HAS_DATA &&
215 now - start > delta) { 216 now - start > delta) {
216 BrowserThread::PostTask( 217 BrowserThread::PostTask(
217 BrowserThread::FILE, FROM_HERE, 218 BrowserThread::FILE, FROM_HERE,
218 base::Bind(&DownloadFileImpl::StreamActive, 219 base::Bind(&DownloadFileImpl::StreamActive,
219 weak_factory_.GetWeakPtr())); 220 weak_factory_.GetWeakPtr()));
220 } 221 }
221 222
222 if (total_incoming_data_size) 223 if (total_incoming_data_size)
223 download_stats::RecordFileThreadReceiveBuffers(num_buffers); 224 download_stats::RecordFileThreadReceiveBuffers(num_buffers);
224 bytes_seen_ += total_incoming_data_size;
225 225
226 download_stats::RecordContiguousWriteTime(now - start); 226 download_stats::RecordContiguousWriteTime(now - start);
227 227
228 // Take care of communication with our controller. 228 // Take care of communication with our controller.
229 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) { 229 if (reason != content::DOWNLOAD_INTERRUPT_REASON_NONE) {
230 // Error case for both upstream source and file write. 230 // Error case for both upstream source and file write.
231 // Shut down processing and signal an error to our controller. 231 // Shut down processing and signal an error to our controller.
232 // Our controller will clean us up. 232 // Our controller will clean us up.
233 stream_reader_->RegisterCallback(base::Closure()); 233 stream_reader_->RegisterCallback(base::Closure());
234 weak_factory_.InvalidateWeakPtrs(); 234 weak_factory_.InvalidateWeakPtrs();
(...skipping 29 matching lines...) Expand all
264 264
265 void DownloadFileImpl::SendUpdate() { 265 void DownloadFileImpl::SendUpdate() {
266 if (download_manager_.get()) { 266 if (download_manager_.get()) {
267 BrowserThread::PostTask( 267 BrowserThread::PostTask(
268 BrowserThread::UI, FROM_HERE, 268 BrowserThread::UI, FROM_HERE,
269 base::Bind(&DownloadManager::UpdateDownload, 269 base::Bind(&DownloadManager::UpdateDownload,
270 download_manager_, id_.local(), 270 download_manager_, id_.local(),
271 BytesSoFar(), CurrentSpeed(), GetHashState())); 271 BytesSoFar(), CurrentSpeed(), GetHashState()));
272 } 272 }
273 } 273 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698