| 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 REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 5 #ifndef REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ |
| 6 #define REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 6 #define REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // the data if called before Init(). Can be called on any thread. | 48 // the data if called before Init(). Can be called on any thread. |
| 49 bool Write(scoped_refptr<net::IOBufferWithSize> buffer, Task* done_task); | 49 bool Write(scoped_refptr<net::IOBufferWithSize> buffer, Task* done_task); |
| 50 | 50 |
| 51 // Returns current size of the buffer. Can be called on any thread. | 51 // Returns current size of the buffer. Can be called on any thread. |
| 52 int GetBufferSize(); | 52 int GetBufferSize(); |
| 53 | 53 |
| 54 // Returns number of chunks that are currently in the buffer waiting | 54 // Returns number of chunks that are currently in the buffer waiting |
| 55 // to be written. Can be called on any thread. | 55 // to be written. Can be called on any thread. |
| 56 int GetBufferChunks(); | 56 int GetBufferChunks(); |
| 57 | 57 |
| 58 // Stops writing and drops current buffers. | 58 // Stops writing and drops current buffers. Must be called on the |
| 59 // network thread. |
| 59 void Close(); | 60 void Close(); |
| 60 | 61 |
| 61 protected: | 62 protected: |
| 62 class PendingPacket; | 63 class PendingPacket; |
| 63 typedef std::list<PendingPacket*> DataQueue; | 64 typedef std::list<PendingPacket*> DataQueue; |
| 64 | 65 |
| 65 DataQueue queue_; | 66 DataQueue queue_; |
| 66 int buffer_size_; | 67 int buffer_size_; |
| 67 | 68 |
| 68 // Removes element from the front of the queue and calls |done_task| | 69 // Removes element from the front of the queue and calls |done_task| |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 protected: | 122 protected: |
| 122 virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); | 123 virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); |
| 123 virtual void AdvanceBufferPosition_Locked(int written); | 124 virtual void AdvanceBufferPosition_Locked(int written); |
| 124 virtual void OnError_Locked(int result); | 125 virtual void OnError_Locked(int result); |
| 125 }; | 126 }; |
| 126 | 127 |
| 127 } // namespace protocol | 128 } // namespace protocol |
| 128 } // namespace remoting | 129 } // namespace remoting |
| 129 | 130 |
| 130 #endif // REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 131 #endif // REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ |
| OLD | NEW |