summaryrefslogtreecommitdiffstats
path: root/net/base/winsock_util.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-11 22:01:17 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-11 22:01:17 +0000
commit02c5bc44bfa08094433251681ece311d78bc29b6 (patch)
tree14003726acc1447b7865cc4e2c8e7215546098db /net/base/winsock_util.h
parent9e497dd1a3174372eda0d4322a959f576415a8c9 (diff)
downloadchromium_src-02c5bc44bfa08094433251681ece311d78bc29b6.zip
chromium_src-02c5bc44bfa08094433251681ece311d78bc29b6.tar.gz
chromium_src-02c5bc44bfa08094433251681ece311d78bc29b6.tar.bz2
UDP sockets implementation for windows.
BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/6658027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77870 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/winsock_util.h')
-rw-r--r--net/base/winsock_util.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/net/base/winsock_util.h b/net/base/winsock_util.h
new file mode 100644
index 0000000..c26e63f
--- /dev/null
+++ b/net/base/winsock_util.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_BASE_WINSOCK_UTIL_H_
+#define NET_BASE_WINSOCK_UTIL_H_
+#pragma once
+
+#include <winsock2.h>
+
+namespace net {
+
+// Assert that the (manual-reset) event object is not signaled.
+void AssertEventNotSignaled(WSAEVENT hEvent);
+
+// If the (manual-reset) event object is signaled, resets it and returns true.
+// Otherwise, does nothing and returns false. Called after a Winsock function
+// succeeds synchronously
+//
+// Our testing shows that except in rare cases (when running inside QEMU),
+// the event object is already signaled at this point, so we call this method
+// to avoid a context switch in common cases. This is just a performance
+// optimization. The code still works if this function simply returns false.
+bool ResetEventIfSignaled(WSAEVENT hEvent);
+
+// Map winsock error to Chromium error.
+int MapWinsockError(int os_error);
+
+} // namespace net
+
+#endif // NET_BASE_WINSOCK_UTIL_H_