OLD | NEW |
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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 return count; | 287 return count; |
288 } | 288 } |
289 | 289 |
290 size_t SyncSocket::Peek() { | 290 size_t SyncSocket::Peek() { |
291 DWORD available = 0; | 291 DWORD available = 0; |
292 PeekNamedPipe(handle_, NULL, 0, NULL, &available, NULL); | 292 PeekNamedPipe(handle_, NULL, 0, NULL, &available, NULL); |
293 return available; | 293 return available; |
294 } | 294 } |
295 | 295 |
296 CancelableSyncSocket::CancelableSyncSocket() | 296 CancelableSyncSocket::CancelableSyncSocket() |
297 : shutdown_event_(true, false), file_operation_(true, false) { | 297 : shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
298 } | 298 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 299 file_operation_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 300 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
299 | 301 |
300 CancelableSyncSocket::CancelableSyncSocket(Handle handle) | 302 CancelableSyncSocket::CancelableSyncSocket(Handle handle) |
301 : SyncSocket(handle), shutdown_event_(true, false), | 303 : SyncSocket(handle), |
302 file_operation_(true, false) { | 304 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, |
303 } | 305 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 306 file_operation_(base::WaitableEvent::ResetPolicy::MANUAL, |
| 307 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
304 | 308 |
305 bool CancelableSyncSocket::Shutdown() { | 309 bool CancelableSyncSocket::Shutdown() { |
306 // This doesn't shut down the pipe immediately, but subsequent Receive or Send | 310 // This doesn't shut down the pipe immediately, but subsequent Receive or Send |
307 // methods will fail straight away. | 311 // methods will fail straight away. |
308 shutdown_event_.Signal(); | 312 shutdown_event_.Signal(); |
309 return true; | 313 return true; |
310 } | 314 } |
311 | 315 |
312 bool CancelableSyncSocket::Close() { | 316 bool CancelableSyncSocket::Close() { |
313 const bool result = SyncSocket::Close(); | 317 const bool result = SyncSocket::Close(); |
(...skipping 23 matching lines...) Expand all Loading... |
337 static_cast<DWORD>(timeout.InMilliseconds())); | 341 static_cast<DWORD>(timeout.InMilliseconds())); |
338 } | 342 } |
339 | 343 |
340 // static | 344 // static |
341 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 345 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
342 CancelableSyncSocket* socket_b) { | 346 CancelableSyncSocket* socket_b) { |
343 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); | 347 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); |
344 } | 348 } |
345 | 349 |
346 } // namespace base | 350 } // namespace base |
OLD | NEW |