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

Side by Side Diff: base/sync_socket_win.cc

Issue 596103002: Fix more disabled MSVC warnings, base/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comment Created 6 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 unified diff | Download patch
« no previous file with comments | « base/strings/utf_string_conversion_utils.cc ('k') | base/test/gtest_xml_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 #include "base/win/scoped_handle.h" 9 #include "base/win/scoped_handle.h"
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // This is either the ReadFile or WriteFile call depending on whether 144 // This is either the ReadFile or WriteFile call depending on whether
145 // we're receiving or sending data. 145 // we're receiving or sending data.
146 DWORD len = 0; 146 DWORD len = 0;
147 const BOOL operation_ok = operation( 147 const BOOL operation_ok = operation(
148 file, static_cast<BufferType*>(buffer) + count, chunk, &len, &ol); 148 file, static_cast<BufferType*>(buffer) + count, chunk, &len, &ol);
149 if (!operation_ok) { 149 if (!operation_ok) {
150 if (::GetLastError() == ERROR_IO_PENDING) { 150 if (::GetLastError() == ERROR_IO_PENDING) {
151 HANDLE events[] = { io_event->handle(), cancel_event->handle() }; 151 HANDLE events[] = { io_event->handle(), cancel_event->handle() };
152 const int wait_result = WaitForMultipleObjects( 152 const int wait_result = WaitForMultipleObjects(
153 ARRAYSIZE_UNSAFE(events), events, FALSE, 153 ARRAYSIZE_UNSAFE(events), events, FALSE,
154 timeout_in_ms == INFINITE 154 timeout_in_ms == INFINITE ?
155 ? timeout_in_ms 155 timeout_in_ms :
156 : (finish_time - current_time).InMilliseconds()); 156 static_cast<DWORD>(
157 (finish_time - current_time).InMilliseconds()));
157 if (wait_result != WAIT_OBJECT_0 + 0) { 158 if (wait_result != WAIT_OBJECT_0 + 0) {
158 // CancelIo() doesn't synchronously cancel outstanding IO, only marks 159 // CancelIo() doesn't synchronously cancel outstanding IO, only marks
159 // outstanding IO for cancellation. We must call GetOverlappedResult() 160 // outstanding IO for cancellation. We must call GetOverlappedResult()
160 // below to ensure in flight writes complete before returning. 161 // below to ensure in flight writes complete before returning.
161 CancelIo(file); 162 CancelIo(file);
162 } 163 }
163 164
164 // We set the |bWait| parameter to TRUE for GetOverlappedResult() to 165 // We set the |bWait| parameter to TRUE for GetOverlappedResult() to
165 // ensure writes are complete before returning. 166 // ensure writes are complete before returning.
166 if (!GetOverlappedResult(file, &ol, &len, TRUE)) 167 if (!GetOverlappedResult(file, &ol, &len, TRUE))
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return CancelableFileOperation( 322 return CancelableFileOperation(
322 &ReadFile, handle_, reinterpret_cast<char*>(buffer), length, 323 &ReadFile, handle_, reinterpret_cast<char*>(buffer), length,
323 &file_operation_, &shutdown_event_, this, INFINITE); 324 &file_operation_, &shutdown_event_, this, INFINITE);
324 } 325 }
325 326
326 size_t CancelableSyncSocket::ReceiveWithTimeout(void* buffer, 327 size_t CancelableSyncSocket::ReceiveWithTimeout(void* buffer,
327 size_t length, 328 size_t length,
328 TimeDelta timeout) { 329 TimeDelta timeout) {
329 return CancelableFileOperation( 330 return CancelableFileOperation(
330 &ReadFile, handle_, reinterpret_cast<char*>(buffer), length, 331 &ReadFile, handle_, reinterpret_cast<char*>(buffer), length,
331 &file_operation_, &shutdown_event_, this, timeout.InMilliseconds()); 332 &file_operation_, &shutdown_event_, this,
333 static_cast<DWORD>(timeout.InMilliseconds()));
332 } 334 }
333 335
334 // static 336 // static
335 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
336 CancelableSyncSocket* socket_b) { 338 CancelableSyncSocket* socket_b) {
337 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); 339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true);
338 } 340 }
339 341
340 } // namespace base 342 } // namespace base
OLDNEW
« no previous file with comments | « base/strings/utf_string_conversion_utils.cc ('k') | base/test/gtest_xml_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698