Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 #if defined(UNIT_TEST) || defined(NET_DLL) |
|
wtc
2011/05/16 20:55:17
Perhaps we should just remove this ifdef?
Could y
rvargas (doing something else)
2011/05/16 22:41:56
If the compiler, while building the dll doesn't "s
| |
| 66 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } | 67 static void set_merge_chunks(bool merge) { merge_chunks_ = merge; } |
|
wtc
2011/05/16 23:07:13
If appropriate, add a comment to say this method i
| |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 enum { kBufSize = 16384 }; | 71 enum { kBufSize = 16384 }; |
| 71 | 72 |
| 72 // Protects from public access since now we have a static creator function | 73 // 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. | 74 // which will do both creation and initialization and might return an error. |
| 74 explicit UploadDataStream(UploadData* data); | 75 explicit UploadDataStream(UploadData* data); |
| 75 | 76 |
| 76 // Fills the buffer with any remaining data and sets eof_ if there was nothing | 77 // Fills the buffer with any remaining data and sets eof_ if there was nothing |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 // TODO(satish): Remove this once we have a better way to unit test POST | 113 // TODO(satish): Remove this once we have a better way to unit test POST |
| 113 // requests with chunked uploads. | 114 // requests with chunked uploads. |
| 114 static bool merge_chunks_; | 115 static bool merge_chunks_; |
| 115 | 116 |
| 116 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 117 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 } // namespace net | 120 } // namespace net |
| 120 | 121 |
| 121 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 122 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
| OLD | NEW |