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

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

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 years, 9 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
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/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/pickle.h" 10 #include "base/pickle.h"
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 448
449 return std::string(reinterpret_cast<const char*>(hash_state.data()), 449 return std::string(reinterpret_cast<const char*>(hash_state.data()),
450 hash_state.size()); 450 hash_state.size());
451 } 451 }
452 452
453 bool BaseFile::SetHashState(const std::string& hash_state_bytes) { 453 bool BaseFile::SetHashState(const std::string& hash_state_bytes) {
454 if (!calculate_hash_) 454 if (!calculate_hash_)
455 return false; 455 return false;
456 456
457 Pickle hash_state(hash_state_bytes.c_str(), hash_state_bytes.size()); 457 Pickle hash_state(hash_state_bytes.c_str(), hash_state_bytes.size());
458 void* data_iterator = NULL; 458 PickleIterator data_iterator(hash_state);
459 459
460 return secure_hash_->Deserialize(&data_iterator, &hash_state); 460 return secure_hash_->Deserialize(&data_iterator);
461 } 461 }
462 462
463 bool BaseFile::IsEmptyHash(const std::string& hash) { 463 bool BaseFile::IsEmptyHash(const std::string& hash) {
464 return (hash.size() == kSha256HashLen && 464 return (hash.size() == kSha256HashLen &&
465 0 == memcmp(hash.data(), kEmptySha256Hash, sizeof(kSha256HashLen))); 465 0 == memcmp(hash.data(), kEmptySha256Hash, sizeof(kSha256HashLen)));
466 } 466 }
467 467
468 void BaseFile::AnnotateWithSourceInformation() { 468 void BaseFile::AnnotateWithSourceInformation() {
469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
470 DCHECK(!detached_); 470 DCHECK(!detached_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const { 562 int64 BaseFile::CurrentSpeedAtTime(base::TimeTicks current_time) const {
563 base::TimeDelta diff = current_time - start_tick_; 563 base::TimeDelta diff = current_time - start_tick_;
564 int64 diff_ms = diff.InMilliseconds(); 564 int64 diff_ms = diff.InMilliseconds();
565 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms; 565 return diff_ms == 0 ? 0 : bytes_so_far() * 1000 / diff_ms;
566 } 566 }
567 567
568 int64 BaseFile::CurrentSpeed() const { 568 int64 BaseFile::CurrentSpeed() const {
569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
570 return CurrentSpeedAtTime(base::TimeTicks::Now()); 570 return CurrentSpeedAtTime(base::TimeTicks::Now());
571 } 571 }
OLDNEW
« no previous file with comments | « chrome_frame/cfproxy_support.cc ('k') | content/browser/renderer_host/render_sandbox_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698