1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_BASE_WINSOCK_UTIL_H_
6 #define NET_BASE_WINSOCK_UTIL_H_
7 
8 #include <stddef.h>
9 #include <winsock2.h>
10 
11 namespace net {
12 
13 // Bluetooth address size. Windows Bluetooth is supported via winsock.
14 static const size_t kBluetoothAddressSize = 6;
15 
16 // Assert that the (manual-reset) event object is not signaled.
17 void AssertEventNotSignaled(WSAEVENT hEvent);
18 
19 // If the (manual-reset) event object is signaled, resets it and returns true.
20 // Otherwise, does nothing and returns false.  Called after a Winsock function
21 // succeeds synchronously
22 //
23 // Our testing shows that except in rare cases (when running inside QEMU),
24 // the event object is already signaled at this point, so we call this method
25 // to avoid a context switch in common cases.  This is just a performance
26 // optimization.  The code still works if this function simply returns false.
27 bool ResetEventIfSignaled(WSAEVENT hEvent);
28 
29 }  // namespace net
30 
31 #endif  // NET_BASE_WINSOCK_UTIL_H_
32