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

Unified Diff: base/sync_socket_win.cc

Issue 23875019: Add SyncSocket::ReceiveWithTimeout() and SyncSocket unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
« base/sync_socket_unittest.cc ('K') | « base/sync_socket_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sync_socket_win.cc
diff --git a/base/sync_socket_win.cc b/base/sync_socket_win.cc
index 99a6afea3ec2fdde77f7ac829cbf102fa6998098..0475c9408e6af575731c6e0948c32dbd1b7e5947 100644
--- a/base/sync_socket_win.cc
+++ b/base/sync_socket_win.cc
@@ -138,7 +138,7 @@ size_t CancelableFileOperation(Function operation, HANDLE file,
if (wait_result == (WAIT_OBJECT_0 + 0)) {
GetOverlappedResult(file, &ol, &len, TRUE);
} else if (wait_result == (WAIT_OBJECT_0 + 1)) {
- VLOG(1) << "Shutdown was signaled. Closing socket.";
+ DVLOG(1) << "Shutdown was signaled. Closing socket.";
CancelIo(file);
socket->Close();
count = 0;
@@ -146,9 +146,8 @@ size_t CancelableFileOperation(Function operation, HANDLE file,
} else {
// Timeout happened.
DCHECK_EQ(WAIT_TIMEOUT, wait_result);
- if (!CancelIo(file)){
+ if (!CancelIo(file))
DLOG(WARNING) << "CancelIo() failed";
- }
break;
}
} else {
@@ -207,6 +206,13 @@ size_t SyncSocket::Send(const void* buffer, size_t length) {
return count;
}
+size_t SyncSocket::ReceiveWithTimeout(void* buffer,
+ size_t length,
+ TimeDelta timeout) {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
size_t SyncSocket::Receive(void* buffer, size_t length) {
DCHECK_LE(length, kMaxMessageLength);
size_t count = 0;
@@ -258,9 +264,17 @@ size_t CancelableSyncSocket::Send(const void* buffer, size_t length) {
}
size_t CancelableSyncSocket::Receive(void* buffer, size_t length) {
- return CancelableFileOperation(&ReadFile, handle_,
- reinterpret_cast<char*>(buffer), length, &file_operation_,
- &shutdown_event_, this, INFINITE);
+ return CancelableFileOperation(
+ &ReadFile, handle_, reinterpret_cast<char*>(buffer), length,
+ &file_operation_, &shutdown_event_, this, INFINITE);
+}
+
+size_t CancelableSyncSocket::ReceiveWithTimeout(void* buffer,
+ size_t length,
+ base::TimeDelta timeout) {
+ return CancelableFileOperation(
+ &ReadFile, handle_, reinterpret_cast<char*>(buffer), length,
+ &file_operation_, &shutdown_event_, this, timeout.InMilliseconds());
}
// static
« base/sync_socket_unittest.cc ('K') | « base/sync_socket_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698