<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[213190] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/213190">213190</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2017-02-28 16:07:23 -0800 (Tue, 28 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>LibWebRTCProvider should check existence of libwebrtc.dylib
https://bugs.webkit.org/show_bug.cgi?id=168986
Source/WebCore:

&lt;rdar://problem/30735413&gt;

Reviewed by Youenn Fablet.

Some configurations of the webrtc tests overwrite the availability of WebRTC in order to test it
with MockLibWebRTCPeerConnection.  If the dylib can not be found, we can't use it, so we want to
fail these tests rather than crashing calling rtc::LogMessage::LogToDebug.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::doCreateOffer):
(WebCore::LibWebRTCMediaEndpoint::doCreateAnswer):
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::LibWebRTCProvider::factory):
(WebCore::LibWebRTCProvider::webRTCAvailable):
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:
* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::useMockRTCPeerConnectionFactory):
(WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):

Source/WebKit2:


Reviewed by Youenn Fablet.

* Shared/WebPreferencesDefinitions.h:
* Shared/WebPreferencesStore.cpp:
* UIProcess/WebPreferences.cpp:
(WebKit::checkWebRTCAvailability): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp">trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProvidercpp">trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProviderh">trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h</a></li>
<li><a href="#trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp">trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesDefinitionsh">trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebPreferencesStorecpp">trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPreferencescpp">trunk/Source/WebKit2/UIProcess/WebPreferences.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/CMakeLists.txt        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -2300,6 +2300,8 @@
</span><span class="cx">     platform/mediastream/RealtimeMediaSourceSettings.cpp
</span><span class="cx">     platform/mediastream/SDPProcessorScriptResource.cpp
</span><span class="cx"> 
</span><ins>+    platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
+
</ins><span class="cx">     platform/mock/DeviceOrientationClientMock.cpp
</span><span class="cx">     platform/mock/GeolocationClientMock.cpp
</span><span class="cx">     platform/mock/MockMediaEndpoint.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/ChangeLog        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2017-02-28  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        LibWebRTCProvider should check existence of libwebrtc.dylib
+        https://bugs.webkit.org/show_bug.cgi?id=168986
+        &lt;rdar://problem/30735413&gt;
+
+        Reviewed by Youenn Fablet.
+
+        Some configurations of the webrtc tests overwrite the availability of WebRTC in order to test it
+        with MockLibWebRTCPeerConnection.  If the dylib can not be found, we can't use it, so we want to
+        fail these tests rather than crashing calling rtc::LogMessage::LogToDebug.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::doCreateOffer):
+        (WebCore::LibWebRTCMediaEndpoint::doCreateAnswer):
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+        (WebCore::LibWebRTCProvider::factory):
+        (WebCore::LibWebRTCProvider::webRTCAvailable):
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
+        * testing/MockLibWebRTCPeerConnection.cpp:
+        (WebCore::useMockRTCPeerConnectionFactory):
+        (WebCore::MockLibWebRTCPeerConnectionFactory::CreatePeerConnection):
+
</ins><span class="cx"> 2017-02-28  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Apply a review comment that was missing in r213182
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediastreamlibwebrtcLibWebRTCMediaEndpointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -155,11 +155,16 @@
</span><span class="cx"> 
</span><span class="cx"> void LibWebRTCMediaEndpoint::doCreateOffer()
</span><span class="cx"> {
</span><ins>+    if (!LibWebRTCProvider::factory()) {
+        m_peerConnectionBackend.createOfferFailed(Exception { NOT_SUPPORTED_ERR, ASCIILiteral(&quot;libwebrtc backend is missing.&quot;) });
+        return;
+    }
+        
</ins><span class="cx">     m_isInitiator = true;
</span><span class="cx">     auto&amp; senders = m_peerConnectionBackend.connection().getSenders();
</span><span class="cx">     if (senders.size()) {
</span><span class="cx">         // FIXME: We only support one stream for the moment.
</span><del>-        auto stream = LibWebRTCProvider::factory().CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));
</del><ins>+        auto stream = LibWebRTCProvider::factory()-&gt;CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));
</ins><span class="cx">         for (RTCRtpSender&amp; sender : senders) {
</span><span class="cx">             auto* track = sender.track();
</span><span class="cx">             if (track) {
</span><span class="lines">@@ -167,13 +172,13 @@
</span><span class="cx">                 auto&amp; source = track-&gt;source();
</span><span class="cx">                 if (source.type() == RealtimeMediaSource::Audio) {
</span><span class="cx">                     auto trackSource = RealtimeOutgoingAudioSource::create(source);
</span><del>-                    auto rtcTrack = LibWebRTCProvider::factory().CreateAudioTrack(track-&gt;id().utf8().data(), trackSource.ptr());
</del><ins>+                    auto rtcTrack = LibWebRTCProvider::factory()-&gt;CreateAudioTrack(track-&gt;id().utf8().data(), trackSource.ptr());
</ins><span class="cx">                     trackSource-&gt;setTrack(rtc::scoped_refptr&lt;webrtc::AudioTrackInterface&gt;(rtcTrack));
</span><span class="cx">                     m_peerConnectionBackend.addAudioSource(WTFMove(trackSource));
</span><span class="cx">                     stream-&gt;AddTrack(WTFMove(rtcTrack));
</span><span class="cx">                 } else {
</span><span class="cx">                     auto videoSource = RealtimeOutgoingVideoSource::create(source);
</span><del>-                    auto videoTrack = LibWebRTCProvider::factory().CreateVideoTrack(track-&gt;id().utf8().data(), videoSource.ptr());
</del><ins>+                    auto videoTrack = LibWebRTCProvider::factory()-&gt;CreateVideoTrack(track-&gt;id().utf8().data(), videoSource.ptr());
</ins><span class="cx">                     m_peerConnectionBackend.addVideoSource(WTFMove(videoSource));
</span><span class="cx">                     stream-&gt;AddTrack(WTFMove(videoTrack));
</span><span class="cx">                 }
</span><span class="lines">@@ -186,12 +191,17 @@
</span><span class="cx"> 
</span><span class="cx"> void LibWebRTCMediaEndpoint::doCreateAnswer()
</span><span class="cx"> {
</span><ins>+    if (!LibWebRTCProvider::factory()) {
+        m_peerConnectionBackend.createAnswerFailed(Exception { NOT_SUPPORTED_ERR, ASCIILiteral(&quot;libwebrtc backend is missing.&quot;) });
+        return;
+    }
+
</ins><span class="cx">     m_isInitiator = false;
</span><span class="cx"> 
</span><span class="cx">     auto&amp; senders = m_peerConnectionBackend.connection().getSenders();
</span><span class="cx">     if (senders.size()) {
</span><span class="cx">         // FIXME: We only support one stream for the moment.
</span><del>-        auto stream = LibWebRTCProvider::factory().CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));
</del><ins>+        auto stream = LibWebRTCProvider::factory()-&gt;CreateLocalMediaStream(streamId(m_peerConnectionBackend.connection()));
</ins><span class="cx">         for (RTCRtpSender&amp; sender : senders) {
</span><span class="cx">             auto* track = sender.track();
</span><span class="cx">             if (track) {
</span><span class="lines">@@ -199,13 +209,13 @@
</span><span class="cx">                 auto&amp; source = track-&gt;source();
</span><span class="cx">                 if (source.type() == RealtimeMediaSource::Audio) {
</span><span class="cx">                     auto trackSource = RealtimeOutgoingAudioSource::create(source);
</span><del>-                    auto rtcTrack = LibWebRTCProvider::factory().CreateAudioTrack(track-&gt;id().utf8().data(), trackSource.ptr());
</del><ins>+                    auto rtcTrack = LibWebRTCProvider::factory()-&gt;CreateAudioTrack(track-&gt;id().utf8().data(), trackSource.ptr());
</ins><span class="cx">                     trackSource-&gt;setTrack(rtc::scoped_refptr&lt;webrtc::AudioTrackInterface&gt;(rtcTrack));
</span><span class="cx">                     m_peerConnectionBackend.addAudioSource(WTFMove(trackSource));
</span><span class="cx">                     stream-&gt;AddTrack(WTFMove(rtcTrack));
</span><span class="cx">                 } else {
</span><span class="cx">                     auto videoSource = RealtimeOutgoingVideoSource::create(source);
</span><del>-                    auto videoTrack = LibWebRTCProvider::factory().CreateVideoTrack(track-&gt;id().utf8().data(), videoSource.ptr());
</del><ins>+                    auto videoTrack = LibWebRTCProvider::factory()-&gt;CreateVideoTrack(track-&gt;id().utf8().data(), videoSource.ptr());
</ins><span class="cx">                     m_peerConnectionBackend.addVideoSource(WTFMove(videoSource));
</span><span class="cx">                     stream-&gt;AddTrack(WTFMove(videoTrack));
</span><span class="cx">                 }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProvidercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -27,9 +27,9 @@
</span><span class="cx"> #include &quot;LibWebRTCProvider.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #if USE(LIBWEBRTC)
</span><del>-
</del><span class="cx"> #include &quot;LibWebRTCAudioModule.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><ins>+#include &lt;dlfcn.h&gt;
</ins><span class="cx"> #include &lt;webrtc/api/peerconnectionfactory.h&gt;
</span><span class="cx"> #include &lt;webrtc/api/peerconnectionfactoryproxy.h&gt;
</span><span class="cx"> #include &lt;webrtc/base/physicalsocketserver.h&gt;
</span><span class="lines">@@ -37,9 +37,11 @@
</span><span class="cx"> #include &lt;webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h&gt;
</span><span class="cx"> #include &lt;wtf/Function.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+#if USE(LIBWEBRTC)
</ins><span class="cx"> struct PeerConnectionFactoryAndThreads : public rtc::MessageHandler {
</span><span class="cx">     std::unique_ptr&lt;LibWebRTCAudioModule&gt; audioDeviceModule;
</span><span class="cx">     std::unique_ptr&lt;rtc::Thread&gt; networkThread;
</span><span class="lines">@@ -111,11 +113,13 @@
</span><span class="cx">     ASSERT(factoryAndThreads.factory);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-webrtc::PeerConnectionFactoryInterface&amp; LibWebRTCProvider::factory()
</del><ins>+webrtc::PeerConnectionFactoryInterface* LibWebRTCProvider::factory()
</ins><span class="cx"> {
</span><ins>+    if (!webRTCAvailable())
+        return nullptr;
</ins><span class="cx">     if (!staticFactoryAndThreads().factory)
</span><span class="cx">         initializePeerConnectionFactoryAndThreads();
</span><del>-    return *staticFactoryAndThreads().factory;
</del><ins>+    return staticFactoryAndThreads().factory;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void LibWebRTCProvider::setPeerConnectionFactory(rtc::scoped_refptr&lt;webrtc::PeerConnectionFactoryInterface&gt;&amp;&amp; factory)
</span><span class="lines">@@ -166,7 +170,22 @@
</span><span class="cx"> 
</span><span class="cx">     return createActualPeerConnection(observer, WTFMove(portAllocator));
</span><span class="cx"> }
</span><ins>+#endif // USE(LIBWEBRTC)
</ins><span class="cx"> 
</span><ins>+bool LibWebRTCProvider::webRTCAvailable()
+{
+#if USE(LIBWEBRTC)
+    static bool available = [] {
+        void* libwebrtcLibrary = dlopen(&quot;libwebrtc.dylib&quot;, RTLD_LAZY);
+        if (!libwebrtcLibrary)
+            return false;
+        dlclose(libwebrtcLibrary);
+        return true;
+    }();
+    return available;
+#else
+    return true;
+#endif
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><del>-
-#endif // USE(LIBWEBRTC)
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreamlibwebrtcLibWebRTCProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     LibWebRTCProvider() = default;
</span><span class="cx">     virtual ~LibWebRTCProvider() = default;
</span><span class="cx"> 
</span><ins>+    static bool webRTCAvailable();
</ins><span class="cx"> #if USE(LIBWEBRTC)
</span><span class="cx">     WEBCORE_EXPORT virtual rtc::scoped_refptr&lt;webrtc::PeerConnectionInterface&gt; createPeerConnection(webrtc::PeerConnectionObserver&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +57,7 @@
</span><span class="cx">     // FIXME: Make these methods not static.
</span><span class="cx">     static WEBCORE_EXPORT void callOnWebRTCNetworkThread(Function&lt;void()&gt;&amp;&amp;);
</span><span class="cx">     static WEBCORE_EXPORT void callOnWebRTCSignalingThread(Function&lt;void()&gt;&amp;&amp;);
</span><del>-    static WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface&amp; factory();
</del><ins>+    static WEBCORE_EXPORT webrtc::PeerConnectionFactoryInterface* factory();
</ins><span class="cx">     // Used for mock testing
</span><span class="cx">     static void setPeerConnectionFactory(rtc::scoped_refptr&lt;webrtc::PeerConnectionFactoryInterface&gt;&amp;&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockLibWebRTCPeerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (provider &amp;&amp; !realPeerConnectionFactory()) {
</span><span class="cx">         auto&amp; factory = getRealPeerConnectionFactory();
</span><del>-        factory = &amp;provider-&gt;factory();
</del><ins>+        factory = provider-&gt;factory();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     LibWebRTCProvider::setPeerConnectionFactory(MockLibWebRTCPeerConnectionFactory::create(String(testCase)));
</span><span class="lines">@@ -162,6 +162,9 @@
</span><span class="cx"> 
</span><span class="cx"> rtc::scoped_refptr&lt;webrtc::PeerConnectionInterface&gt; MockLibWebRTCPeerConnectionFactory::CreatePeerConnection(const webrtc::PeerConnectionInterface::RTCConfiguration&amp; configuration, std::unique_ptr&lt;cricket::PortAllocator&gt; portAllocator, std::unique_ptr&lt;rtc::RTCCertificateGeneratorInterface&gt; generator, webrtc::PeerConnectionObserver* observer)
</span><span class="cx"> {
</span><ins>+    if (!realPeerConnectionFactory())
+        return nullptr;
+
</ins><span class="cx">     if (m_numberOfRealPeerConnections) {
</span><span class="cx">         auto connection = realPeerConnectionFactory()-&gt;CreatePeerConnection(configuration, WTFMove(portAllocator), WTFMove(generator), observer);
</span><span class="cx">         --m_numberOfRealPeerConnections;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-02-28  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        LibWebRTCProvider should check existence of libwebrtc.dylib
+        https://bugs.webkit.org/show_bug.cgi?id=168986
+
+        Reviewed by Youenn Fablet.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * Shared/WebPreferencesStore.cpp:
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::checkWebRTCAvailability): Deleted.
+
</ins><span class="cx"> 2017-02-28  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, build fix after r213176.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesDefinitionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -312,11 +312,6 @@
</span><span class="cx"> //   DEFAULT_EXPERIMENTAL_FEATURE_ENABLED (for features that are ready for
</span><span class="cx"> //   wider testing).
</span><span class="cx"> 
</span><del>-// Disable webrtc feature if libwebrtc library is not present
-namespace WebKit {
-bool checkWebRTCAvailability();
-}
-
</del><span class="cx"> #define FOR_EACH_WEBKIT_EXPERIMENTAL_FEATURE_PREFERENCE(macro) \
</span><span class="cx">     macro(SpringTimingFunctionEnabled, springTimingFunctionEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, &quot;CSS Spring Animations&quot;, &quot;CSS Spring Animation prototype&quot;) \
</span><span class="cx">     macro(GamepadsEnabled, gamepadsEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, &quot;Gamepads&quot;, &quot;Web Gamepad API support&quot;) \
</span><span class="lines">@@ -328,7 +323,7 @@
</span><span class="cx">     macro(UserTimingEnabled, userTimingEnabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, &quot;User Timing&quot;, &quot;Enable UserTiming API&quot;) \
</span><span class="cx">     macro(WebAnimationsEnabled, webAnimationsEnabled, Bool, bool, false, &quot;Web Animations&quot;, &quot;Web Animations prototype&quot;) \
</span><span class="cx">     macro(WebGL2Enabled, webGL2Enabled, Bool, bool, DEFAULT_EXPERIMENTAL_FEATURES_ENABLED, &quot;WebGL 2.0&quot;, &quot;WebGL 2 prototype&quot;) \
</span><del>-    macro(PeerConnectionEnabled, peerConnectionEnabled, Bool, bool, checkWebRTCAvailability(), &quot;WebRTC&quot;, &quot;Enable WebRTC API&quot;) \
</del><ins>+    macro(PeerConnectionEnabled, peerConnectionEnabled, Bool, bool, WebCore::LibWebRTCProvider::webRTCAvailable(), &quot;WebRTC&quot;, &quot;Enable WebRTC API&quot;) \
</ins><span class="cx">     \
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebPreferencesStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebKit2/Shared/WebPreferencesStore.cpp        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;FontSmoothingLevel.h&quot;
</span><span class="cx"> #include &quot;WebCoreArgumentCoders.h&quot;
</span><span class="cx"> #include &quot;WebPreferencesKeys.h&quot;
</span><ins>+#include &lt;WebCore/LibWebRTCProvider.h&gt;
</ins><span class="cx"> #include &lt;WebCore/Settings.h&gt;
</span><span class="cx"> #include &lt;WebCore/TextEncodingRegistry.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.cpp (213189 => 213190)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPreferences.cpp        2017-03-01 00:01:57 UTC (rev 213189)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.cpp        2017-03-01 00:07:23 UTC (rev 213190)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #include &quot;WebPageGroup.h&quot;
</span><span class="cx"> #include &quot;WebPreferencesKeys.h&quot;
</span><span class="cx"> #include &quot;WebProcessPool.h&quot;
</span><del>-#include &lt;dlfcn.h&gt;
</del><ins>+#include &lt;WebCore/LibWebRTCProvider.h&gt;
</ins><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="cx"> #include &lt;wtf/ThreadingPrimitives.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -196,22 +196,6 @@
</span><span class="cx"> 
</span><span class="cx"> #undef DEFINE_PREFERENCE_GETTER_AND_SETTERS
</span><span class="cx"> 
</span><del>-bool checkWebRTCAvailability()
-{
-#if USE(LIBWEBRTC)
-    static bool available = [&amp;] {
-        void* libwebrtcLibrary = dlopen(&quot;libwebrtc.dylib&quot;, RTLD_LAZY);
-        if (!libwebrtcLibrary)
-            return false;
-        dlclose(libwebrtcLibrary);
-        return true;
-    }();
-    return available;
-#else
-    return true;
-#endif
-}
-
</del><span class="cx"> #define DEFINE_EXPERIMENTAL_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
</span><span class="cx">     void WebPreferences::set##KeyUpper(const Type&amp; value) \
</span><span class="cx">     { \
</span></span></pre>
</div>
</div>

</body>
</html>