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

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

Issue 6969077: net: Add NET_API to net/base (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
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_api.h"
10 #include "net/base/upload_data.h" 11 #include "net/base/upload_data.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 class FileStream; 15 class FileStream;
15 class IOBuffer; 16 class IOBuffer;
16 17
17 class UploadDataStream { 18 class NET_API UploadDataStream {
18 public: 19 public:
19 ~UploadDataStream(); 20 ~UploadDataStream();
20 21
21 // Returns a new instance of UploadDataStream if it can be created and 22 // Returns a new instance of UploadDataStream if it can be created and
22 // initialized successfully. If not, NULL will be returned and the error 23 // initialized successfully. If not, NULL will be returned and the error
23 // 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.
24 static UploadDataStream* Create(UploadData* data, int* error_code); 25 static UploadDataStream* Create(UploadData* data, int* error_code);
25 26
26 // Returns the stream's buffer and buffer length. 27 // Returns the stream's buffer and buffer length.
27 IOBuffer* buf() const { return buf_; } 28 IOBuffer* buf() const { return buf_; }
(...skipping 27 matching lines...) Expand all
55 // Returns whether there is no more data to read, regardless of whether 56 // Returns whether there is no more data to read, regardless of whether
56 // position < size. 57 // position < size.
57 bool eof() const { return eof_; } 58 bool eof() const { return eof_; }
58 59
59 // 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
60 // 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
61 // 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
62 // returns true only after the data in buf() has been consumed. 63 // returns true only after the data in buf() has been consumed.
63 bool IsOnLastChunk() const; 64 bool IsOnLastChunk() const;
64 65
65 #if defined(UNIT_TEST) 66 // This method is provided only to be used by unit tests.
66 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } 67 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; }
67 #endif
68 68
69 private: 69 private:
70 enum { kBufSize = 16384 }; 70 enum { kBufSize = 16384 };
71 71
72 // Protects from public access since now we have a static creator function 72 // 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. 73 // which will do both creation and initialization and might return an error.
74 explicit UploadDataStream(UploadData* data); 74 explicit UploadDataStream(UploadData* data);
75 75
76 // Fills the buffer with any remaining data and sets eof_ if there was nothing 76 // Fills the buffer with any remaining data and sets eof_ if there was nothing
77 // left to fill the buffer with. 77 // left to fill the buffer with.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // TODO(satish): Remove this once we have a better way to unit test POST 112 // TODO(satish): Remove this once we have a better way to unit test POST
113 // requests with chunked uploads. 113 // requests with chunked uploads.
114 static bool merge_chunks_; 114 static bool merge_chunks_;
115 115
116 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); 116 DISALLOW_COPY_AND_ASSIGN(UploadDataStream);
117 }; 117 };
118 118
119 } // namespace net 119 } // namespace net
120 120
121 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ 121 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_
OLDNEW
« base/compiler_specific.h ('K') | « net/base/upload_data.h ('k') | net/base/winsock_init.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698