| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_BUFFERED_SOCKET_WRITER_H_ |
| 6 #define REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 6 #define REMOTING_BASE_BUFFERED_SOCKET_WRITER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
| 14 #include "net/socket/socket.h" | 14 #include "net/socket/socket.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class Socket; | 17 class Socket; |
| 18 } // namespace net | 18 } // namespace net |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 namespace protocol { | |
| 22 | 21 |
| 23 // BufferedSocketWriter and BufferedDatagramWriter implement write data queue | 22 // BufferedSocketWriter and BufferedDatagramWriter implement write data queue |
| 24 // for stream and datagram sockets. BufferedSocketWriterBase is a base class | 23 // for stream and datagram sockets. BufferedSocketWriterBase is a base class |
| 25 // that implements base functionality common for streams and datagrams. | 24 // that implements base functionality common for streams and datagrams. |
| 26 // These classes are particularly useful when data comes from a thread | 25 // These classes are particularly useful when data comes from a thread |
| 27 // that doesn't own the socket, as Write() can be called from any thread. | 26 // that doesn't own the socket, as Write() can be called from any thread. |
| 28 // Whenever new data is written it is just put in the queue, and then written | 27 // Whenever new data is written it is just put in the queue, and then written |
| 29 // on the thread that owns the socket. GetBufferChunks() and GetBufferSize() | 28 // on the thread that owns the socket. GetBufferChunks() and GetBufferSize() |
| 30 // can be used to throttle writes. | 29 // can be used to throttle writes. |
| 31 | 30 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 public: | 118 public: |
| 120 BufferedDatagramWriter(); | 119 BufferedDatagramWriter(); |
| 121 ~BufferedDatagramWriter() override; | 120 ~BufferedDatagramWriter() override; |
| 122 | 121 |
| 123 protected: | 122 protected: |
| 124 void GetNextPacket(net::IOBuffer** buffer, int* size) override; | 123 void GetNextPacket(net::IOBuffer** buffer, int* size) override; |
| 125 base::Closure AdvanceBufferPosition(int written) override; | 124 base::Closure AdvanceBufferPosition(int written) override; |
| 126 void OnError(int result) override; | 125 void OnError(int result) override; |
| 127 }; | 126 }; |
| 128 | 127 |
| 129 } // namespace protocol | |
| 130 } // namespace remoting | 128 } // namespace remoting |
| 131 | 129 |
| 132 #endif // REMOTING_PROTOCOL_BUFFERED_SOCKET_WRITER_H_ | 130 #endif // REMOTING_BASE_BUFFERED_SOCKET_WRITER_H_ |
| OLD | NEW |