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

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

Issue 6314010: Even more reordering the methods in headers and implementation in net/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/transport_security_state.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 #pragma once 7 #pragma once
8 8
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "net/base/upload_data.h" 10 #include "net/base/upload_data.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 class FileStream; 14 class FileStream;
15 class IOBuffer; 15 class IOBuffer;
16 16
17 class UploadDataStream { 17 class UploadDataStream {
18 public: 18 public:
19 ~UploadDataStream();
20
19 // Returns a new instance of UploadDataStream if it can be created and 21 // Returns a new instance of UploadDataStream if it can be created and
20 // initialized successfully. If not, NULL will be returned and the error 22 // initialized successfully. If not, NULL will be returned and the error
21 // code will be set if the output parameter error_code is not empty. 23 // code will be set if the output parameter error_code is not empty.
22 static UploadDataStream* Create(UploadData* data, int* error_code); 24 static UploadDataStream* Create(UploadData* data, int* error_code);
23 25
24 ~UploadDataStream();
25
26 // Returns the stream's buffer and buffer length. 26 // Returns the stream's buffer and buffer length.
27 IOBuffer* buf() const { return buf_; } 27 IOBuffer* buf() const { return buf_; }
28 size_t buf_len() const { return buf_len_; } 28 size_t buf_len() const { return buf_len_; }
29 29
30 // Call to indicate that a portion of the stream's buffer was consumed. This 30 // Call to indicate that a portion of the stream's buffer was consumed. This
31 // call modifies the stream's buffer so that it contains the next segment of 31 // call modifies the stream's buffer so that it contains the next segment of
32 // the upload data to be consumed. 32 // the upload data to be consumed.
33 void DidConsume(size_t num_bytes); 33 void DidConsume(size_t num_bytes);
34 34
35 // Returns the total size of the data stream and the current position. 35 // Returns the total size of the data stream and the current position.
36 // size() is not to be used to determine whether the stream has ended 36 // size() is not to be used to determine whether the stream has ended
37 // because it is possible for the stream to end before its size is reached, 37 // because it is possible for the stream to end before its size is reached,
38 // for example, if the file is truncated. 38 // for example, if the file is truncated.
39 uint64 size() const { return total_size_; } 39 uint64 size() const { return total_size_; }
40 uint64 position() const { return current_position_; } 40 uint64 position() const { return current_position_; }
41 41
42 // Returns whether there is no more data to read, regardless of whether 42 // Returns whether there is no more data to read, regardless of whether
43 // position < size. 43 // position < size.
44 bool eof() const { return eof_; } 44 bool eof() const { return eof_; }
45 45
46 private: 46 private:
47 enum { kBufSize = 16384 };
48
47 // Protects from public access since now we have a static creator function 49 // Protects from public access since now we have a static creator function
48 // which will do both creation and initialization and might return an error. 50 // which will do both creation and initialization and might return an error.
49 explicit UploadDataStream(UploadData* data); 51 explicit UploadDataStream(UploadData* data);
50 52
51 // Fills the buffer with any remaining data and sets eof_ if there was nothing 53 // Fills the buffer with any remaining data and sets eof_ if there was nothing
52 // left to fill the buffer with. 54 // left to fill the buffer with.
53 // Returns OK if the operation succeeds. Otherwise error code is returned. 55 // Returns OK if the operation succeeds. Otherwise error code is returned.
54 int FillBuf(); 56 int FillBuf();
55 57
56 UploadData* data_; 58 UploadData* data_;
57 59
58 // This buffer is filled with data to be uploaded. The data to be sent is 60 // This buffer is filled with data to be uploaded. The data to be sent is
59 // always at the front of the buffer. If we cannot send all of the buffer at 61 // always at the front of the buffer. If we cannot send all of the buffer at
60 // once, then we memmove the remaining portion and back-fill the buffer for 62 // once, then we memmove the remaining portion and back-fill the buffer for
61 // the next "write" call. buf_len_ indicates how much data is in the buffer. 63 // the next "write" call. buf_len_ indicates how much data is in the buffer.
62 enum { kBufSize = 16384 };
63 scoped_refptr<IOBuffer> buf_; 64 scoped_refptr<IOBuffer> buf_;
64 size_t buf_len_; 65 size_t buf_len_;
65 66
66 // Iterator to the upload element to be written to the send buffer next. 67 // Iterator to the upload element to be written to the send buffer next.
67 std::vector<UploadData::Element>::iterator next_element_; 68 std::vector<UploadData::Element>::iterator next_element_;
68 69
69 // The byte offset into next_element_'s data buffer if the next element is 70 // The byte offset into next_element_'s data buffer if the next element is
70 // a TYPE_BYTES element. 71 // a TYPE_BYTES element.
71 size_t next_element_offset_; 72 size_t next_element_offset_;
72 73
(...skipping 11 matching lines...) Expand all
84 85
85 // Whether there is no data left to read. 86 // Whether there is no data left to read.
86 bool eof_; 87 bool eof_;
87 88
88 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); 89 DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
89 }; 90 };
90 91
91 } // namespace net 92 } // namespace net
92 93
93 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 94 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « net/base/transport_security_state.cc ('k') | net/base/upload_data_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698