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

Unified Diff: remoting/base/buffered_socket_writer.h

Issue 1197853003: Add P2PDatagramSocket and P2PStreamSocket interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | remoting/base/buffered_socket_writer.cc » ('j') | remoting/protocol/p2p_datagram_socket.h » ('J')
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 c6012e37e8bc97efe98cc09ba43a876c01596a24..2c530b3f38659f990c2241b152df7c8677405082 100644
--- a/remoting/base/buffered_socket_writer.h
+++ b/remoting/base/buffered_socket_writer.h
@@ -10,12 +10,8 @@
#include "base/callback.h"
#include "base/synchronization/lock.h"
#include "base/threading/non_thread_safe.h"
+#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
-#include "net/socket/socket.h"
-
-namespace net {
-class Socket;
-} // namespace net
namespace remoting {
@@ -27,9 +23,11 @@ namespace remoting {
// Whenever new data is written it is just put in the queue, and then written
// on the thread that owns the socket. GetBufferChunks() and GetBufferSize()
// can be used to throttle writes.
-
class BufferedSocketWriterBase : public base::NonThreadSafe {
public:
+ typedef base::Callback<int(net::IOBuffer* buf, int buf_len,
+ const net::CompletionCallback& callback)>
+ WriteCallback;
typedef base::Callback<void(int)> WriteFailedCallback;
BufferedSocketWriterBase();
@@ -37,9 +35,9 @@ class BufferedSocketWriterBase : public base::NonThreadSafe {
// Initializes the writer. Must be called on the thread that will be used
// to access the socket in the future. |callback| will be called after each
- // failed write. Caller retains ownership of |socket|.
- // TODO(sergeyu): Change it so that it take ownership of |socket|.
- void Init(net::Socket* socket, const WriteFailedCallback& callback);
+ // failed write.
+ void Init(const WriteCallback& write_callback,
+ const WriteFailedCallback& write_failed_callback);
// Puts a new data chunk in the buffer. Returns false and doesn't enqueue
// the data if called before Init(). Can be called on any thread.
@@ -85,7 +83,7 @@ class BufferedSocketWriterBase : public base::NonThreadSafe {
// This method is called when an error is encountered.
void HandleError(int result);
- net::Socket* socket_;
+ WriteCallback write_callback_;
WriteFailedCallback write_failed_callback_;
bool write_pending_;
« no previous file with comments | « no previous file | remoting/base/buffered_socket_writer.cc » ('j') | remoting/protocol/p2p_datagram_socket.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698