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

Unified Diff: net/base/upload_data.h

Issue 541022: Fix the case where the browser livelocks if we cannot open a file. (Closed)
Patch Set: Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: net/base/upload_data.h
diff --git a/net/base/upload_data.h b/net/base/upload_data.h
index 02880d3e5f84b65b3591e505d10abdfaebcad490..bd3f8f4089c981449d772afda6ab682fb1281e37 100644
--- a/net/base/upload_data.h
+++ b/net/base/upload_data.h
@@ -24,7 +24,7 @@ class UploadData : public base::RefCounted<UploadData> {
class Element {
public:
Element() : type_(TYPE_BYTES), file_range_offset_(0),
- file_range_length_(kuint64max) {
+ file_range_length_(kuint64max), expected_file_length_(-1) {
}
Type type() const { return type_; }
@@ -32,6 +32,7 @@ class UploadData : public base::RefCounted<UploadData> {
const FilePath& file_path() const { return file_path_; }
uint64 file_range_offset() const { return file_range_offset_; }
uint64 file_range_length() const { return file_range_length_; }
+ int64 expected_length() const { return expected_file_length_; }
wtc 2010/01/12 19:51:02 Nit: rename this method expected_file_size and the
agl 2010/01/25 14:14:09 Done.
void SetToBytes(const char* bytes, int bytes_len) {
type_ = TYPE_BYTES;
@@ -60,6 +61,11 @@ class UploadData : public base::RefCounted<UploadData> {
FilePath file_path_;
uint64 file_range_offset_;
uint64 file_range_length_;
+
+ // If this Element is a file, then this is the length that we expect it to
+ // have. This allows us to detect when a file has been truncated from under
+ // us. This is only valid after calling GetContentLength().
+ mutable int64 expected_file_length_;
wtc 2010/01/12 19:51:02 Does this member need to be mutable?
agl 2010/01/25 14:14:09 It's changed inside of GetContextLength, which is
};
void AppendBytes(const char* bytes, int bytes_len) {

Powered by Google App Engine
This is Rietveld 408576698