Backed out changeset 5669c20b0617 (bug 1903669) for causing crashtest failures on...
[gecko.git] / netwerk / socket / nsUDPSocketProvider.cpp
blobe99ef36a6d1771e4d38241981e42c9fc1e96e10e
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/. */
5 #include "nsUDPSocketProvider.h"
7 #include "nspr.h"
9 using mozilla::OriginAttributes;
11 NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider)
13 NS_IMETHODIMP
14 nsUDPSocketProvider::NewSocket(int32_t aFamily, const char* aHost,
15 int32_t aPort, nsIProxyInfo* aProxy,
16 const OriginAttributes& originAttributes,
17 uint32_t aFlags, uint32_t aTlsFlags,
18 PRFileDesc** aFileDesc,
19 nsITLSSocketControl** aTLSSocketControl) {
20 NS_ENSURE_ARG_POINTER(aFileDesc);
22 PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily);
23 if (!udpFD) return NS_ERROR_FAILURE;
25 *aFileDesc = udpFD;
26 return NS_OK;
29 NS_IMETHODIMP
30 nsUDPSocketProvider::AddToSocket(int32_t aFamily, const char* aHost,
31 int32_t aPort, nsIProxyInfo* aProxy,
32 const OriginAttributes& originAttributes,
33 uint32_t aFlags, uint32_t aTlsFlags,
34 struct PRFileDesc* aFileDesc,
35 nsITLSSocketControl** aTLSSocketControl) {
36 // does not make sense to strap a UDP socket onto an existing socket
37 MOZ_ASSERT_UNREACHABLE("Cannot layer UDP socket on an existing socket");
38 return NS_ERROR_UNEXPECTED;