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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "base/win/scoped_handle.h" | 10 #include "base/win/scoped_handle.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 size_t CancelableFileOperation(Function operation, | 114 size_t CancelableFileOperation(Function operation, |
115 HANDLE file, | 115 HANDLE file, |
116 BufferType* buffer, | 116 BufferType* buffer, |
117 size_t length, | 117 size_t length, |
118 WaitableEvent* io_event, | 118 WaitableEvent* io_event, |
119 WaitableEvent* cancel_event, | 119 WaitableEvent* cancel_event, |
120 CancelableSyncSocket* socket, | 120 CancelableSyncSocket* socket, |
121 DWORD timeout_in_ms) { | 121 DWORD timeout_in_ms) { |
122 ThreadRestrictions::AssertIOAllowed(); | 122 ThreadRestrictions::AssertIOAllowed(); |
123 // The buffer must be byte size or the length check won't make much sense. | 123 // The buffer must be byte size or the length check won't make much sense. |
124 COMPILE_ASSERT(sizeof(buffer[0]) == sizeof(char), incorrect_buffer_type); | 124 static_assert(sizeof(buffer[0]) == sizeof(char), "incorrect buffer type"); |
125 DCHECK_GT(length, 0u); | 125 DCHECK_GT(length, 0u); |
126 DCHECK_LE(length, kMaxMessageLength); | 126 DCHECK_LE(length, kMaxMessageLength); |
127 DCHECK_NE(file, SyncSocket::kInvalidHandle); | 127 DCHECK_NE(file, SyncSocket::kInvalidHandle); |
128 | 128 |
129 // Track the finish time so we can calculate the timeout as data is read. | 129 // Track the finish time so we can calculate the timeout as data is read. |
130 TimeTicks current_time, finish_time; | 130 TimeTicks current_time, finish_time; |
131 if (timeout_in_ms != INFINITE) { | 131 if (timeout_in_ms != INFINITE) { |
132 current_time = TimeTicks::Now(); | 132 current_time = TimeTicks::Now(); |
133 finish_time = | 133 finish_time = |
134 current_time + base::TimeDelta::FromMilliseconds(timeout_in_ms); | 134 current_time + base::TimeDelta::FromMilliseconds(timeout_in_ms); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 static_cast<DWORD>(timeout.InMilliseconds())); | 333 static_cast<DWORD>(timeout.InMilliseconds())); |
334 } | 334 } |
335 | 335 |
336 // static | 336 // static |
337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 337 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
338 CancelableSyncSocket* socket_b) { | 338 CancelableSyncSocket* socket_b) { |
339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); | 339 return CreatePairImpl(&socket_a->handle_, &socket_b->handle_, true); |
340 } | 340 } |
341 | 341 |
342 } // namespace base | 342 } // namespace base |
OLD | NEW |