Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Unified Diff: remoting/protocol/buffered_socket_writer.h

Issue 10836030: Add unittests for BufferedSocketWriter and fix some bugs in that code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/buffered_socket_writer.h
diff --git a/remoting/protocol/buffered_socket_writer.h b/remoting/protocol/buffered_socket_writer.h
index d840270e5a625ffd79d6e74cdeec444dc90deff9..2a92b05493d67419b4f05bc0e4b64107049a3267 100644
--- a/remoting/protocol/buffered_socket_writer.h
+++ b/remoting/protocol/buffered_socket_writer.h
@@ -67,19 +67,24 @@ class BufferedSocketWriterBase : public base::NonThreadSafe {
// Removes element from the front of the queue and calls |done_task|
// for that element.
- void PopQueue();
+ base::Closure PopQueue();
simonmorris 2012/07/31 20:19:50 Maybe document what the caller may/should/must do
Sergey Ulanov 2012/07/31 21:37:53 Done.
// 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.
+
+ // Returns next packet that needs to be written to the socket. |buffer| must
simonmorris 2012/07/31 20:19:50 "|buffer| must" -> "*buffer will"? "Must" sounds l
Sergey Ulanov 2012/07/31 21:37:53 Done.
+ // be set to NULL if there is nothing left in the queue.
virtual void GetNextPacket(net::IOBuffer** buffer, int* size) = 0;
- virtual void AdvanceBufferPosition(int written) = 0;
+
+ // Returns closure that must be executed or null closure if the last write
+ // didn't complete any messages.
+ virtual base::Closure AdvanceBufferPosition(int written) = 0;
// This method is called whenever there is an error writing to the socket.
virtual void OnError(int result) = 0;
private:
void DoWrite();
+ void HandleWriteResult(int result, bool* write_again);
void OnWritten(int result);
// This method is called when an error is encountered.
@@ -91,6 +96,8 @@ class BufferedSocketWriterBase : public base::NonThreadSafe {
bool write_pending_;
bool closed_;
+
+ bool* destroyed_flag_;
};
class BufferedSocketWriter : public BufferedSocketWriterBase {
@@ -100,7 +107,7 @@ class BufferedSocketWriter : public BufferedSocketWriterBase {
protected:
virtual void GetNextPacket(net::IOBuffer** buffer, int* size) OVERRIDE;
- virtual void AdvanceBufferPosition(int written) OVERRIDE;
+ virtual base::Closure AdvanceBufferPosition(int written) OVERRIDE;
virtual void OnError(int result) OVERRIDE;
private:
@@ -114,7 +121,7 @@ class BufferedDatagramWriter : public BufferedSocketWriterBase {
protected:
virtual void GetNextPacket(net::IOBuffer** buffer, int* size) OVERRIDE;
- virtual void AdvanceBufferPosition(int written) OVERRIDE;
+ virtual base::Closure AdvanceBufferPosition(int written) OVERRIDE;
virtual void OnError(int result) OVERRIDE;
};
« no previous file with comments | « no previous file | remoting/protocol/buffered_socket_writer.cc » ('j') | remoting/protocol/buffered_socket_writer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698