diff options
Diffstat (limited to 'remoting/protocol/buffered_socket_writer.h')
-rw-r--r-- | remoting/protocol/buffered_socket_writer.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/remoting/protocol/buffered_socket_writer.h b/remoting/protocol/buffered_socket_writer.h index c786c44..3ea127e 100644 --- a/remoting/protocol/buffered_socket_writer.h +++ b/remoting/protocol/buffered_socket_writer.h @@ -5,7 +5,7 @@ #ifndef REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ #define REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ -#include <queue> +#include <list> #include "base/lock.h" #include "base/ref_counted.h" @@ -13,6 +13,7 @@ #include "net/socket/socket.h" class MessageLoop; +class Task; namespace net { class Socket; @@ -45,7 +46,7 @@ class BufferedSocketWriterBase // Puts a new data chunk in the buffer. Returns false and doesn't enqueue // the data if called before Init(). Can be called on any thread. - bool Write(scoped_refptr<net::IOBufferWithSize> buffer); + bool Write(scoped_refptr<net::IOBufferWithSize> buffer, Task* done_task); // Returns current size of the buffer. Can be called on any thread. int GetBufferSize(); @@ -58,11 +59,16 @@ class BufferedSocketWriterBase void Close(); protected: - typedef std::queue<scoped_refptr<net::IOBufferWithSize> > DataQueue; + class PendingPacket; + typedef std::list<PendingPacket*> DataQueue; DataQueue queue_; int buffer_size_; + // Removes element from the front of the queue and calls |done_task| + // for that element. + void PopQueue(); + // Following three methods must be implemented in child classes. // GetNextPacket() returns next packet that needs to be written to the // socket. |buffer| must be set to NULL if there is nothing left in the queue. |