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

Unified Diff: base/sync_socket.h

Issue 23875019: Add SyncSocket::ReceiveWithTimeout() and SyncSocket unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only AssertIOAllowed() on blocking Send(). Created 7 years, 2 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: base/sync_socket.h
diff --git a/base/sync_socket.h b/base/sync_socket.h
index 8ba3f6c2652f0a02e97066dae40f821387b253c3..71addd1e163a9ab16d201a961ba3ae5b3ed6972f 100644
--- a/base/sync_socket.h
+++ b/base/sync_socket.h
@@ -18,6 +18,7 @@
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/synchronization/waitable_event.h"
+#include "base/time/time.h"
namespace base {
@@ -58,6 +59,13 @@ class BASE_EXPORT SyncSocket {
// Returns the number of bytes received, or 0 upon failure.
virtual size_t Receive(void* buffer, size_t length);
+ // Same as Receive() but only blocks for data until |timeout| has elapsed or
+ // |buffer| |length| is exhausted. Currently only timeouts less than one
+ // second are allowed. Return the amount of data read.
+ virtual size_t ReceiveWithTimeout(void* buffer,
+ size_t length,
+ TimeDelta timeout);
+
// Returns the number of bytes available. If non-zero, Receive() will not
// not block when called. NOTE: Some implementations cannot reliably
// determine the number of bytes available so avoid using the returned
@@ -102,6 +110,9 @@ class BASE_EXPORT CancelableSyncSocket : public SyncSocket {
// SyncSocket methods in order to support shutting down the 'socket'.
virtual bool Close() OVERRIDE;
virtual size_t Receive(void* buffer, size_t length) OVERRIDE;
+ virtual size_t ReceiveWithTimeout(void* buffer,
+ size_t length,
+ TimeDelta timeout) OVERRIDE;
#endif
// Send() is overridden to catch cases where the remote end is not responding
« no previous file with comments | « base/base.gyp ('k') | base/sync_socket_nacl.cc » ('j') | base/sync_socket_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698