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

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

Issue 9242018: Factor out chunk encoding logic into HttpStreamParser::EncodeChunk(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | « no previous file | net/base/upload_data_stream.cc » ('j') | net/http/http_stream_parser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/base/net_export.h" 10 #include "net/base/net_export.h"
(...skipping 12 matching lines...) Expand all
23 // initialized successfully. If not, NULL will be returned and the error 23 // initialized successfully. If not, NULL will be returned and the error
24 // code will be set if the output parameter error_code is not empty. 24 // code will be set if the output parameter error_code is not empty.
25 static UploadDataStream* Create(UploadData* data, int* error_code); 25 static UploadDataStream* Create(UploadData* data, int* error_code);
26 26
27 // Returns the stream's buffer and buffer length. 27 // Returns the stream's buffer and buffer length.
28 IOBuffer* buf() const { return buf_; } 28 IOBuffer* buf() const { return buf_; }
29 size_t buf_len() const { return buf_len_; } 29 size_t buf_len() const { return buf_len_; }
30 30
31 // TODO(satish): We should ideally have UploadDataStream expose a Read() 31 // TODO(satish): We should ideally have UploadDataStream expose a Read()
32 // method which returns data in a caller provided IOBuffer. That would do away 32 // method which returns data in a caller provided IOBuffer. That would do away
33 // with this method and make the interface cleaner as well with less memmove 33 // with this method and make the interface cleaner as well with less memmove
wtc 2012/01/18 22:49:24 method => constant
satorux1 2012/01/18 23:42:30 Good catch. Done.
34 // calls. 34 // calls.
35 size_t GetMaxBufferSize() const { return kBufSize; } 35 static const size_t kBufferSize;
wtc 2012/01/18 22:49:24 Please document this constant. (I know this is a
satorux1 2012/01/18 23:42:30 Done.
36 36
37 // Call to indicate that a portion of the stream's buffer was consumed. This 37 // Call to indicate that a portion of the stream's buffer was consumed. This
38 // call modifies the stream's buffer so that it contains the next segment of 38 // call modifies the stream's buffer so that it contains the next segment of
39 // the upload data to be consumed. 39 // the upload data to be consumed.
40 void MarkConsumedAndFillBuffer(size_t num_bytes); 40 void MarkConsumedAndFillBuffer(size_t num_bytes);
41 41
42 // Sets the callback to be invoked when new chunks are available to upload. 42 // Sets the callback to be invoked when new chunks are available to upload.
43 void set_chunk_callback(ChunkCallback* callback) { 43 void set_chunk_callback(ChunkCallback* callback) {
44 data_->set_chunk_callback(callback); 44 data_->set_chunk_callback(callback);
45 } 45 }
(...skipping 14 matching lines...) Expand all
60 // Returns whether the data available in buf() includes the last chunk in a 60 // Returns whether the data available in buf() includes the last chunk in a
61 // chunked data stream. This method returns true once the final chunk has been 61 // chunked data stream. This method returns true once the final chunk has been
62 // placed in the IOBuffer returned by buf(), in contrast to eof() which 62 // placed in the IOBuffer returned by buf(), in contrast to eof() which
63 // returns true only after the data in buf() has been consumed. 63 // returns true only after the data in buf() has been consumed.
64 bool IsOnLastChunk() const; 64 bool IsOnLastChunk() const;
65 65
66 // This method is provided only to be used by unit tests. 66 // This method is provided only to be used by unit tests.
67 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } 67 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; }
68 68
69 private: 69 private:
70 enum { kBufSize = 16384 };
71
72 // Protects from public access since now we have a static creator function 70 // Protects from public access since now we have a static creator function
73 // which will do both creation and initialization and might return an error. 71 // which will do both creation and initialization and might return an error.
74 explicit UploadDataStream(UploadData* data); 72 explicit UploadDataStream(UploadData* data);
75 73
76 // Fills the buffer with any remaining data and sets eof_ if there was nothing 74 // Fills the buffer with any remaining data and sets eof_ if there was nothing
77 // left to fill the buffer with. 75 // left to fill the buffer with.
78 // Returns OK if the operation succeeds. Otherwise error code is returned. 76 // Returns OK if the operation succeeds. Otherwise error code is returned.
79 int FillBuf(); 77 int FillBuf();
80 78
81 scoped_refptr<UploadData> data_; 79 scoped_refptr<UploadData> data_;
(...skipping 30 matching lines...) Expand all
112 // TODO(satish): Remove this once we have a better way to unit test POST 110 // TODO(satish): Remove this once we have a better way to unit test POST
113 // requests with chunked uploads. 111 // requests with chunked uploads.
114 static bool merge_chunks_; 112 static bool merge_chunks_;
115 113
116 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); 114 DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
117 }; 115 };
118 116
119 } // namespace net 117 } // namespace net
120 118
121 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 119 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/upload_data_stream.cc » ('j') | net/http/http_stream_parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698