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

Unified Diff: remoting/base/buffered_socket_writer.h

Issue 1582583003: Fix BufferedSocketWriter to buffer everything before it starts writing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | remoting/base/buffered_socket_writer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/buffered_socket_writer.h
diff --git a/remoting/base/buffered_socket_writer.h b/remoting/base/buffered_socket_writer.h
index dffed45f4e277de902def779adb84bbb9e46f214..c153ebec65c2851014d51eec086bbeddaa8cfdc4 100644
--- a/remoting/base/buffered_socket_writer.h
+++ b/remoting/base/buffered_socket_writer.h
@@ -36,13 +36,14 @@ class BufferedSocketWriter {
BufferedSocketWriter();
virtual ~BufferedSocketWriter();
- // Initializes the writer. |write_callback| is called to write data to the
+ // Starts the writer. |write_callback| is called to write data to the
// socket. |write_failed_callback| is called when write operation fails.
// Writing stops after the first failed write.
- void Init(const WriteCallback& write_callback,
- const WriteFailedCallback& write_failed_callback);
+ void Start(const WriteCallback& write_callback,
+ const WriteFailedCallback& write_failed_callback);
- // Puts a new data chunk in the buffer.
+ // Puts a new data chunk in the buffer. If called before Start() then all data
+ // is buffered until Start().
void Write(const scoped_refptr<net::IOBufferWithSize>& buffer,
const base::Closure& done_task);
@@ -53,9 +54,6 @@ class BufferedSocketWriter {
struct PendingPacket;
typedef std::list<PendingPacket*> DataQueue;
- // Returns true if the writer is closed due to an error.
- bool is_closed();
-
void DoWrite();
void HandleWriteResult(int result);
void OnWritten(int result);
@@ -65,6 +63,8 @@ class BufferedSocketWriter {
WriteCallback write_callback_;
WriteFailedCallback write_failed_callback_;
+ bool closed_ = false;
+
DataQueue queue_;
bool write_pending_ = false;
« no previous file with comments | « no previous file | remoting/base/buffered_socket_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698