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

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

Issue 7583049: Record UMA statistics for file_stream operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed extra logging. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/file_stream.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 : full_path_(full_path), 191 : full_path_(full_path),
192 source_url_(source_url), 192 source_url_(source_url),
193 referrer_url_(referrer_url), 193 referrer_url_(referrer_url),
194 file_stream_(file_stream), 194 file_stream_(file_stream),
195 bytes_so_far_(received_bytes), 195 bytes_so_far_(received_bytes),
196 power_save_blocker_(true), 196 power_save_blocker_(true),
197 calculate_hash_(false), 197 calculate_hash_(false),
198 detached_(false) { 198 detached_(false) {
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
200 memset(sha256_hash_, 0, sizeof(sha256_hash_)); 200 memset(sha256_hash_, 0, sizeof(sha256_hash_));
201 if (file_stream_.get())
202 file_stream_->EnableErrorStatistics();
201 } 203 }
202 204
203 BaseFile::~BaseFile() { 205 BaseFile::~BaseFile() {
204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
205 if (detached_) 207 if (detached_)
206 Close(); 208 Close();
207 else 209 else
208 Cancel(); // Will delete the file. 210 Cancel(); // Will delete the file.
209 } 211 }
210 212
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 383 }
382 384
383 net::Error BaseFile::Open() { 385 net::Error BaseFile::Open() {
384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
385 DCHECK(!detached_); 387 DCHECK(!detached_);
386 DCHECK(!full_path_.empty()); 388 DCHECK(!full_path_.empty());
387 389
388 // Create a new file stream if it is not provided. 390 // Create a new file stream if it is not provided.
389 if (!file_stream_.get()) { 391 if (!file_stream_.get()) {
390 CreateFileStream(); 392 CreateFileStream();
393 file_stream_->EnableErrorStatistics();
391 int open_result = file_stream_->Open( 394 int open_result = file_stream_->Open(
392 full_path_, 395 full_path_,
393 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE); 396 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_WRITE);
394 if (open_result != net::OK) { 397 if (open_result != net::OK) {
395 file_stream_.reset(); 398 file_stream_.reset();
396 return LOG_ERROR("Open", open_result); 399 return LOG_ERROR("Open", open_result);
397 } 400 }
398 401
399 // We may be re-opening the file after rename. Always make sure we're 402 // We may be re-opening the file after rename. Always make sure we're
400 // writing at the end of the file. 403 // writing at the end of the file.
(...skipping 25 matching lines...) Expand all
426 429
427 std::string BaseFile::DebugString() const { 430 std::string BaseFile::DebugString() const {
428 return base::StringPrintf("{ source_url_ = \"%s\"" 431 return base::StringPrintf("{ source_url_ = \"%s\""
429 " full_path_ = \"%" PRFilePath "\"" 432 " full_path_ = \"%" PRFilePath "\""
430 " bytes_so_far_ = %" PRId64 " detached_ = %c }", 433 " bytes_so_far_ = %" PRId64 " detached_ = %c }",
431 source_url_.spec().c_str(), 434 source_url_.spec().c_str(),
432 full_path_.value().c_str(), 435 full_path_.value().c_str(),
433 bytes_so_far_, 436 bytes_so_far_,
434 detached_ ? 'T' : 'F'); 437 detached_ ? 'T' : 'F');
435 } 438 }
OLDNEW
« no previous file with comments | « no previous file | net/base/file_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698