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

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

Issue 10799005: Replace the DownloadFileManager with direct ownership (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to LKGR. Created 8 years, 4 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 | « content/browser/download/base_file.h ('k') | content/browser/download/download_file.h » ('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/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 const net::BoundNetLog& bound_net_log) 213 const net::BoundNetLog& bound_net_log)
214 : full_path_(full_path), 214 : full_path_(full_path),
215 source_url_(source_url), 215 source_url_(source_url),
216 referrer_url_(referrer_url), 216 referrer_url_(referrer_url),
217 file_stream_(file_stream), 217 file_stream_(file_stream),
218 bytes_so_far_(received_bytes), 218 bytes_so_far_(received_bytes),
219 start_tick_(base::TimeTicks::Now()), 219 start_tick_(base::TimeTicks::Now()),
220 calculate_hash_(calculate_hash), 220 calculate_hash_(calculate_hash),
221 detached_(false), 221 detached_(false),
222 bound_net_log_(bound_net_log) { 222 bound_net_log_(bound_net_log) {
223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
224 memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen); 223 memcpy(sha256_hash_, kEmptySha256Hash, kSha256HashLen);
225 if (file_stream_.get()) { 224 if (file_stream_.get()) {
226 file_stream_->SetBoundNetLogSource(bound_net_log_); 225 file_stream_->SetBoundNetLogSource(bound_net_log_);
227 file_stream_->EnableErrorStatistics(); 226 file_stream_->EnableErrorStatistics();
228 } 227 }
229 228
230 if (calculate_hash_) { 229 if (calculate_hash_) {
231 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 230 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256));
232 if ((bytes_so_far_ > 0) && // Not starting at the beginning. 231 if ((bytes_so_far_ > 0) && // Not starting at the beginning.
233 (hash_state != "") && // Reasonably sure we have a hash state. 232 (hash_state != "") && // Reasonably sure we have a hash state.
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 base::TimeDelta diff = current_time - start_tick_; 550 base::TimeDelta diff = current_time - start_tick_;
552 int64 diff_ms = diff.InMilliseconds(); 551 int64 diff_ms = diff.InMilliseconds();
553 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 552 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
554 } 553 }
555 554
556 int64 BaseFile::CurrentSpeed() const { 555 int64 BaseFile::CurrentSpeed() const {
557 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 556 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
558 return CurrentSpeedAtTime(base::TimeTicks::Now()); 557 return CurrentSpeedAtTime(base::TimeTicks::Now());
559 } 558 }
560 559
OLDNEW
« no previous file with comments | « content/browser/download/base_file.h ('k') | content/browser/download/download_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698