summaryrefslogtreecommitdiffstats
path: root/net/base/upload_data_stream.h
diff options
context:
space:
mode:
authorvandebo@google.com <vandebo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 21:25:33 +0000
committervandebo@google.com <vandebo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 21:25:33 +0000
commit95d88ffe2faa5ccceb1c4619f4e316fb7ad4d70f (patch)
treedb13d8ae72b1e28783fa0571b08e31b4b65c8358 /net/base/upload_data_stream.h
parent268b02fa13ca56e7b32f0b6a445ce5758a1dfc3c (diff)
downloadchromium_src-95d88ffe2faa5ccceb1c4619f4e316fb7ad4d70f.zip
chromium_src-95d88ffe2faa5ccceb1c4619f4e316fb7ad4d70f.tar.gz
chromium_src-95d88ffe2faa5ccceb1c4619f4e316fb7ad4d70f.tar.bz2
Add a notion of 'eof' to UploadDataStream, replacing the use of its size property for detecting when an upload is finished.
While this does prevent the crash described in the bug from occurring, this doesn't fully solve the problem as now the affected uploads don't complete. Fully resolving the issue will require implementing the chunked transfer encoding for requests. Patch from Vernon Tang <vt@foilhead.net>, original review: http://codereview.chromium.org/555194 BUG=33501 TEST=Create a file with a non-zero size and select that file in an HTML-based uploader. Before starting the upload, remove read permissions from that file. Check that the upload doesn't cause the browser to crash or hang. net_unittests: HttpNetworkTransactionTest.UploadFileSmallerThanLength, UploadDataStreamTest.* Review URL: http://codereview.chromium.org/578004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/upload_data_stream.h')
-rw-r--r--net/base/upload_data_stream.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
index d703c3d..0dd7dd3 100644
--- a/net/base/upload_data_stream.h
+++ b/net/base/upload_data_stream.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,10 +27,19 @@ class UploadDataStream {
void DidConsume(size_t num_bytes);
// Returns the total size of the data stream and the current position.
+ // size() is not to be used to determine whether the stream has ended
+ // because it is possible for the stream to end before its size is reached,
+ // for example, if the file is truncated.
uint64 size() const { return total_size_; }
uint64 position() const { return current_position_; }
+ // Returns whether there is no more data to read, regardless of whether
+ // position < size.
+ bool eof() const { return eof_; }
+
private:
+ // Fills the buffer with any remaining data and sets eof_ if there was nothing
+ // left to fill the buffer with.
void FillBuf();
const UploadData* data_;
@@ -62,6 +71,9 @@ class UploadDataStream {
uint64 total_size_;
uint64 current_position_;
+ // Whether there is no data left to read.
+ bool eof_;
+
DISALLOW_EVIL_CONSTRUCTORS(UploadDataStream);
};