Update V8 to version 4.6.48.
[chromium-blink-merge.git] / net / socket / socket_descriptor.h
blobb2a22234b800ff2d21e0f3fcd3552e902611007e
1 // Copyright 2013 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.
5 #ifndef NET_SOCKET_SOCKET_DESCRIPTOR_H_
6 #define NET_SOCKET_SOCKET_DESCRIPTOR_H_
8 #include "build/build_config.h"
9 #include "net/base/net_export.h"
11 #if defined(OS_WIN)
12 #include <winsock2.h>
13 #endif // OS_WIN
15 namespace net {
17 #if defined(OS_POSIX)
18 typedef int SocketDescriptor;
19 const SocketDescriptor kInvalidSocket = -1;
20 #elif defined(OS_WIN)
21 typedef SOCKET SocketDescriptor;
22 const SocketDescriptor kInvalidSocket = INVALID_SOCKET;
23 #endif
25 // Interface to create native socket.
26 // Usually such factories are used for testing purposes, which is not true in
27 // this case. This interface is used to substitute WSASocket/socket to make
28 // possible execution of some network code in sandbox.
29 class NET_EXPORT PlatformSocketFactory {
30 public:
31 PlatformSocketFactory();
32 virtual ~PlatformSocketFactory();
34 // Replace WSASocket/socket with given factory. The factory will be used by
35 // CreatePlatformSocket.
36 static void SetInstance(PlatformSocketFactory* factory);
38 // Creates socket. See WSASocket/socket documentation of parameters.
39 virtual SocketDescriptor CreateSocket(int family, int type, int protocol) = 0;
42 // Creates socket. See WSASocket/socket documentation of parameters.
43 SocketDescriptor NET_EXPORT CreatePlatformSocket(int family,
44 int type,
45 int protocol);
47 } // namespace net
49 #endif // NET_SOCKET_SOCKET_DESCRIPTOR_H_