Changeset 229359 in webkit
- Timestamp:
- Mar 7, 2018 7:21:24 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 18 edited
- 6 copied
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r229353 r229359 1 2018-03-07 Alejandro G. Castro <alex@igalia.com> 2 3 Make NetworkRTCResolver port agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=178855 5 6 Reviewed by Youenn Fablet. 7 8 Add new API in the DNSResolveQueue allowing to revolve hostnames and get the result. Add platform 9 specific code for soup platform and refactor the other platforms. Added new API to the DNS API header 10 and move the general code to the DNS.cpp file, that way we can reuse that code in all the platforms 11 and leave the ResolveQueue class of the platforms in a file. 12 13 No new tests because this is a refactor. 14 15 * PlatformAppleWin.cmake: Move the DNSCFNet class to DNSResolveQueueCFNet. 16 * PlatformMac.cmake: Ditto. 17 * Sources.txt: Add the DNS.cpp for compilation. 18 * SourcesCocoa.txt: Move the DNSCFNet class to DNSResolveQueueCFNet. 19 * WebCore.xcodeproj/project.pbxproj: Move the DNSCFNet class to DNSResolveQueueCFNet, add the DNS.cpp 20 for compilation. Add the new DNSResolveQueueCFNet class. 21 * platform/Curl.cmake: Move the DNSCFNet class to DNSResolveQueueCurl. 22 * platform/network/DNS.cpp: Add this file with the default implementation of the DNS functions for 23 all the platforms. 24 (WebCore::prefetchDNS): Copied from every platform implementation. 25 (WebCore::resolveDNS): Add the function, resolves a hostname, receives the identifier of the operation 26 and the completion handler. 27 (WebCore::stopResolveDNS): Add the function, stops a resolution operation, receives the identifier 28 of the operation. 29 * platform/network/DNS.h: Add the new APIs resolveDNS and stopResolveDNS with the classes used for the 30 implementation. 31 (WebCore::IPAddress::IPAddress): Add this class used to send the resolved address information, it does 32 not depend on libwebrtc rtc classes. 33 (WebCore::IPAddress::get): Get a reference to the struct sockaddr_in in the IPAddress class. 34 (WebCore::DNSCompletionHandler): Add this CompletionHandler type to be used when resolving the DNS 35 address. 36 * platform/network/DNSResolveQueue.cpp: Add the DNSResolveQueue platform instantiation in the singleton. 37 (WebCore::DNSResolveQueue::singleton): Use DNSResolveQueue platform classes when creating the singleton.. 38 (WebCore::DNSResolveQueue::resolve): Add this method to get the address of a hostname, it sends the 39 identifier and the completion handler to use when returning the result. 40 (WebCore::DNSResolveQueue::stopResolve): Add this method to stop the resolve operation when required. 41 * platform/network/DNSResolveQueue.h: Add the new methods and make the class abstract, so that every 42 platform can implement the functions. 43 * platform/network/cf/DNSResolveQueueCFNet.cpp: Renamed from Source/WebCore/platform/network/cf/DNSCFNet.cpp. 44 Add the methods to the new class DNSResolveQueueCFNet, move the prefetchDNS to the DNS.cpp general 45 implementation. 46 * platform/network/cf/DNSResolveQueueCFNet.h: Add the new class inheriting from the DNSResolveQueue. Add the 47 new methods, we have to implement these methods and move the NetworkRTCResolver for COCOA code here. 48 (WebCore::DNSResolveQueueCF::resolve): Dummy method, not implemented. 49 (WebCore::DNSResolveQueueCF::stopResolve): Ditto. 50 * platform/network/curl/DNSResolveQueueCurl.cpp: Renamed from Source/WebCore/platform/network/curl/DNSCurl.cpp. 51 * platform/network/curl/DNSResolveQueueCurl.h: Add the new class inheriting from the DNSResolveQueue. 52 (WebCore::DNSResolveQueueCurl::resolve): Ditto. 53 (WebCore::DNSResolveQueueCurl::stopResolve): Ditto. 54 * platform/network/soup/DNSResolveQueueSoup.h: New class inheriting from the DNSResolveQueue class, adding 55 a HasMap with the active operations, it allows stopping them. 56 * platform/network/soup/DNSResolveQueueSoup.cpp: Renamed from Source/WebCore/platform/network/curl/DNSSoup.cpp. 57 (WebCore::resolvedWithObserverCallback): Called when the result address from the soup platform is ready, 58 sends the address to the completion handler. 59 (WebCore::DNSResolveQueueSoup::resolve): Launch the resolve operation with the soup library. 60 (WebCore::DNSResolveQueueSoup::stopResolve): Stop the resolve operation on process with a GCancellable. 61 1 62 2018-03-06 Brian Burg <bburg@apple.com> 2 63 -
trunk/Source/WebCore/PlatformAppleWin.cmake
r228451 r229359 51 51 platform/network/cf/CookieStorageCFNet.cpp 52 52 platform/network/cf/CredentialStorageCFNet.cpp 53 platform/network/cf/DNS CFNet.cpp53 platform/network/cf/DNSResolveQueueCFNet.cpp 54 54 platform/network/cf/FormDataStreamCFNet.cpp 55 55 platform/network/cf/LoaderRunLoopCF.cpp -
trunk/Source/WebCore/PlatformMac.cmake
r228451 r229359 414 414 platform/mediastream/mac/MockRealtimeVideoSourceMac.mm 415 415 416 platform/network/cf/DNS CFNet.cpp416 platform/network/cf/DNSResolveQueueCFNet.cpp 417 417 platform/network/cf/FormDataStreamCFNet.cpp 418 418 platform/network/cf/NetworkStorageSessionCFNet.cpp -
trunk/Source/WebCore/Sources.txt
r229340 r229359 1710 1710 platform/network/CredentialBase.cpp 1711 1711 platform/network/CredentialStorage.cpp 1712 platform/network/DNS.cpp 1712 1713 platform/network/DNSResolveQueue.cpp 1713 1714 platform/network/DataURLDecoder.cpp -
trunk/Source/WebCore/SourcesCocoa.txt
r228912 r229359 483 483 platform/mock/MediaPlaybackTargetMock.cpp 484 484 485 platform/network/cf/DNS CFNet.cpp485 platform/network/cf/DNSResolveQueueCFNet.cpp 486 486 platform/network/cf/FormDataStreamCFNet.cpp 487 487 platform/network/cf/NetworkStorageSessionCFNet.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r229353 r229359 2260 2260 7EE6846D12D26E3800E79415 /* ResourceRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845A12D26E3800E79415 /* ResourceRequest.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2261 2261 7EE6846F12D26E3800E79415 /* ResourceRequestCFNet.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845C12D26E3800E79415 /* ResourceRequestCFNet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2262 7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845C12D26E3800FF9415 /* DNSResolveQueueCFNet.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2262 2263 7EE6847012D26E3800E79415 /* ResourceResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845D12D26E3800E79415 /* ResourceResponse.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2263 2264 7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F4C96D91AD4483500365A50 /* JSFetchBody.h */; }; … … 9621 9622 7EE6845B12D26E3800E79415 /* ResourceRequestCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceRequestCFNet.cpp; sourceTree = "<group>"; }; 9622 9623 7EE6845C12D26E3800E79415 /* ResourceRequestCFNet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceRequestCFNet.h; sourceTree = "<group>"; }; 9624 7EE6845C12D26E3800FF9415 /* DNSResolveQueueCFNet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSResolveQueueCFNet.h; sourceTree = "<group>"; }; 9623 9625 7EE6845D12D26E3800E79415 /* ResourceResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceResponse.h; sourceTree = "<group>"; }; 9624 9626 7F4C96D81AD4483500365A50 /* JSFetchBody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchBody.cpp; sourceTree = "<group>"; }; … … 12142 12144 B2E4EC960D00C22B00432643 /* SVGZoomEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGZoomEvent.idl; sourceTree = "<group>"; }; 12143 12145 B2ED97700B1F55CE00257D0F /* GraphicsContextCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextCG.cpp; sourceTree = "<group>"; }; 12146 1AF8E13212565A4445230FF7 /* DNS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNS.cpp; sourceTree = "<group>"; }; 12144 12147 B2F34FE50E82F81400F627CD /* DNS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNS.h; sourceTree = "<group>"; }; 12145 B2F34FE80E82F82700F6 27CD /* DNSCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSCFNet.cpp; sourceTree = "<group>"; };12148 B2F34FE80E82F82700F648CD /* DNSResolveQueueCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DNSResolveQueueCFNet.cpp; sourceTree = "<group>"; }; 12146 12149 B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimateColorElement.cpp; sourceTree = "<group>"; }; 12147 12150 B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAnimateColorElement.h; sourceTree = "<group>"; }; … … 18742 18745 E4A007841B820ED3002C5A6E /* DataURLDecoder.cpp */, 18743 18746 E4A007821B820EC8002C5A6E /* DataURLDecoder.h */, 18747 1AF8E13212565A4445230FF7 /* DNS.cpp */, 18744 18748 B2F34FE50E82F81400F627CD /* DNS.h */, 18745 18749 7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */, … … 23476 23480 7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */, 23477 23481 5F2DBBE8178E336900141486 /* CertificateInfo.h */, 23478 B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */, 23482 B2F34FE80E82F82700F648CD /* DNSResolveQueueCFNet.cpp */, 23483 7EE6845C12D26E3800FF9415 /* DNSResolveQueueCFNet.h */, 23479 23484 7EE6845312D26E3800E79415 /* FormDataStreamCFNet.cpp */, 23480 23485 7EE6845412D26E3800E79415 /* FormDataStreamCFNet.h */, … … 27341 27346 84730D771248F0B300D3A9C9 /* DistantLightSource.h in Headers */, 27342 27347 B2F34FE60E82F81400F627CD /* DNS.h in Headers */, 27348 7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */, 27343 27349 A8185F4009765766005826D9 /* Document.h in Headers */, 27344 27350 A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */, -
trunk/Source/WebCore/platform/Curl.cmake
r228577 r229359 22 22 platform/network/curl/CurlSSLHandle.cpp 23 23 platform/network/curl/CurlSSLVerifier.cpp 24 platform/network/curl/DNS Curl.cpp24 platform/network/curl/DNSResolveQueueCurl.cpp 25 25 platform/network/curl/NetworkStorageSessionCurl.cpp 26 26 platform/network/curl/ProxyServerCurl.cpp -
trunk/Source/WebCore/platform/SourcesSoup.txt
r225054 r229359 28 28 platform/network/soup/CookieStorageSoup.cpp 29 29 platform/network/soup/CredentialStorageSoup.cpp 30 platform/network/soup/DNS Soup.cpp30 platform/network/soup/DNSResolveQueueSoup.cpp 31 31 platform/network/soup/GRefPtrSoup.cpp 32 32 platform/network/soup/NetworkStorageSessionSoup.cpp -
trunk/Source/WebCore/platform/network/DNS.cpp
r229358 r229359 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2012, 2018 Igalia S.L. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 21 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 25 */ 25 26 26 27 #include "config.h" 27 28 #include "DNS.h" 29 28 30 #include "DNSResolveQueue.h" 29 30 #if USE(CURL) 31 32 #include "NotImplemented.h" 31 #include <wtf/MainThread.h> 33 32 34 33 namespace WebCore { 35 34 36 void DNSResolveQueue::updateIsUsingProxy()35 void prefetchDNS(const String& hostname) 37 36 { 38 notImplemented(); 37 ASSERT(isMainThread()); 38 if (hostname.isEmpty()) 39 return; 40 41 DNSResolveQueue::singleton().add(hostname); 39 42 } 40 43 41 void DNSResolveQueue::platformResolve(const String& /* hostname */)44 void resolveDNS(const String& hostname, uint64_t identifier, DNSCompletionHandler&& completionHandler) 42 45 { 43 notImplemented(); 46 ASSERT(isMainThread()); 47 if (hostname.isEmpty()) 48 return; 49 50 WebCore::DNSResolveQueue::singleton().resolve(hostname, identifier, WTFMove(completionHandler)); 44 51 } 45 52 46 void prefetchDNS(const String& /* hostname */)53 void stopResolveDNS(uint64_t identifier) 47 54 { 48 notImplemented();55 WebCore::DNSResolveQueue::singleton().stopResolve(identifier); 49 56 } 50 57 51 58 } 52 53 #endif -
trunk/Source/WebCore/platform/network/DNS.h
r172849 r229359 24 24 */ 25 25 26 #ifndef DNS_h 27 #define DNS_h 26 #pragma once 27 28 #if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE) 29 #include <netinet/in.h> 30 #elif PLATFORM(WIN) 31 #include <winsock2.h> 32 #endif 28 33 29 34 #include <wtf/Forward.h> … … 31 36 namespace WebCore { 32 37 38 class WEBCORE_EXPORT IPAddress { 39 public: 40 explicit IPAddress(const struct sockaddr_in& address) 41 { 42 memset(&m_address, 0, sizeof(struct sockaddr_in)); 43 m_address = address; 44 } 45 46 const struct in_addr& getSinAddr() { return m_address.sin_addr; }; 47 48 private: 49 struct sockaddr_in m_address; 50 }; 51 52 enum class DNSError { Unknown, CannotResolve, Cancelled }; 53 54 using DNSAddressesOrError = Expected<Vector<WebCore::IPAddress>, DNSError>; 55 using DNSCompletionHandler = WTF::CompletionHandler<void(DNSAddressesOrError&&)>; 56 33 57 WEBCORE_EXPORT void prefetchDNS(const String& hostname); 58 WEBCORE_EXPORT void resolveDNS(const String& hostname, uint64_t identifier, DNSCompletionHandler&&); 59 WEBCORE_EXPORT void stopResolveDNS(uint64_t identifier); 60 34 61 } 35 36 #endif -
trunk/Source/WebCore/platform/network/DNSResolveQueue.cpp
r229209 r229359 28 28 #include "DNSResolveQueue.h" 29 29 30 #if USE(SOUP) 31 #include "DNSResolveQueueSoup.h" 32 #elif USE(CURL) 33 #include "DNSResolveQueueCurl.h" 34 #elif USE(CF) 35 #include "DNSResolveQueueCFNet.h" 36 #endif 37 30 38 #include <wtf/NeverDestroyed.h> 31 39 … … 52 60 DNSResolveQueue& DNSResolveQueue::singleton() 53 61 { 54 static NeverDestroyed<DNSResolveQueue > queue;62 static NeverDestroyed<DNSResolveQueuePlatform> queue; 55 63 56 64 return queue; … … 60 68 : m_timer(*this, &DNSResolveQueue::timerFired) 61 69 , m_requestsInFlight(0) 62 , m_isUsingProxy(true)63 70 { 64 71 // isUsingProxy will return the initial value of m_isUsingProxy at first on -
trunk/Source/WebCore/platform/network/DNSResolveQueue.h
r229174 r229359 28 28 #define DNSResolveQueue_h 29 29 30 #include "DNS.h" 30 31 #include "Timer.h" 31 32 #include <atomic> … … 40 41 41 42 public: 43 DNSResolveQueue(); 44 virtual ~DNSResolveQueue() = default; 45 42 46 static DNSResolveQueue& singleton(); 43 47 48 virtual void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) = 0; 49 virtual void stopResolve(uint64_t identifier) = 0; 44 50 void add(const String& hostname); 45 51 void decrementRequestCount() … … 48 54 } 49 55 50 private: 51 DNSResolveQueue(); 52 56 protected: 53 57 bool isUsingProxy(); 54 58 55 void updateIsUsingProxy(); 56 void platformResolve(const String&); 59 bool m_isUsingProxy { true }; 57 60 61 private: 62 virtual void updateIsUsingProxy() = 0; 63 virtual void platformResolve(const String&) = 0; 58 64 void timerFired(); 59 65 … … 62 68 HashSet<String> m_names; 63 69 std::atomic<int> m_requestsInFlight; 64 bool m_isUsingProxy;65 70 MonotonicTime m_lastProxyEnabledStatusCheckTime; 66 71 }; -
trunk/Source/WebCore/platform/network/cf/DNSResolveQueueCFNet.cpp
r229358 r229359 27 27 28 28 #include "config.h" 29 #include "DNS.h" 30 #include "DNSResolveQueue.h" 29 #include "DNSResolveQueueCFNet.h" 31 30 31 #include "NotImplemented.h" 32 #include "Timer.h" 32 33 #include "URL.h" 33 #include "Timer.h"34 34 #include <wtf/HashSet.h> 35 35 #include <wtf/MainThread.h> … … 38 38 #include <wtf/text/StringHash.h> 39 39 40 #if PLATFORM( IOS)41 #include <CFNetwork/CFNetwork.h>40 #if PLATFORM(WIN) 41 #include "LoaderRunLoopCF.h" 42 42 #endif 43 43 44 #if PLATFORM(WIN) 45 #include "LoaderRunLoopCF.h" 44 #if PLATFORM(WIN) || PLATFORM(IOS) 46 45 #include <CFNetwork/CFNetwork.h> 47 46 #endif … … 49 48 namespace WebCore { 50 49 51 void DNSResolveQueue ::updateIsUsingProxy()50 void DNSResolveQueueCFNet::updateIsUsingProxy() 52 51 { 53 52 RetainPtr<CFDictionaryRef> proxySettings = adoptCF(CFNetworkCopySystemProxySettings()); … … 79 78 } 80 79 81 void DNSResolveQueue ::platformResolve(const String& hostname)80 void DNSResolveQueueCFNet::platformResolve(const String& hostname) 82 81 { 83 82 ASSERT(isMainThread()); … … 102 101 } 103 102 104 void prefetchDNS(const String& hostname)103 void DNSResolveQueueCFNet::resolve(const String& /* hostname */, uint64_t /* identifier */, DNSCompletionHandler&& /* completionHandler */) 105 104 { 106 ASSERT(isMainThread()); 107 if (hostname.isEmpty()) 108 return; 109 DNSResolveQueue::singleton().add(hostname); 105 notImplemented(); 106 } 107 108 void DNSResolveQueueCFNet::stopResolve(uint64_t /* identifier */) 109 { 110 notImplemented(); 110 111 } 111 112 -
trunk/Source/WebCore/platform/network/cf/DNSResolveQueueCFNet.h
r229358 r229359 1 1 /* 2 * Copyright (C) 20 08 Apple Inc. All rights reserved.2 * Copyright (C) 2018 Igalia S.L. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 # include "config.h"27 #include "DNS.h" 26 #pragma once 27 28 28 #include "DNSResolveQueue.h" 29 30 #if USE(CURL)31 32 #include "NotImplemented.h"33 29 34 30 namespace WebCore { 35 31 36 void DNSResolveQueue::updateIsUsingProxy() 37 { 38 notImplemented(); 39 } 32 class DNSResolveQueueCFNet final : public DNSResolveQueue { 33 public: 34 DNSResolveQueueCFNet() = default; 35 void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) final; 36 void stopResolve(uint64_t identifier) final; 40 37 41 void DNSResolveQueue::platformResolve(const String& /* hostname */) 42 { 43 notImplemented();44 } 38 private: 39 void updateIsUsingProxy() final; 40 void platformResolve(const String&) final; 41 }; 45 42 46 void prefetchDNS(const String& /* hostname */) 47 { 48 notImplemented(); 49 } 43 using DNSResolveQueuePlatform = DNSResolveQueueCFNet; 50 44 51 45 } 52 53 #endif -
trunk/Source/WebCore/platform/network/curl/DNSResolveQueueCurl.cpp
r229358 r229359 25 25 26 26 #include "config.h" 27 #include "DNS.h" 28 #include "DNSResolveQueue.h" 27 #include "DNSResolveQueueCurl.h" 29 28 30 29 #if USE(CURL) … … 34 33 namespace WebCore { 35 34 36 void DNSResolveQueue ::updateIsUsingProxy()35 void DNSResolveQueueCurl::updateIsUsingProxy() 37 36 { 38 37 notImplemented(); 39 38 } 40 39 41 void DNSResolveQueue ::platformResolve(const String& /* hostname */)40 void DNSResolveQueueCurl::platformResolve(const String& /* hostname */) 42 41 { 43 42 notImplemented(); 44 43 } 45 44 46 void prefetchDNS(const String& /* hostname */) 45 void DNSResolveQueueCurl::resolve(const String& /* hostname */, uint64_t /* identifier */, DNSCompletionHandler&& /* completionHandler */) 46 { 47 notImplemented(); 48 } 49 50 void DNSResolveQueueCurl::stopResolve(uint64_t /* identifier */) 47 51 { 48 52 notImplemented(); -
trunk/Source/WebCore/platform/network/curl/DNSResolveQueueCurl.h
r229358 r229359 1 1 /* 2 * Copyright (C) 20 08 Apple Inc. All rights reserved.2 * Copyright (C) 2018 Igalia S.L. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 21 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 25 26 # include "config.h"27 #include "DNS.h" 26 #pragma once 27 28 28 #include "DNSResolveQueue.h" 29 30 #if USE(CURL)31 32 #include "NotImplemented.h"33 29 34 30 namespace WebCore { 35 31 36 void DNSResolveQueue::updateIsUsingProxy() 37 { 38 notImplemented(); 39 } 32 class DNSResolveQueueCurl final : public DNSResolveQueue { 33 public: 34 DNSResolveQueueCurl() = default; 35 void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) final; 36 void stopResolve(uint64_t identifier) final; 40 37 41 void DNSResolveQueue::platformResolve(const String& /* hostname */) 42 { 43 notImplemented();44 } 38 private: 39 void updateIsUsingProxy() final; 40 void platformResolve(const String&) final; 41 }; 45 42 46 void prefetchDNS(const String& /* hostname */) 47 { 48 notImplemented(); 49 } 43 using DNSResolveQueuePlatform = DNSResolveQueueCurl; 50 44 51 45 } 52 53 #endif -
trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.cpp
r229358 r229359 26 26 27 27 #include "config.h" 28 #include "DNS.h" 29 #include "DNSResolveQueue.h" 28 #include "DNSResolveQueueSoup.h" 30 29 31 30 #if USE(SOUP) … … 34 33 #include "SoupNetworkSession.h" 35 34 #include <libsoup/soup.h> 35 #include <wtf/CompletionHandler.h> 36 36 #include <wtf/MainThread.h> 37 37 #include <wtf/glib/GUniquePtr.h> … … 77 77 } 78 78 79 void DNSResolveQueue ::updateIsUsingProxy()79 void DNSResolveQueueSoup::updateIsUsingProxy() 80 80 { 81 81 GRefPtr<GProxyResolver> resolver; … … 92 92 } 93 93 94 void DNSResolveQueue::platformResolve(const String& hostname) 94 static void resolvedWithObserverCallback(SoupAddress* address, guint status, void* data) 95 { 96 ASSERT(data); 97 auto* resolveQueue = static_cast<DNSResolveQueueSoup*>(data); 98 99 uint64_t identifier = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(address), "identifier")); 100 101 auto completionAndCancelHandlers = resolveQueue->takeCompletionAndCancelHandlers(identifier); 102 103 if (!completionAndCancelHandlers) 104 return; 105 106 auto completionHandler = WTFMove(completionAndCancelHandlers.get()->first); 107 108 if (status != SOUP_STATUS_OK) { 109 DNSError error = DNSError::Unknown; 110 111 switch (status) { 112 case SOUP_STATUS_CANT_RESOLVE: 113 error = DNSError::CannotResolve; 114 break; 115 case SOUP_STATUS_CANCELLED: 116 error = DNSError::Cancelled; 117 break; 118 case SOUP_STATUS_OK: 119 default: 120 ASSERT_NOT_REACHED(); 121 }; 122 123 completionHandler(makeUnexpected(error)); 124 return; 125 } 126 127 if (!soup_address_is_resolved(address)) { 128 completionHandler(makeUnexpected(DNSError::Unknown)); 129 return; 130 } 131 132 Vector<WebCore::IPAddress> addresses; 133 addresses.reserveInitialCapacity(1); 134 int len; 135 auto* ipAddress = reinterpret_cast<const struct sockaddr_in*>(soup_address_get_sockaddr(address, &len)); 136 for (unsigned i = 0; i < sizeof(*ipAddress) / len; i++) 137 addresses.uncheckedAppend(WebCore::IPAddress(ipAddress[i])); 138 139 completionHandler(addresses); 140 } 141 142 std::unique_ptr<DNSResolveQueueSoup::CompletionAndCancelHandlers> DNSResolveQueueSoup::takeCompletionAndCancelHandlers(uint64_t identifier) 143 { 144 ASSERT(isMainThread()); 145 146 auto completionAndCancelHandlers = m_completionAndCancelHandlers.take(identifier); 147 148 if (!completionAndCancelHandlers) 149 return nullptr; 150 151 return WTFMove(completionAndCancelHandlers); 152 } 153 154 void DNSResolveQueueSoup::removeCancelAndCompletionHandler(uint64_t identifier) 155 { 156 ASSERT(isMainThread()); 157 158 m_completionAndCancelHandlers.remove(identifier); 159 } 160 161 void DNSResolveQueueSoup::platformResolve(const String& hostname) 95 162 { 96 163 ASSERT(isMainThread()); … … 99 166 } 100 167 101 void prefetchDNS(const String& hostname)168 void DNSResolveQueueSoup::resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&& completionHandler) 102 169 { 103 170 ASSERT(isMainThread()); 104 if (hostname.isEmpty())105 return;106 171 107 DNSResolveQueue::singleton().add(hostname); 172 auto address = adoptGRef(soup_address_new(hostname.utf8().data(), 0)); 173 auto cancellable = adoptGRef(g_cancellable_new()); 174 soup_address_resolve_async(address.get(), soup_session_get_async_context(WebCore::NetworkStorageSession::defaultStorageSession().getOrCreateSoupNetworkSession().soupSession()), cancellable.get(), resolvedWithObserverCallback, this); 175 176 g_object_set_data(G_OBJECT(address.get()), "identifier", GUINT_TO_POINTER(identifier)); 177 178 m_completionAndCancelHandlers.add(identifier, std::make_unique<DNSResolveQueueSoup::CompletionAndCancelHandlers>(WTFMove(completionHandler), WTFMove(cancellable))); 179 } 180 181 void DNSResolveQueueSoup::stopResolve(uint64_t identifier) 182 { 183 ASSERT(isMainThread()); 184 185 if (auto completionAndCancelHandler = m_completionAndCancelHandlers.take(identifier)) { 186 g_cancellable_cancel(completionAndCancelHandler.get()->second.get()); 187 completionAndCancelHandler.get()->first(makeUnexpected(DNSError::Cancelled)); 188 } 108 189 } 109 190 -
trunk/Source/WebCore/platform/network/soup/DNSResolveQueueSoup.h
r229358 r229359 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All Rights Reserved. 3 * Copyright (C) 2012 Igalia S.L. 2 * Copyright (C) 2018 Igalia S.L. 4 3 * 5 4 * Redistribution and use in source and binary forms, with or without … … 25 24 */ 26 25 27 #ifndef DNSResolveQueue_h 28 #define DNSResolveQueue_h 26 #pragma once 29 27 30 #include "Timer.h" 31 #include <atomic> 32 #include <wtf/Forward.h> 33 #include <wtf/HashSet.h> 34 #include <wtf/text/StringHash.h> 28 #include "DNSResolveQueue.h" 29 30 #include <wtf/HashMap.h> 31 #include <wtf/glib/GRefPtr.h> 35 32 36 33 namespace WebCore { 37 34 38 class DNSResolveQueue { 39 friend NeverDestroyed<DNSResolveQueue>; 35 class DNSResolveQueueSoup final : public DNSResolveQueue { 36 public: 37 using CompletionAndCancelHandlers = std::pair<WebCore::DNSCompletionHandler, GRefPtr<GCancellable>>; 40 38 41 public: 42 static DNSResolveQueue& singleton(); 39 DNSResolveQueueSoup() = default; 40 void resolve(const String& hostname, uint64_t identifier, DNSCompletionHandler&&) final; 41 void stopResolve(uint64_t identifier) final; 43 42 44 void add(const String& hostname); 45 void decrementRequestCount() 46 { 47 --m_requestsInFlight; 48 } 43 std::unique_ptr<CompletionAndCancelHandlers> takeCompletionAndCancelHandlers(uint64_t identifier); 44 void removeCancelAndCompletionHandler(uint64_t identifier); 49 45 50 46 private: 51 DNSResolveQueue();47 void updateIsUsingProxy() final; 52 48 53 bool isUsingProxy();49 HashMap<uint64_t, std::unique_ptr<CompletionAndCancelHandlers>> m_completionAndCancelHandlers; 54 50 55 void updateIsUsingProxy(); 56 void platformResolve(const String&); 57 58 void timerFired(); 59 60 Timer m_timer; 61 62 HashSet<String> m_names; 63 std::atomic<int> m_requestsInFlight; 64 bool m_isUsingProxy; 65 MonotonicTime m_lastProxyEnabledStatusCheckTime; 51 void platformResolve(const String&) final; 66 52 }; 67 53 54 using DNSResolveQueuePlatform = DNSResolveQueueSoup; 55 68 56 } 69 70 #endif // DNSResolveQueue_h -
trunk/Source/WebKit/ChangeLog
r229343 r229359 1 2018-03-07 Alejandro G. Castro <alex@igalia.com> 2 3 Make NetworkRTCResolver port agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=178855 5 6 Reviewed by Youenn Fablet. 7 8 Create a specific Cocoa class to isolate the generic code in the base class, make the base implementation port 9 agnostic and dependent on DNS API in the platform directory which encapsulates the platform specific details. 10 11 * NetworkProcess/webrtc/NetworkRTCProvider.cpp: Create an alias class name defined per platform to instantiate the resolver. 12 (WebKit::NetworkRTCProvider::createResolver): Used the alias class name and receive a new IPAddress class that is not 13 dependent on rtc libwebrtc library. 14 * NetworkProcess/webrtc/NetworkRTCResolver.cpp: Remove the platform specific code. Use the DNS API to implement the 15 platform specific code in the default start and stop methods. Add the identifier of the resolve operation to the class. 16 (WebKit::NetworkRTCResolver::NetworkRTCResolver): Add the identifier in the initialization. 17 (WebKit::NetworkRTCResolver::~NetworkRTCResolver): Remove the platform specific code. 18 (WebKit::NetworkRTCResolver::completed): Ditto. 19 (WebKit::NetworkRTCResolver::start): Add a new implementation using the DNS API. 20 (WebKit::NetworkRTCResolver::stop): Ditto 21 * NetworkProcess/webrtc/NetworkRTCResolver.h: Remove the platform specific code and use the DNSResolveQueue for a general 22 solution to implement the platform specific code. Avoid using the IPAddress class that depends on libwertc classes to make 23 it more general regarding DNS name resolution. 24 (WebKit::NetworkRTCResolver::start): Make this class virtual. 25 (WebKit::NetworkRTCResolver::stop): Ditto. 26 * NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp: Copied Cocoa code from Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolver.cpp. 27 Now this class overrides the start and stop methods that use DNS, cocoa implementation should use the DNS methods in the future and 28 remove this class, making sure all the platform specific class is in the platform directory. 29 * NetworkProcess/webrtc/NetworkRTCResolverCocoa.h: Copied Cocoa code from Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolver.h. 30 * PlatformGTK.cmake: Add NetworkRTCResolver compilation for GTK. 31 * WebKit.xcodeproj/project.pbxproj: Add the NetworkRTCResolverCocoa class to the compilation. 32 1 33 2018-03-06 Brent Fulgham <bfulgham@apple.com> 2 34 -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
r225499 r229359 41 41 #include <wtf/text/WTFString.h> 42 42 43 #if PLATFORM(COCOA) 44 #include "NetworkRTCResolverCocoa.h" 45 #endif 46 43 47 namespace WebKit { 44 48 … … 163 167 } 164 168 169 #if PLATFORM(COCOA) 170 165 171 void NetworkRTCProvider::createResolver(uint64_t identifier, const String& address) 166 172 { 167 auto resolver = std::make_unique<NetworkRTCResolver>([this, identifier](NetworkRTCResolver::AddressesOrError&& result) mutable {173 auto resolver = NetworkRTCResolver::create(identifier, [this, identifier](WebCore::DNSAddressesOrError&& result) mutable { 168 174 if (!result.has_value()) { 169 if (result.error() != NetworkRTCResolver::Error::Cancelled)175 if (result.error() != WebCore::DNSError::Cancelled) 170 176 m_connection->connection().send(Messages::WebRTCResolver::ResolvedAddressError(1), identifier); 171 177 return; 172 178 } 173 m_connection->connection().send(Messages::WebRTCResolver::SetResolvedAddress(result.value()), identifier); 179 180 auto addresses = WTF::map(result.value(), [] (auto& address) { 181 return RTCNetwork::IPAddress { rtc::IPAddress { address.getSinAddr() } }; 182 }); 183 184 m_connection->connection().send(Messages::WebRTCResolver::SetResolvedAddress(addresses), identifier); 174 185 }); 175 186 resolver->start(address); … … 182 193 resolver->stop(); 183 194 } 195 196 #else 197 198 void NetworkRTCProvider::createResolver(uint64_t identifier, const String& address) 199 { 200 auto completionHandler = [this, identifier](WebCore::DNSAddressesOrError&& result) mutable { 201 if (!result.has_value()) { 202 if (result.error() != WebCore::DNSError::Cancelled) 203 m_connection->connection().send(Messages::WebRTCResolver::ResolvedAddressError(1), identifier); 204 return; 205 } 206 207 auto addresses = WTF::map(result.value(), [] (auto& address) { 208 return RTCNetwork::IPAddress { rtc::IPAddress { address.getSinAddr() } }; 209 }); 210 211 m_connection->connection().send(Messages::WebRTCResolver::SetResolvedAddress(addresses), identifier); 212 }; 213 214 WebCore::resolveDNS(address, identifier, WTFMove(completionHandler)); 215 } 216 217 void NetworkRTCProvider::stopResolver(uint64_t identifier) 218 { 219 WebCore::stopResolveDNS(identifier); 220 } 221 222 #endif 184 223 185 224 void NetworkRTCProvider::closeListeningSockets(Function<void()>&& completionHandler) -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolver.cpp
r223990 r229359 33 33 namespace WebKit { 34 34 35 static void resolvedName(CFHostRef hostRef, CFHostInfoType typeInfo, const CFStreamError *error, void *info) 35 // FIXME: Use the function after removing the NetworkRTCResolverCocoa. 36 #if !PLATFORM(COCOA) 37 std::unique_ptr<NetworkRTCResolver> NetworkRTCResolver::create(uint64_t identifier, WebCore::DNSCompletionHandler&& completionHandler) 36 38 { 37 ASSERT_UNUSED(typeInfo, !typeInfo); 39 return std::unique_ptr<NetworkRTCResolver>(new NetworkRTCResolver(identifier, WTFMove(completionHandler))); 40 } 41 #endif 38 42 39 if (error->domain) { 40 // FIXME: Need to handle failure, but info is not provided in the callback. 41 return; 42 } 43 44 ASSERT(info); 45 auto* resolver = static_cast<NetworkRTCResolver*>(info); 46 47 Boolean result; 48 CFArrayRef resolvedAddresses = (CFArrayRef)CFHostGetAddressing(hostRef, &result); 49 ASSERT_UNUSED(result, result); 50 51 size_t count = CFArrayGetCount(resolvedAddresses); 52 Vector<RTCNetwork::IPAddress> addresses; 53 addresses.reserveInitialCapacity(count); 54 55 for (size_t index = 0; index < count; ++index) { 56 CFDataRef data = (CFDataRef)CFArrayGetValueAtIndex(resolvedAddresses, index); 57 auto* address = reinterpret_cast<const struct sockaddr_in*>(CFDataGetBytePtr(data)); 58 addresses.uncheckedAppend(RTCNetwork::IPAddress(rtc::IPAddress(address->sin_addr))); 59 } 60 resolver->completed(addresses); 61 } 62 63 NetworkRTCResolver::NetworkRTCResolver(CompletionHandler&& completionHandler) 64 : m_completionHandler(WTFMove(completionHandler)) 43 NetworkRTCResolver::NetworkRTCResolver(uint64_t identifier, WebCore::DNSCompletionHandler&& completionHandler) 44 : m_identifier(identifier) 45 , m_completionHandler(WTFMove(completionHandler)) 65 46 { 66 47 } … … 68 49 NetworkRTCResolver::~NetworkRTCResolver() 69 50 { 70 CFHostUnscheduleFromRunLoop(m_host.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);71 CFHostSetClient(m_host.get(), nullptr, nullptr);72 51 if (auto completionHandler = WTFMove(m_completionHandler)) 73 completionHandler(makeUnexpected( Error::Unknown));52 completionHandler(makeUnexpected(WebCore::DNSError::Unknown)); 74 53 } 75 54 76 55 void NetworkRTCResolver::start(const String& address) 77 56 { 78 m_host = adoptCF(CFHostCreateWithName(kCFAllocatorDefault, address.createCFString().get())); 79 CFHostClientContext context = { 0, this, nullptr, nullptr, nullptr }; 80 CFHostSetClient(m_host.get(), resolvedName, &context); 81 CFHostScheduleWithRunLoop(m_host.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 82 Boolean result = CFHostStartInfoResolution(m_host.get(), kCFHostAddresses, nullptr); 83 ASSERT_UNUSED(result, result); 57 WebCore::resolveDNS(address, m_identifier, WTFMove(m_completionHandler)); 84 58 } 85 59 86 60 void NetworkRTCResolver::stop() 87 61 { 88 CFHostCancelInfoResolution(m_host.get(), CFHostInfoType::kCFHostAddresses); 89 if (auto completionHandler = WTFMove(m_completionHandler)) 90 completionHandler(makeUnexpected(Error::Cancelled)); 91 } 92 93 void NetworkRTCResolver::completed(const Vector<RTCNetwork::IPAddress>& addresses) 94 { 95 if (auto completionHandler = WTFMove(m_completionHandler)) 96 completionHandler({ addresses }); 62 WebCore::stopResolveDNS(m_identifier); 97 63 } 98 64 -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolver.h
r223990 r229359 29 29 30 30 #include "RTCNetwork.h" 31 #include < CFNetwork/CFHost.h>31 #include <WebCore/DNS.h> 32 32 #include <wtf/CompletionHandler.h> 33 33 #include <wtf/text/WTFString.h> … … 37 37 class NetworkRTCResolver { 38 38 public: 39 enum class Error { Unknown, Cancelled };39 static std::unique_ptr<NetworkRTCResolver> create(uint64_t identifier, WebCore::DNSCompletionHandler&&); 40 40 41 using AddressesOrError = Expected<std::reference_wrapper<const Vector<RTCNetwork::IPAddress>>, Error>;42 using CompletionHandler = WTF::CompletionHandler<void(AddressesOrError&&)>;41 NetworkRTCResolver(uint64_t identifier, WebCore::DNSCompletionHandler&&); 42 virtual ~NetworkRTCResolver(); 43 43 44 explicit NetworkRTCResolver(CompletionHandler&&);45 ~NetworkRTCResolver();44 virtual void start(const String& address); 45 virtual void stop(); 46 46 47 void start(const String& address); 48 void stop(); 49 50 void completed(const Vector<RTCNetwork::IPAddress>&); 51 52 private: 53 CompletionHandler m_completionHandler; 54 RetainPtr<CFHostRef> m_host; 47 protected: 48 uint64_t m_identifier; 49 WebCore::DNSCompletionHandler m_completionHandler; 55 50 }; 56 51 -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp
r229358 r229359 25 25 26 26 #include "config.h" 27 #include "NetworkRTCResolver .h"27 #include "NetworkRTCResolverCocoa.h" 28 28 29 29 #if USE(LIBWEBRTC) … … 37 37 ASSERT_UNUSED(typeInfo, !typeInfo); 38 38 39 ASSERT(info); 40 auto* resolver = static_cast<NetworkRTCResolverCocoa*>(info); 41 39 42 if (error->domain) { 40 43 // FIXME: Need to handle failure, but info is not provided in the callback. 44 resolver->completed(makeUnexpected(WebCore::DNSError::Unknown)); 41 45 return; 42 46 } 43 44 ASSERT(info);45 auto* resolver = static_cast<NetworkRTCResolver*>(info);46 47 47 48 Boolean result; … … 50 51 51 52 size_t count = CFArrayGetCount(resolvedAddresses); 52 Vector< RTCNetwork::IPAddress> addresses;53 Vector<WebCore::IPAddress> addresses; 53 54 addresses.reserveInitialCapacity(count); 54 55 … … 56 57 CFDataRef data = (CFDataRef)CFArrayGetValueAtIndex(resolvedAddresses, index); 57 58 auto* address = reinterpret_cast<const struct sockaddr_in*>(CFDataGetBytePtr(data)); 58 addresses.uncheckedAppend( RTCNetwork::IPAddress(rtc::IPAddress(address->sin_addr)));59 addresses.uncheckedAppend(WebCore::IPAddress(*address)); 59 60 } 60 resolver->completed( addresses);61 resolver->completed(WTFMove(addresses)); 61 62 } 62 63 63 NetworkRTCResolver::NetworkRTCResolver(CompletionHandler&& completionHandler) 64 : m_completionHandler(WTFMove(completionHandler)) 64 std::unique_ptr<NetworkRTCResolver> NetworkRTCResolver::create(uint64_t identifier, WebCore::DNSCompletionHandler&& completionHandler) 65 { 66 return std::unique_ptr<NetworkRTCResolver>(new NetworkRTCResolverCocoa(identifier, WTFMove(completionHandler))); 67 } 68 69 NetworkRTCResolverCocoa::NetworkRTCResolverCocoa(uint64_t identifier, WebCore::DNSCompletionHandler&& completionHandler) 70 : NetworkRTCResolver(identifier, WTFMove(completionHandler)) 65 71 { 66 72 } 67 73 68 NetworkRTCResolver ::~NetworkRTCResolver()74 NetworkRTCResolverCocoa::~NetworkRTCResolverCocoa() 69 75 { 70 76 CFHostUnscheduleFromRunLoop(m_host.get(), CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 71 77 CFHostSetClient(m_host.get(), nullptr, nullptr); 72 if (auto completionHandler = WTFMove(m_completionHandler))73 completionHandler(makeUnexpected(Error::Unknown));74 78 } 75 79 76 void NetworkRTCResolver ::start(const String& address)80 void NetworkRTCResolverCocoa::start(const String& address) 77 81 { 78 82 m_host = adoptCF(CFHostCreateWithName(kCFAllocatorDefault, address.createCFString().get())); … … 84 88 } 85 89 86 void NetworkRTCResolver ::stop()90 void NetworkRTCResolverCocoa::stop() 87 91 { 88 92 CFHostCancelInfoResolution(m_host.get(), CFHostInfoType::kCFHostAddresses); 89 93 if (auto completionHandler = WTFMove(m_completionHandler)) 90 completionHandler(makeUnexpected( Error::Cancelled));94 completionHandler(makeUnexpected(WebCore::DNSError::Cancelled)); 91 95 } 92 96 93 void NetworkRTCResolver ::completed(const Vector<RTCNetwork::IPAddress>& addresses)97 void NetworkRTCResolverCocoa::completed(WebCore::DNSAddressesOrError&& addressesOrError) 94 98 { 95 99 if (auto completionHandler = WTFMove(m_completionHandler)) 96 completionHandler( { addresses });100 completionHandler(WTFMove(addressesOrError)); 97 101 } 98 102 -
trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCResolverCocoa.h
r229358 r229359 28 28 #if USE(LIBWEBRTC) 29 29 30 #include "RTCNetwork.h" 30 #include "NetworkRTCResolver.h" 31 31 32 #include <CFNetwork/CFHost.h> 32 #include <wtf/CompletionHandler.h>33 #include <wtf/text/WTFString.h>34 33 35 34 namespace WebKit { 36 35 37 class NetworkRTCResolver { 36 // FIXME: Remove this class when we complete the implementation of the DNSResolveQueueCFNet. 37 class NetworkRTCResolverCocoa final : public NetworkRTCResolver { 38 38 public: 39 enum class Error { Unknown, Cancelled }; 39 explicit NetworkRTCResolverCocoa(uint64_t identifier, WebCore::DNSCompletionHandler&&); 40 ~NetworkRTCResolverCocoa() final; 40 41 41 using AddressesOrError = Expected<std::reference_wrapper<const Vector<RTCNetwork::IPAddress>>, Error>;42 using CompletionHandler = WTF::CompletionHandler<void(AddressesOrError&&)>;42 void start(const String& address) final; 43 void stop() final; 43 44 44 explicit NetworkRTCResolver(CompletionHandler&&); 45 ~NetworkRTCResolver(); 46 47 void start(const String& address); 48 void stop(); 49 50 void completed(const Vector<RTCNetwork::IPAddress>&); 45 void completed(WebCore::DNSAddressesOrError&&); 51 46 52 47 private: 53 CompletionHandler m_completionHandler;54 48 RetainPtr<CFHostRef> m_host; 55 49 }; -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r229066 r229359 916 916 410482CE1DDD324F00F006D0 /* RTCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 410482CC1DDD2FB500F006D0 /* RTCNetwork.h */; }; 917 917 4112B5551FA0EA7A00E67875 /* NetworkRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4112B5471F9FD3AB00E67875 /* NetworkRTCResolver.cpp */; }; 918 4112B5551FA0EA7A00E67986 /* NetworkRTCResolverCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */; }; 918 919 411B22641E371BA6004F7363 /* LibWebRTCNetwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 411B22621E371244004F7363 /* LibWebRTCNetwork.h */; }; 919 920 413075A91DE85F2C0039EC69 /* NetworkRTCSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */; }; … … 3288 3289 4112B5471F9FD3AB00E67875 /* NetworkRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCResolver.cpp; path = NetworkProcess/webrtc/NetworkRTCResolver.cpp; sourceTree = "<group>"; }; 3289 3290 4112B5481F9FD3AC00E67875 /* NetworkRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkRTCResolver.h; path = NetworkProcess/webrtc/NetworkRTCResolver.h; sourceTree = "<group>"; }; 3291 4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCResolverCocoa.cpp; path = NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp; sourceTree = "<group>"; }; 3292 4112B5481F9FD3AC00E67986 /* NetworkRTCResolverCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkRTCResolverCocoa.h; path = NetworkProcess/webrtc/NetworkRTCResolverCocoa.h; sourceTree = "<group>"; }; 3290 3293 411B22621E371244004F7363 /* LibWebRTCNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCNetwork.h; path = Network/webrtc/LibWebRTCNetwork.h; sourceTree = "<group>"; }; 3291 3294 413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCSocket.cpp; path = NetworkProcess/webrtc/NetworkRTCSocket.cpp; sourceTree = "<group>"; }; … … 6237 6240 4112B5471F9FD3AB00E67875 /* NetworkRTCResolver.cpp */, 6238 6241 4112B5481F9FD3AC00E67875 /* NetworkRTCResolver.h */, 6242 4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */, 6243 4112B5481F9FD3AC00E67986 /* NetworkRTCResolverCocoa.h */, 6239 6244 413075981DE84FB00039EC69 /* NetworkRTCSocket.cpp */, 6240 6245 413075991DE84FB00039EC69 /* NetworkRTCSocket.h */, … … 10622 10627 51F060E11654318500F3282E /* NetworkRTCProviderMessageReceiver.cpp in Sources */, 10623 10628 4112B5551FA0EA7A00E67875 /* NetworkRTCResolver.cpp in Sources */, 10629 4112B5551FA0EA7A00E67986 /* NetworkRTCResolverCocoa.cpp in Sources */, 10624 10630 413075A91DE85F2C0039EC69 /* NetworkRTCSocket.cpp in Sources */, 10625 10631 51F060E11654318500F3281D /* NetworkRTCSocketMessageReceiver.cpp in Sources */, -
trunk/Tools/ChangeLog
r229349 r229359 1 2018-03-07 Alejandro G. Castro <alex@igalia.com> 2 3 Make NetworkRTCResolver port agnostic 4 https://bugs.webkit.org/show_bug.cgi?id=178855 5 6 Reviewed by Youenn Fablet. 7 8 Added new unit tests for he resolve and stopResolve functions. We need to compile them for the 9 other platforms when the APIs are supported. 10 11 * TestWebKitAPI/PlatformGTK.cmake: 12 * TestWebKitAPI/Tests/WebCore/DNS.cpp: 13 1 14 2018-03-06 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/Tools/TestWebKitAPI/PlatformGTK.cmake
r228451 r229359 88 88 ${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp 89 89 ${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp 90 ${TESTWEBKITAPI_DIR}/Tests/WebCore/DNS.cpp 90 91 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp 91 92 ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
Note: See TracChangeset
for help on using the changeset viewer.