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

Side by Side Diff: content/browser/download/download_file.h

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
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 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/download_interrupt_reasons.h" 15 #include "content/public/browser/download_interrupt_reasons.h"
16 16
17 class GURL;
18
17 namespace content { 19 namespace content {
18 20
19 class DownloadManager; 21 class DownloadManager;
20 22
21 // These objects live exclusively on the file thread and handle the writing 23 // These objects live exclusively on the file thread and handle the writing
22 // operations for one download. These objects live only for the duration that 24 // operations for one download. These objects live only for the duration that
23 // the download is 'in progress': once the download has been completed or 25 // the download is 'in progress': once the download has been completed or
24 // cancelled, the DownloadFile is destroyed. 26 // cancelled, the DownloadFile is destroyed.
25 class CONTENT_EXPORT DownloadFile { 27 class CONTENT_EXPORT DownloadFile {
26 public: 28 public:
(...skipping 21 matching lines...) Expand all
48 // Rename the download file to |full_path|. If that file exists 50 // Rename the download file to |full_path|. If that file exists
49 // |full_path| will be uniquified by suffixing " (<number>)" to the 51 // |full_path| will be uniquified by suffixing " (<number>)" to the
50 // file name before the extension. 52 // file name before the extension.
51 virtual void RenameAndUniquify(const base::FilePath& full_path, 53 virtual void RenameAndUniquify(const base::FilePath& full_path,
52 const RenameCompletionCallback& callback) = 0; 54 const RenameCompletionCallback& callback) = 0;
53 55
54 // Rename the download file to |full_path| and annotate it with 56 // Rename the download file to |full_path| and annotate it with
55 // "Mark of the Web" information about its source. No uniquification 57 // "Mark of the Web" information about its source. No uniquification
56 // will be performed. 58 // will be performed.
57 virtual void RenameAndAnnotate(const base::FilePath& full_path, 59 virtual void RenameAndAnnotate(const base::FilePath& full_path,
60 const std::string& client_guid,
61 const GURL& source_url,
62 const GURL& referrer_url,
58 const RenameCompletionCallback& callback) = 0; 63 const RenameCompletionCallback& callback) = 0;
59 64
60 // Detach the file so it is not deleted on destruction. 65 // Detach the file so it is not deleted on destruction.
61 virtual void Detach() = 0; 66 virtual void Detach() = 0;
62 67
63 // Abort the download and automatically close the file. 68 // Abort the download and automatically close the file.
64 virtual void Cancel() = 0; 69 virtual void Cancel() = 0;
65 70
66 virtual base::FilePath FullPath() const = 0; 71 virtual const base::FilePath& FullPath() const = 0;
67 virtual bool InProgress() const = 0; 72 virtual bool InProgress() const = 0;
68 virtual int64_t CurrentSpeed() const = 0;
69
70 // Set |hash| with sha256 digest for the file.
71 // Returns true if digest is successfully calculated.
72 virtual bool GetHash(std::string* hash) = 0;
73
74 // Returns the current (intermediate) state of the hash as a byte string.
75 virtual std::string GetHashState() = 0;
76
77 // Set the application GUID to be used to identify the app to the
78 // system AV function when scanning downloaded files. Should be called
79 // before RenameAndAnnotate() to take effect.
80 virtual void SetClientGuid(const std::string& guid) = 0;
81
82 // For testing. Must be called on FILE thread.
83 // TODO(rdsmith): Replace use of EnsureNoPendingDownloads()
84 // on the DownloadManager with a test-specific DownloadFileFactory
85 // which keeps track of the number of DownloadFiles.
86 static int GetNumberOfDownloadFiles();
87
88 protected:
89 static int number_active_objects_;
90 }; 73 };
91 74
92 } // namespace content 75 } // namespace content
93 76
94 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_ 77 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_FILE_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_destination_observer.h ('k') | content/browser/download/download_file_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698