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"
18 typedef int SocketDescriptor
;
19 const SocketDescriptor kInvalidSocket
= -1;
21 typedef SOCKET SocketDescriptor
;
22 const SocketDescriptor kInvalidSocket
= INVALID_SOCKET
;
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
{
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
,
49 #endif // NET_SOCKET_SOCKET_DESCRIPTOR_H_