| 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 23 matching lines...) Expand all Loading... |
| 34 class BufferedSocketWriterBase | 34 class BufferedSocketWriterBase |
| 35 : public base::RefCountedThreadSafe<BufferedSocketWriterBase> { | 35 : public base::RefCountedThreadSafe<BufferedSocketWriterBase> { |
| 36 public: | 36 public: |
| 37 typedef Callback1<int>::Type WriteFailedCallback; | 37 typedef Callback1<int>::Type WriteFailedCallback; |
| 38 | 38 |
| 39 explicit BufferedSocketWriterBase(); | 39 explicit BufferedSocketWriterBase(); |
| 40 virtual ~BufferedSocketWriterBase(); | 40 virtual ~BufferedSocketWriterBase(); |
| 41 | 41 |
| 42 // Initializes the writer. Must be called on the thread that will be used | 42 // Initializes the writer. Must be called on the thread that will be used |
| 43 // to access the socket in the future. |callback| will be called after each | 43 // to access the socket in the future. |callback| will be called after each |
| 44 // failed write. | 44 // failed write. Caller retains ownership of |socket|. |
| 45 // TODO(sergeyu): Change it so that it take ownership of |socket|. |
| 45 void Init(net::Socket* socket, WriteFailedCallback* callback); | 46 void Init(net::Socket* socket, WriteFailedCallback* callback); |
| 46 | 47 |
| 47 // Puts a new data chunk in the buffer. Returns false and doesn't enqueue | 48 // Puts a new data chunk in the buffer. Returns false and doesn't enqueue |
| 48 // the data if called before Init(). Can be called on any thread. | 49 // the data if called before Init(). Can be called on any thread. |
| 49 bool Write(scoped_refptr<net::IOBufferWithSize> buffer, Task* done_task); | 50 bool Write(scoped_refptr<net::IOBufferWithSize> buffer, Task* done_task); |
| 50 | 51 |
| 51 // Returns current size of the buffer. Can be called on any thread. | 52 // Returns current size of the buffer. Can be called on any thread. |
| 52 int GetBufferSize(); | 53 int GetBufferSize(); |
| 53 | 54 |
| 54 // Returns number of chunks that are currently in the buffer waiting | 55 // Returns number of chunks that are currently in the buffer waiting |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 protected: | 123 protected: |
| 123 virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); | 124 virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); |
| 124 virtual void AdvanceBufferPosition_Locked(int written); | 125 virtual void AdvanceBufferPosition_Locked(int written); |
| 125 virtual void OnError_Locked(int result); | 126 virtual void OnError_Locked(int result); |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 } // namespace protocol | 129 } // namespace protocol |
| 129 } // namespace remoting | 130 } // namespace remoting |
| 130 | 131 |
| 131 #endif // REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 132 #endif // REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ |
| OLD | NEW |