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

Unified Diff: base/sync_socket_win.cc

Issue 10083064: Revert 132842 - If we are using blocking write, when the renderer stop getting the data without not… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « base/sync_socket_posix.cc ('k') | content/browser/renderer_host/media/audio_sync_reader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sync_socket_win.cc
===================================================================
--- base/sync_socket_win.cc (revision 132887)
+++ base/sync_socket_win.cc (working copy)
@@ -114,8 +114,7 @@
BufferType* buffer, size_t length,
base::WaitableEvent* io_event,
base::WaitableEvent* cancel_event,
- CancelableSyncSocket* socket,
- DWORD timeout_in_ms) {
+ CancelableSyncSocket* socket) {
// The buffer must be byte size or the length check won't make much sense.
COMPILE_ASSERT(sizeof(buffer[0]) == sizeof(char), incorrect_buffer_type);
DCHECK_LE(length, kMaxMessageLength);
@@ -132,38 +131,24 @@
&len, &ol);
if (!ok) {
if (::GetLastError() == ERROR_IO_PENDING) {
- HANDLE events[] = { io_event->handle(), cancel_event->handle() };
- int wait_result = WaitForMultipleObjects(
- arraysize(events), events, FALSE, timeout_in_ms);
- if (wait_result == (WAIT_OBJECT_0 + 0)) {
- GetOverlappedResult(file, &ol, &len, TRUE);
- } else if (wait_result == (WAIT_OBJECT_0 + 1)) {
+ base::WaitableEvent* events[] = { io_event, cancel_event };
+ size_t signaled = WaitableEvent::WaitMany(events, arraysize(events));
+ if (signaled == 1) {
VLOG(1) << "Shutdown was signaled. Closing socket.";
CancelIo(file);
socket->Close();
count = 0;
break;
} else {
- // Timeout happened.
- DCHECK_EQ(WAIT_TIMEOUT, wait_result);
- if (!CancelIo(file)){
- DLOG(WARNING) << "CancelIo() failed";
- }
- break;
+ GetOverlappedResult(file, &ol, &len, TRUE);
}
} else {
- break;
+ return (0 < count) ? count : 0;
}
}
-
count += len;
-
- // Quit the operation if we can't write/read anymore.
- if (len != chunk)
- break;
}
-
- return (count > 0) ? count : 0;
+ return count;
}
} // namespace
@@ -249,16 +234,15 @@
}
size_t CancelableSyncSocket::Send(const void* buffer, size_t length) {
- static const DWORD kWaitTimeOutInMs = 500;
- return CancelableFileOperation(
- &WriteFile, handle_, reinterpret_cast<const char*>(buffer),
- length, &file_operation_, &shutdown_event_, this, kWaitTimeOutInMs);
+ return CancelableFileOperation(&WriteFile, handle_,
+ reinterpret_cast<const char*>(buffer), length, &file_operation_,
+ &shutdown_event_, this);
}
size_t CancelableSyncSocket::Receive(void* buffer, size_t length) {
return CancelableFileOperation(&ReadFile, handle_,
reinterpret_cast<char*>(buffer), length, &file_operation_,
- &shutdown_event_, this, INFINITE);
+ &shutdown_event_, this);
}
// static
« no previous file with comments | « base/sync_socket_posix.cc ('k') | content/browser/renderer_host/media/audio_sync_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698