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

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

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 #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/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 29 matching lines...) Expand all
40 bytes_so_far_(received_bytes), 40 bytes_so_far_(received_bytes),
41 start_tick_(base::TimeTicks::Now()), 41 start_tick_(base::TimeTicks::Now()),
42 calculate_hash_(calculate_hash), 42 calculate_hash_(calculate_hash),
43 detached_(false), 43 detached_(false),
44 bound_net_log_(bound_net_log) { 44 bound_net_log_(bound_net_log) {
45 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length); 45 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length);
46 if (calculate_hash_) { 46 if (calculate_hash_) {
47 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 47 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256));
48 if ((bytes_so_far_ > 0) && // Not starting at the beginning. 48 if ((bytes_so_far_ > 0) && // Not starting at the beginning.
49 (!IsEmptyHash(hash_state_bytes))) { 49 (!IsEmptyHash(hash_state_bytes))) {
50 Pickle hash_state(hash_state_bytes.c_str(), hash_state_bytes.size()); 50 base::Pickle hash_state(hash_state_bytes.c_str(),
51 PickleIterator data_iterator(hash_state); 51 hash_state_bytes.size());
52 base::PickleIterator data_iterator(hash_state);
52 secure_hash_->Deserialize(&data_iterator); 53 secure_hash_->Deserialize(&data_iterator);
53 } 54 }
54 } 55 }
55 } 56 }
56 57
57 BaseFile::~BaseFile() { 58 BaseFile::~BaseFile() {
58 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 59 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
59 if (detached_) 60 if (detached_)
60 Close(); 61 Close();
61 else 62 else
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 DCHECK(!detached_); 219 DCHECK(!detached_);
219 hash->assign(reinterpret_cast<const char*>(sha256_hash_), 220 hash->assign(reinterpret_cast<const char*>(sha256_hash_),
220 sizeof(sha256_hash_)); 221 sizeof(sha256_hash_));
221 return (calculate_hash_ && !in_progress()); 222 return (calculate_hash_ && !in_progress());
222 } 223 }
223 224
224 std::string BaseFile::GetHashState() { 225 std::string BaseFile::GetHashState() {
225 if (!calculate_hash_) 226 if (!calculate_hash_)
226 return std::string(); 227 return std::string();
227 228
228 Pickle hash_state; 229 base::Pickle hash_state;
229 if (!secure_hash_->Serialize(&hash_state)) 230 if (!secure_hash_->Serialize(&hash_state))
230 return std::string(); 231 return std::string();
231 232
232 return std::string(reinterpret_cast<const char*>(hash_state.data()), 233 return std::string(reinterpret_cast<const char*>(hash_state.data()),
233 hash_state.size()); 234 hash_state.size());
234 } 235 }
235 236
236 // static 237 // static
237 bool BaseFile::IsEmptyHash(const std::string& hash) { 238 bool BaseFile::IsEmptyHash(const std::string& hash) {
238 return (hash.size() == crypto::kSHA256Length && 239 return (hash.size() == crypto::kSHA256Length &&
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 const char* operation, 340 const char* operation,
340 int os_error, 341 int os_error,
341 DownloadInterruptReason reason) { 342 DownloadInterruptReason reason) {
342 bound_net_log_.AddEvent( 343 bound_net_log_.AddEvent(
343 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, 344 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR,
344 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); 345 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason));
345 return reason; 346 return reason;
346 } 347 }
347 348
348 } // namespace content 349 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_message_filter.cc ('k') | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698