Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this
3 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "nsUDPSocketProvider.h"
6 :
7 : #include "nspr.h"
8 :
9 : using mozilla::OriginAttributes;
10 :
11 0 : NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)
12 :
13 0 : nsUDPSocketProvider::~nsUDPSocketProvider()
14 : {
15 0 : }
16 :
17 : NS_IMETHODIMP
18 0 : nsUDPSocketProvider::NewSocket(int32_t aFamily,
19 : const char *aHost,
20 : int32_t aPort,
21 : nsIProxyInfo *aProxy,
22 : const OriginAttributes &originAttributes,
23 : uint32_t aFlags,
24 : PRFileDesc * *aFileDesc,
25 : nsISupports **aSecurityInfo)
26 : {
27 0 : NS_ENSURE_ARG_POINTER(aFileDesc);
28 :
29 0 : PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
30 0 : if (!udpFD)
31 0 : return NS_ERROR_FAILURE;
32 :
33 0 : *aFileDesc = udpFD;
34 0 : return NS_OK;
35 : }
36 :
37 : NS_IMETHODIMP
38 0 : nsUDPSocketProvider::AddToSocket(int32_t aFamily,
39 : const char *aHost,
40 : int32_t aPort,
41 : nsIProxyInfo *aProxy,
42 : const OriginAttributes &originAttributes,
43 : uint32_t aFlags,
44 : struct PRFileDesc * aFileDesc,
45 : nsISupports **aSecurityInfo)
46 : {
47 : // does not make sense to strap a UDP socket onto an existing socket
48 0 : NS_NOTREACHED("Cannot layer UDP socket on an existing socket");
49 0 : return NS_ERROR_UNEXPECTED;
50 : }
|