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

Side by Side Diff: net/base/upload_data_stream.h

Issue 541022: Fix the case where the browser livelocks if we cannot open a file. (Closed)
Patch Set: Uploading checkpoint. This is known to cause all uploads on Windows to be zero bytes long. Created 10 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
« no previous file with comments | « net/base/upload_data.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 NET_BASE_UPLOAD_DATA_STREAM_H_ 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_
6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_
7 7
8 #include "net/base/file_stream.h" 8 #include "net/base/file_stream.h"
9 #include "net/base/upload_data.h" 9 #include "net/base/upload_data.h"
10 10
11 namespace net { 11 namespace net {
12 12
13 class IOBuffer; 13 class IOBuffer;
14 14
15 class UploadDataStream { 15 class UploadDataStream {
16 public: 16 public:
17 explicit UploadDataStream(const UploadData* data); 17 explicit UploadDataStream(UploadData* data);
18 ~UploadDataStream(); 18 ~UploadDataStream();
19 19
20 // Returns the stream's buffer and buffer length. 20 // Returns the stream's buffer and buffer length.
21 IOBuffer* buf() const { return buf_; } 21 IOBuffer* buf() const { return buf_; }
22 size_t buf_len() const { return buf_len_; } 22 size_t buf_len() const { return buf_len_; }
23 23
24 // Call to indicate that a portion of the stream's buffer was consumed. This 24 // Call to indicate that a portion of the stream's buffer was consumed. This
25 // call modifies the stream's buffer so that it contains the next segment of 25 // call modifies the stream's buffer so that it contains the next segment of
26 // the upload data to be consumed. 26 // the upload data to be consumed.
27 void DidConsume(size_t num_bytes); 27 void DidConsume(size_t num_bytes);
28 28
29 // Returns the total size of the data stream and the current position. 29 // Returns the total size of the data stream and the current position.
30 // size() is not to be used to determine whether the stream has ended 30 // size() is not to be used to determine whether the stream has ended
31 // because it is possible for the stream to end before its size is reached, 31 // because it is possible for the stream to end before its size is reached,
32 // for example, if the file is truncated. 32 // for example, if the file is truncated.
33 uint64 size() const { return total_size_; } 33 uint64 size() const { return total_size_; }
34 uint64 position() const { return current_position_; } 34 uint64 position() const { return current_position_; }
35 35
36 // Returns whether there is no more data to read, regardless of whether 36 // Returns whether there is no more data to read, regardless of whether
37 // position < size. 37 // position < size.
38 bool eof() const { return eof_; } 38 bool eof() const { return eof_; }
39 39
40 private: 40 private:
41 // Fills the buffer with any remaining data and sets eof_ if there was nothing 41 // Fills the buffer with any remaining data and sets eof_ if there was nothing
42 // left to fill the buffer with. 42 // left to fill the buffer with.
43 void FillBuf(); 43 void FillBuf();
44 44
45 const UploadData* data_; 45 UploadData* data_;
46 46
47 // This buffer is filled with data to be uploaded. The data to be sent is 47 // This buffer is filled with data to be uploaded. The data to be sent is
48 // always at the front of the buffer. If we cannot send all of the buffer at 48 // always at the front of the buffer. If we cannot send all of the buffer at
49 // once, then we memmove the remaining portion and back-fill the buffer for 49 // once, then we memmove the remaining portion and back-fill the buffer for
50 // the next "write" call. buf_len_ indicates how much data is in the buffer. 50 // the next "write" call. buf_len_ indicates how much data is in the buffer.
51 enum { kBufSize = 16384 }; 51 enum { kBufSize = 16384 };
52 scoped_refptr<IOBuffer> buf_; 52 scoped_refptr<IOBuffer> buf_;
53 size_t buf_len_; 53 size_t buf_len_;
54 54
55 // Iterator to the upload element to be written to the send buffer next. 55 // Iterator to the upload element to be written to the send buffer next.
(...skipping 17 matching lines...) Expand all
73 73
74 // Whether there is no data left to read. 74 // Whether there is no data left to read.
75 bool eof_; 75 bool eof_;
76 76
77 DISALLOW_EVIL_CONSTRUCTORS(UploadDataStream); 77 DISALLOW_EVIL_CONSTRUCTORS(UploadDataStream);
78 }; 78 };
79 79
80 } // namespace net 80 } // namespace net
81 81
82 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 82 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « net/base/upload_data.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698