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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with trunk Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PUBLIC_BROWSER_DOWNLOAD_FILE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DOWNLOAD_FILE_H_
6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_FILE_H_ 6 #define CONTENT_PUBLIC_BROWSER_DOWNLOAD_FILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 // These objects live exclusively on the file thread and handle the writing 21 // 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 22 // 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 23 // the download is 'in progress': once the download has been completed or
24 // cancelled, the DownloadFile is destroyed. 24 // cancelled, the DownloadFile is destroyed.
25 class CONTENT_EXPORT DownloadFile { 25 class CONTENT_EXPORT DownloadFile {
26 public: 26 public:
27 virtual ~DownloadFile() {} 27 virtual ~DownloadFile() {}
28 28
29 // If calculate_hash is true, sha256 hash will be calculated. 29 // If calculate_hash is true, sha256 hash will be calculated.
30 // Returns net::OK on success, or a network error code on failure. 30 // Returns net::OK on success, or a network error code on failure.
31 virtual net::Error Initialize(bool calculate_hash) = 0; 31 virtual net::Error Initialize() = 0;
32 32
33 // Write a new chunk of data to the file. 33 // Write a new chunk of data to the file.
34 // Returns net::OK on success (all bytes written to the file), 34 // Returns net::OK on success (all bytes written to the file),
35 // or a network error code on failure. 35 // or a network error code on failure.
36 virtual net::Error AppendDataToFile(const char* data, size_t data_len) = 0; 36 virtual net::Error AppendDataToFile(const char* data, size_t data_len) = 0;
37 37
38 // Rename the download file. 38 // Rename the download file.
39 // Returns net::OK on success, or a network error code on failure. 39 // Returns net::OK on success, or a network error code on failure.
40 virtual net::Error Rename(const FilePath& full_path) = 0; 40 virtual net::Error Rename(const FilePath& full_path) = 0;
41 41
42 // Detach the file so it is not deleted on destruction. 42 // Detach the file so it is not deleted on destruction.
43 virtual void Detach() = 0; 43 virtual void Detach() = 0;
44 44
45 // Abort the download and automatically close the file. 45 // Abort the download and automatically close the file.
46 virtual void Cancel() = 0; 46 virtual void Cancel() = 0;
47 47
48 // Indicate that the download has finished. No new data will be received. 48 // Indicate that the download has finished. No new data will be received.
49 virtual void Finish() = 0; 49 virtual void Finish() = 0;
50 50
51 // Informs the OS that this file came from the internet. 51 // Informs the OS that this file came from the internet.
52 virtual void AnnotateWithSourceInformation() = 0; 52 virtual void AnnotateWithSourceInformation() = 0;
53 53
54 virtual FilePath FullPath() const = 0; 54 virtual FilePath FullPath() const = 0;
55 virtual bool InProgress() const = 0; 55 virtual bool InProgress() const = 0;
56 virtual int64 BytesSoFar() const = 0; 56 virtual int64 BytesSoFar() const = 0;
57 virtual int64 CurrentSpeed() const = 0; 57 virtual int64 CurrentSpeed() const = 0;
58 58
59 // Set |hash| with sha256 digest for the file. 59 // Set |hash| with sha256 digest for the file.
60 // Returns true if digest is successfully calculated. 60 // Returns true if digest is successfully calculated.
61 virtual bool GetSha256Hash(std::string* hash) = 0; 61 virtual bool GetHash(std::string* hash) = 0;
62
63 // Returns the current (intermediate) state of the hash as a byte string.
64 virtual std::string GetHashState() = 0;
62 65
63 // Cancels the download request associated with this file. 66 // Cancels the download request associated with this file.
64 virtual void CancelDownloadRequest() = 0; 67 virtual void CancelDownloadRequest() = 0;
65 68
66 virtual int Id() const = 0; 69 virtual int Id() const = 0;
67 virtual DownloadManager* GetDownloadManager() = 0; 70 virtual DownloadManager* GetDownloadManager() = 0;
68 virtual const DownloadId& GlobalId() const = 0; 71 virtual const DownloadId& GlobalId() const = 0;
69 72
70 virtual std::string DebugString() const = 0; 73 virtual std::string DebugString() const = 0;
71 74
(...skipping 15 matching lines...) Expand all
87 // If |path| does not exist, 0 is returned. If it fails to find such 90 // If |path| does not exist, 0 is returned. If it fails to find such
88 // a number, -1 is returned. 91 // a number, -1 is returned.
89 static int GetUniquePathNumberWithSuffix( 92 static int GetUniquePathNumberWithSuffix(
90 const FilePath& path, 93 const FilePath& path,
91 const FilePath::StringType& suffix); 94 const FilePath::StringType& suffix);
92 }; 95 };
93 96
94 } // namespace content 97 } // namespace content
95 98
96 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_FILE_H_ 99 #endif // CONTENT_PUBLIC_BROWSER_DOWNLOAD_FILE_H_
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_dispatcher_host_unittest.cc ('k') | content/public/browser/download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698