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

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

Issue 1513413002: Enable "Hide Extension" option when "Save Link As" on the Mac Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits. Created 5 years 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
« no previous file with comments | « content/browser/download/base_file.h ('k') | content/browser/download/base_file_mac.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/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 23 matching lines...) Expand all
34 base::File file, 34 base::File file,
35 const net::BoundNetLog& bound_net_log) 35 const net::BoundNetLog& bound_net_log)
36 : full_path_(full_path), 36 : full_path_(full_path),
37 source_url_(source_url), 37 source_url_(source_url),
38 referrer_url_(referrer_url), 38 referrer_url_(referrer_url),
39 file_(file.Pass()), 39 file_(file.Pass()),
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 hide_file_extension_(false) {
45 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length); 46 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length);
46 if (calculate_hash_) { 47 if (calculate_hash_) {
47 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 48 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256));
48 if ((bytes_so_far_ > 0) && // Not starting at the beginning. 49 if ((bytes_so_far_ > 0) && // Not starting at the beginning.
49 (!IsEmptyHash(hash_state_bytes))) { 50 (!IsEmptyHash(hash_state_bytes))) {
50 base::Pickle hash_state(hash_state_bytes.c_str(), 51 base::Pickle hash_state(hash_state_bytes.c_str(),
51 hash_state_bytes.size()); 52 hash_state_bytes.size());
52 base::PickleIterator data_iterator(hash_state); 53 base::PickleIterator data_iterator(hash_state);
53 secure_hash_->Deserialize(&data_iterator); 54 secure_hash_->Deserialize(&data_iterator);
54 } 55 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return base::StringPrintf("{ source_url_ = \"%s\"" 245 return base::StringPrintf("{ source_url_ = \"%s\""
245 " full_path_ = \"%" PRFilePath "\"" 246 " full_path_ = \"%" PRFilePath "\""
246 " bytes_so_far_ = %" PRId64 247 " bytes_so_far_ = %" PRId64
247 " detached_ = %c }", 248 " detached_ = %c }",
248 source_url_.spec().c_str(), 249 source_url_.spec().c_str(),
249 full_path_.value().c_str(), 250 full_path_.value().c_str(),
250 bytes_so_far_, 251 bytes_so_far_,
251 detached_ ? 'T' : 'F'); 252 detached_ ? 'T' : 'F');
252 } 253 }
253 254
255 void BaseFile::set_hide_file_extension(bool hide_file_extension) {
256 hide_file_extension_ = hide_file_extension;
257 }
258
254 DownloadInterruptReason BaseFile::Open() { 259 DownloadInterruptReason BaseFile::Open() {
255 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 260 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
256 DCHECK(!detached_); 261 DCHECK(!detached_);
257 DCHECK(!full_path_.empty()); 262 DCHECK(!full_path_.empty());
258 263
259 bound_net_log_.BeginEvent( 264 bound_net_log_.BeginEvent(
260 net::NetLog::TYPE_DOWNLOAD_FILE_OPENED, 265 net::NetLog::TYPE_DOWNLOAD_FILE_OPENED,
261 base::Bind(&FileOpenedNetLogCallback, &full_path_, bytes_so_far_)); 266 base::Bind(&FileOpenedNetLogCallback, &full_path_, bytes_so_far_));
262 267
263 // Create a new file if it is not provided. 268 // Create a new file if it is not provided.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 const char* operation, 345 const char* operation,
341 int os_error, 346 int os_error,
342 DownloadInterruptReason reason) { 347 DownloadInterruptReason reason) {
343 bound_net_log_.AddEvent( 348 bound_net_log_.AddEvent(
344 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, 349 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR,
345 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); 350 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason));
346 return reason; 351 return reason;
347 } 352 }
348 353
349 } // namespace content 354 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/base_file.h ('k') | content/browser/download/base_file_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698