summaryrefslogtreecommitdiff
path: root/chromium/net/socket/socket_descriptor.h
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-12-11 21:33:03 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-12-13 12:34:07 +0100
commitf2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch)
tree0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/net/socket/socket_descriptor.h
parent5362912cdb5eea702b68ebe23702468d17c3017a (diff)
downloadqtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/net/socket/socket_descriptor.h')
-rw-r--r--chromium/net/socket/socket_descriptor.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/chromium/net/socket/socket_descriptor.h b/chromium/net/socket/socket_descriptor.h
new file mode 100644
index 00000000000..b2a22234b80
--- /dev/null
+++ b/chromium/net/socket/socket_descriptor.h
@@ -0,0 +1,49 @@
+// Copyright 2013 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_SOCKET_SOCKET_DESCRIPTOR_H_
+#define NET_SOCKET_SOCKET_DESCRIPTOR_H_
+
+#include "build/build_config.h"
+#include "net/base/net_export.h"
+
+#if defined(OS_WIN)
+#include <winsock2.h>
+#endif // OS_WIN
+
+namespace net {
+
+#if defined(OS_POSIX)
+typedef int SocketDescriptor;
+const SocketDescriptor kInvalidSocket = -1;
+#elif defined(OS_WIN)
+typedef SOCKET SocketDescriptor;
+const SocketDescriptor kInvalidSocket = INVALID_SOCKET;
+#endif
+
+// Interface to create native socket.
+// Usually such factories are used for testing purposes, which is not true in
+// this case. This interface is used to substitute WSASocket/socket to make
+// possible execution of some network code in sandbox.
+class NET_EXPORT PlatformSocketFactory {
+ public:
+ PlatformSocketFactory();
+ virtual ~PlatformSocketFactory();
+
+ // Replace WSASocket/socket with given factory. The factory will be used by
+ // CreatePlatformSocket.
+ static void SetInstance(PlatformSocketFactory* factory);
+
+ // Creates socket. See WSASocket/socket documentation of parameters.
+ virtual SocketDescriptor CreateSocket(int family, int type, int protocol) = 0;
+};
+
+// Creates socket. See WSASocket/socket documentation of parameters.
+SocketDescriptor NET_EXPORT CreatePlatformSocket(int family,
+ int type,
+ int protocol);
+
+} // namespace net
+
+#endif // NET_SOCKET_SOCKET_DESCRIPTOR_H_