forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to libwebrtc new DNS resolver interface
https://bugs.webkit.org/show_bug.cgi?id=265791 rdar://119133276 Reviewed by Eric Carlson. Migrate code from deprecated webrtc::AsyncResolverFactory to webrtc::AsyncDnsResolverFactory. This in particular simplifies how we do memory management, since the peer connection factory is now owned by the peer connection. We keep using a map of WeakPtr to allow to handle IPC responses from network process. We work around a header conflict between SDK and libwebrtc by isolating absl::InvokeCall in LibWebRTCDnsResolverFactory.cpp. * Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp: (WebCore::LibWebRTCProvider::createPeerConnection): * Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h: * Source/WebKit/Sources.txt: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCDnsResolverFactory.cpp: Added. (WebKit::LibWebRTCDnsResolverFactory::CreateAndResolve): (WebKit::LibWebRTCDnsResolverFactory::Create): (WebKit::LibWebRTCDnsResolverFactory::Resolver::Start): * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCDnsResolverFactory.h: Added. * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCProvider.cpp: (WebKit::LibWebRTCProvider::createPeerConnection): (WebKit::RTCSocketFactory::CreateAsyncDnsResolver): (WebKit::RTCSocketFactory::CreateAsyncResolver): Deleted. * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.cpp: (WebKit::LibWebRTCResolver::~LibWebRTCResolver): (WebKit::LibWebRTCResolver::start): (WebKit::LibWebRTCResolver::result const): (WebKit::LibWebRTCResolver::setResolvedAddress): (WebKit::LibWebRTCResolver::setError): (WebKit::LibWebRTCResolver::Start): Deleted. (WebKit::LibWebRTCResolver::Destroy): Deleted. (WebKit::LibWebRTCResolver::doDestroy): Deleted. * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.h: * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp: (WebKit::LibWebRTCSocketFactory::createAsyncDnsResolver): (WebKit::LibWebRTCSocketFactory::createAsyncResolver): Deleted. * Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h: (WebKit::LibWebRTCSocketFactory::resolver): (WebKit::LibWebRTCSocketFactory::removeResolver): (WebKit::LibWebRTCSocketFactory::takeResolver): Deleted. * Source/WebKit/WebProcess/Network/webrtc/WebRTCResolver.cpp: (WebKit::WebRTCResolver::setResolvedAddress): (WebKit::WebRTCResolver::resolvedAddressError): Canonical link: https://commits.webkit.org/272029@main
- Loading branch information
Showing
11 changed files
with
211 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCDnsResolverFactory.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "LibWebRTCDnsResolverFactory.h" | ||
|
||
#if USE(LIBWEBRTC) | ||
|
||
#include "LibWebRTCNetwork.h" | ||
#include "WebProcess.h" | ||
|
||
namespace WebKit { | ||
|
||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> LibWebRTCDnsResolverFactory::CreateAndResolve(const rtc::SocketAddress& address, absl::AnyInvocable<void()> callback) | ||
{ | ||
auto resolver = WebProcess::singleton().libWebRTCNetwork().socketFactory().createAsyncDnsResolver(); | ||
resolver->start(address, [callback = absl::move(callback)] () mutable { | ||
callback(); | ||
}); | ||
return resolver; | ||
} | ||
|
||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> LibWebRTCDnsResolverFactory::CreateAndResolve(const rtc::SocketAddress& address, int /* family */, absl::AnyInvocable<void()> callback) | ||
{ | ||
auto resolver = WebProcess::singleton().libWebRTCNetwork().socketFactory().createAsyncDnsResolver(); | ||
// FIXME: Make use of family. | ||
resolver->start(address, [callback = absl::move(callback)] () mutable { | ||
callback(); | ||
}); | ||
return resolver; | ||
} | ||
|
||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> LibWebRTCDnsResolverFactory::Create() | ||
{ | ||
return WebProcess::singleton().libWebRTCNetwork().socketFactory().createAsyncDnsResolver(); | ||
} | ||
|
||
void LibWebRTCDnsResolverFactory::Resolver::Start(const rtc::SocketAddress& address, absl::AnyInvocable<void()> callback) | ||
{ | ||
start(address, [callback = absl::move(callback)] () mutable { | ||
callback(); | ||
}); | ||
} | ||
|
||
void LibWebRTCDnsResolverFactory::Resolver::Start(const rtc::SocketAddress& address, int /* family */, absl::AnyInvocable<void()> callback) | ||
{ | ||
// FIXME: Make use of family. | ||
start(address, [callback = absl::move(callback)] () mutable { | ||
callback(); | ||
}); | ||
} | ||
|
||
} // namespace WebKit | ||
|
||
#endif // USE(LIBWEBRTC) |
62 changes: 62 additions & 0 deletions
62
Source/WebKit/WebProcess/Network/webrtc/LibWebRTCDnsResolverFactory.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if USE(LIBWEBRTC) | ||
|
||
#include <WebCore/LibWebRTCMacros.h> | ||
|
||
ALLOW_COMMA_BEGIN | ||
#include <webrtc/api/async_dns_resolver.h> | ||
ALLOW_COMMA_END | ||
|
||
#include <wtf/FastMalloc.h> | ||
#include <wtf/Function.h> | ||
|
||
namespace WebKit { | ||
|
||
class LibWebRTCDnsResolverFactory final : public webrtc::AsyncDnsResolverFactoryInterface { | ||
WTF_MAKE_FAST_ALLOCATED; | ||
public: | ||
class Resolver : public webrtc::AsyncDnsResolverInterface { | ||
public: | ||
virtual void start(const rtc::SocketAddress&, Function<void()>&&) = 0; | ||
|
||
private: | ||
// webrtc::AsyncDnsResolverInterface | ||
void Start(const rtc::SocketAddress&, absl::AnyInvocable<void()>) final; | ||
void Start(const rtc::SocketAddress&, int family, absl::AnyInvocable<void()>) final; | ||
}; | ||
|
||
private: | ||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAndResolve(const rtc::SocketAddress&, absl::AnyInvocable<void()>) final; | ||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAndResolve(const rtc::SocketAddress&, int family, absl::AnyInvocable<void()>) final; | ||
std::unique_ptr<webrtc::AsyncDnsResolverInterface> Create() final; | ||
}; | ||
|
||
} // namespace WebKit | ||
|
||
#endif // USE(LIBWEBRTC) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.