| Index: net/base/io_buffer.h
|
| diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h
|
| index 3a04b6a969cfe3f5ee6da2aad1f15fff0514c4e1..41393091d6b9c7849530576b1086d21d77c72f27 100644
|
| --- a/net/base/io_buffer.h
|
| +++ b/net/base/io_buffer.h
|
| @@ -126,6 +126,21 @@ class NET_EXPORT StringIOBuffer : public IOBuffer {
|
|
|
| // This version wraps an existing IOBuffer and provides convenient functions
|
| // to progressively read all the data.
|
| +//
|
| +// DrainableIOBuffer is useful when you have an IOBuffer that contains data
|
| +// to be written progressively, and Write() function takes an IOBuffer rather
|
| +// than char*. DrainableIOBuffer can be used as follows:
|
| +//
|
| +// // payload is the IOBuffer containing the data to be written.
|
| +// buf = new DrainableIOBuffer(payload, payload_size);
|
| +//
|
| +// while (buf->BytesRemaining() > 0) {
|
| +// // Write() takes an IOBuffer. If it takes char*, we could
|
| +// // simply use the regular IOBuffer like payload->data() + offset.
|
| +// int bytes_written = Write(buf, buf->BytesRemaining());
|
| +// buf->DidConsume(bytes_written);
|
| +// }
|
| +//
|
| class NET_EXPORT DrainableIOBuffer : public IOBuffer {
|
| public:
|
| DrainableIOBuffer(IOBuffer* base, int size);
|
| @@ -155,6 +170,22 @@ class NET_EXPORT DrainableIOBuffer : public IOBuffer {
|
| };
|
|
|
| // This version provides a resizable buffer and a changeable offset.
|
| +//
|
| +// GrowableIOBuffer is useful when you read data progressively without
|
| +// knowing the total size in advance. GrowableIOBuffer can be used as
|
| +// follows:
|
| +//
|
| +// buf = new GrowableIOBuffer;
|
| +// buf->SetCapacity(1024); // Initial capacity.
|
| +//
|
| +// while (!some_stream->IsEOF()) {
|
| +// // Double the capacity if the remaining capacity is empty.
|
| +// if (buf->RemainingCapacity() == 0)
|
| +// buf->SetCapacity(buf->capacity() * 2);
|
| +// int bytes_read = some_stream->Read(buf, buf->RemainingCapacity());
|
| +// buf->set_offset(buf->offset() + bytes_read);
|
| +// }
|
| +//
|
| class NET_EXPORT GrowableIOBuffer : public IOBuffer {
|
| public:
|
| GrowableIOBuffer();
|
|
|