diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 21:52:57 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-11 21:52:57 +0000 |
commit | e221eeb710a2b463402d4550688bb9e0d9cdd496 (patch) | |
tree | 852e8776b7bf950f61c6b7f031bb2206b6f7e501 /remoting/protocol/buffered_socket_writer.h | |
parent | 6b7d1aab099945e69cd259c17fa75d926638ff33 (diff) | |
download | chromium_src-e221eeb710a2b463402d4550688bb9e0d9cdd496.zip chromium_src-e221eeb710a2b463402d4550688bb9e0d9cdd496.tar.gz chromium_src-e221eeb710a2b463402d4550688bb9e0d9cdd496.tar.bz2 |
Handle error in BufferedStreamWriter and friends
Sets the closed flag to true when an error is encountered in the socket.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/4705002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/buffered_socket_writer.h')
-rw-r--r-- | remoting/protocol/buffered_socket_writer.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/remoting/protocol/buffered_socket_writer.h b/remoting/protocol/buffered_socket_writer.h index 04e41b6..c786c44 100644 --- a/remoting/protocol/buffered_socket_writer.h +++ b/remoting/protocol/buffered_socket_writer.h @@ -63,16 +63,22 @@ class BufferedSocketWriterBase DataQueue queue_; int buffer_size_; - // Following two methods must be implemented in child classes. + // 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. virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size) = 0; virtual void AdvanceBufferPosition_Locked(int written) = 0; + // This method is called whenever there is an error writing to the socket. + virtual void OnError_Locked(int result) = 0; + private: void DoWrite(); void OnWritten(int result); + // This method is called when an error is encountered. + void HandleError(int result); + // Must be locked when accessing |socket_|, |queue_| and |buffer_size_|; Lock lock_; @@ -95,6 +101,7 @@ class BufferedSocketWriter : public BufferedSocketWriterBase { protected: virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); virtual void AdvanceBufferPosition_Locked(int written); + virtual void OnError_Locked(int result); private: scoped_refptr<net::DrainableIOBuffer> current_buf_; @@ -108,6 +115,7 @@ class BufferedDatagramWriter : public BufferedSocketWriterBase { protected: virtual void GetNextPacket_Locked(net::IOBuffer** buffer, int* size); virtual void AdvanceBufferPosition_Locked(int written); + virtual void OnError_Locked(int result); }; } // namespace protocol |