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

Side by Side Diff: content/browser/download/base_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, 1 month 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_BROWSER_DOWNLOAD_BASE_FILE_H_ 5 #ifndef CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 6 #define CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Indicate that the download has finished. No new data will be received. 56 // Indicate that the download has finished. No new data will be received.
57 void Finish(); 57 void Finish();
58 58
59 // Informs the OS that this file came from the internet. 59 // Informs the OS that this file came from the internet.
60 void AnnotateWithSourceInformation(); 60 void AnnotateWithSourceInformation();
61 61
62 FilePath full_path() const { return full_path_; } 62 FilePath full_path() const { return full_path_; }
63 bool in_progress() const { return file_stream_ != NULL; } 63 bool in_progress() const { return file_stream_ != NULL; }
64 int64 bytes_so_far() const { return bytes_so_far_; } 64 int64 bytes_so_far() const { return bytes_so_far_; }
65 65
66 // Set |hash| with sha256 digest for the file. 66 // Copies the current sha256 digest for the file into |hash|. May be partial.
67 // Used to save the hash in the case of download resumption.
68 // Returns true on success, false on failure.
69 bool GetPartialSha256Hash(std::string* hash);
Randy Smith (Not in Mondays) 2011/10/31 18:46:43 I'd like to look at combining the concepts of part
ahendrickson 2011/11/13 21:15:20 Done.
70
71 // Sets the sha256 digest for the file from |hash|.
72 // Used to restore the hash in the case of download resumption.
73 // Returns true on success, false on failure.
74 bool SetPartialSha256Hash(const std::string& hash);
Randy Smith (Not in Mondays) 2011/10/31 18:46:43 Hmmm. This feels like something that's relevant o
ahendrickson 2011/11/13 21:15:20 I'd like to be able to set the partial hash in uni
Randy Smith (Not in Mondays) 2011/11/15 18:35:25 Why can't that be done in the constructor?
ahendrickson 2011/11/16 15:41:08 Done.
75
76 // Sets |hash| with sha256 digest for the file.
67 // Returns true if digest is successfully calculated. 77 // Returns true if digest is successfully calculated.
68 virtual bool GetSha256Hash(std::string* hash); 78 virtual bool GetSha256Hash(std::string* hash);
69 79
70 virtual std::string DebugString() const; 80 virtual std::string DebugString() const;
71 81
72 protected: 82 protected:
73 virtual void CreateFileStream(); // For testing. 83 virtual void CreateFileStream(); // For testing.
74 // Returns net::OK on success, or a network error code on failure. 84 // Returns net::OK on success, or a network error code on failure.
75 net::Error Open(); 85 net::Error Open();
76 void Close(); 86 void Close();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 unsigned char sha256_hash_[kSha256HashLen]; 119 unsigned char sha256_hash_[kSha256HashLen];
110 120
111 // Indicates that this class no longer owns the associated file, and so 121 // Indicates that this class no longer owns the associated file, and so
112 // won't delete it on destruction. 122 // won't delete it on destruction.
113 bool detached_; 123 bool detached_;
114 124
115 DISALLOW_COPY_AND_ASSIGN(BaseFile); 125 DISALLOW_COPY_AND_ASSIGN(BaseFile);
116 }; 126 };
117 127
118 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_ 128 #endif // CONTENT_BROWSER_DOWNLOAD_BASE_FILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698