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

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

Issue 1751603002: [Downloads] Rework how hashes are calculated for download files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on top of https://codereview.chromium.org/1781983002 since that's going in first. Created 4 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
« no previous file with comments | « content/browser/download/save_file.h ('k') | content/browser/download/save_package.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/save_file.h" 5 #include "content/browser/download/save_file.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 9
10 namespace content { 10 namespace content {
11 11
12 // TODO(asanka): SaveFile should use the target directory of the save package as 12 // TODO(asanka): SaveFile should use the target directory of the save package as
13 // the default download directory when initializing |file_|. 13 // the default download directory when initializing |file_|.
14 // Unfortunately, as it is, constructors of SaveFile don't always 14 // Unfortunately, as it is, constructors of SaveFile don't always
15 // have access to the SavePackage at this point. 15 // have access to the SavePackage at this point.
16 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash) 16 SaveFile::SaveFile(const SaveFileCreateInfo* info, bool calculate_hash)
17 : file_(base::FilePath(), 17 : file_(net::BoundNetLog()), info_(info) {
18 info->url,
19 GURL(),
20 0,
21 calculate_hash,
22 std::string(),
23 base::File(),
24 net::BoundNetLog()),
25 info_(info) {
26 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 18 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
27 19
28 DCHECK(info); 20 DCHECK(info);
29 DCHECK(info->path.empty()); 21 DCHECK(info->path.empty());
30 } 22 }
31 23
32 SaveFile::~SaveFile() { 24 SaveFile::~SaveFile() {
33 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 25 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
34 } 26 }
35 27
36 DownloadInterruptReason SaveFile::Initialize() { 28 DownloadInterruptReason SaveFile::Initialize() {
37 return file_.Initialize(base::FilePath()); 29 return file_.Initialize(base::FilePath(),
30 base::FilePath(),
31 base::File(),
32 0,
33 std::string(),
34 scoped_ptr<crypto::SecureHash>());
38 } 35 }
39 36
40 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data, 37 DownloadInterruptReason SaveFile::AppendDataToFile(const char* data,
41 size_t data_len) { 38 size_t data_len) {
42 return file_.AppendDataToFile(data, data_len); 39 return file_.AppendDataToFile(data, data_len);
43 } 40 }
44 41
45 DownloadInterruptReason SaveFile::Rename(const base::FilePath& full_path) { 42 DownloadInterruptReason SaveFile::Rename(const base::FilePath& full_path) {
46 return file_.Rename(full_path); 43 return file_.Rename(full_path);
47 } 44 }
48 45
49 void SaveFile::Detach() { 46 void SaveFile::Detach() {
50 file_.Detach(); 47 file_.Detach();
51 } 48 }
52 49
53 void SaveFile::Cancel() { 50 void SaveFile::Cancel() {
54 file_.Cancel(); 51 file_.Cancel();
55 } 52 }
56 53
57 void SaveFile::Finish() { 54 void SaveFile::Finish() {
58 file_.Finish(); 55 file_.Finish();
59 } 56 }
60 57
61 void SaveFile::AnnotateWithSourceInformation() { 58 void SaveFile::AnnotateWithSourceInformation() {
62 // TODO(gbillock): If this method is called, it should set the 59 // TODO(gbillock): If this method is called, it should set the
63 // file_.SetClientGuid() method first. 60 // file_.SetClientGuid() method first.
64 file_.AnnotateWithSourceInformation(); 61 NOTREACHED();
65 } 62 }
66 63
67 base::FilePath SaveFile::FullPath() const { 64 base::FilePath SaveFile::FullPath() const {
68 return file_.full_path(); 65 return file_.full_path();
69 } 66 }
70 67
71 bool SaveFile::InProgress() const { 68 bool SaveFile::InProgress() const {
72 return file_.in_progress(); 69 return file_.in_progress();
73 } 70 }
74 71
75 int64_t SaveFile::BytesSoFar() const { 72 int64_t SaveFile::BytesSoFar() const {
76 return file_.bytes_so_far(); 73 return file_.bytes_so_far();
77 } 74 }
78 75
79 bool SaveFile::GetHash(std::string* hash) {
80 return file_.GetHash(hash);
81 }
82
83 std::string SaveFile::DebugString() const { 76 std::string SaveFile::DebugString() const {
84 return file_.DebugString(); 77 return file_.DebugString();
85 } 78 }
86 79
87 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/save_file.h ('k') | content/browser/download/save_package.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698