MockLibWebRTCPeerConnectionFactory should isolate copy its test case
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 16:30:53 +0000 (16:30 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Dec 2018 16:30:53 +0000 (16:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192545

Reviewed by Eric Carlson.

Isolate copy the test case member so that it can be destroyed on another thread.
Covered by existing test that should no longer crash.

* testing/MockLibWebRTCPeerConnection.cpp:
(WebCore::useMockRTCPeerConnectionFactory):
(WebCore::MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory):
* testing/MockLibWebRTCPeerConnection.h:
(WebCore::MockLibWebRTCPeerConnectionFactory::create):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239030 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/testing/MockLibWebRTCPeerConnection.cpp
Source/WebCore/testing/MockLibWebRTCPeerConnection.h

index 2b56068..bc129d3 100644 (file)
@@ -1,3 +1,19 @@
+2018-12-10  Youenn Fablet  <youenn@apple.com>
+
+        MockLibWebRTCPeerConnectionFactory should isolate copy its test case
+        https://bugs.webkit.org/show_bug.cgi?id=192545
+
+        Reviewed by Eric Carlson.
+
+        Isolate copy the test case member so that it can be destroyed on another thread.
+        Covered by existing test that should no longer crash.
+
+        * testing/MockLibWebRTCPeerConnection.cpp:
+        (WebCore::useMockRTCPeerConnectionFactory):
+        (WebCore::MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory):
+        * testing/MockLibWebRTCPeerConnection.h:
+        (WebCore::MockLibWebRTCPeerConnectionFactory::create):
+
 2018-12-09  Youenn Fablet  <youenn@apple.com>
 
         Move capture manager from RealtimeMediaSourceCenter to capture factory
index 1597eb7..2192b93 100644 (file)
@@ -66,7 +66,7 @@ void useMockRTCPeerConnectionFactory(LibWebRTCProvider* provider, const String&
         auto& factory = getRealPeerConnectionFactory();
         factory = provider->factory();
     }
-    provider->setPeerConnectionFactory(MockLibWebRTCPeerConnectionFactory::create(String(testCase)));
+    provider->setPeerConnectionFactory(MockLibWebRTCPeerConnectionFactory::create(testCase));
 }
 
 MockLibWebRTCPeerConnection::~MockLibWebRTCPeerConnection()
@@ -167,8 +167,8 @@ private:
     void SetLocalDescription(webrtc::SetSessionDescriptionObserver* observer, webrtc::SessionDescriptionInterface*) final { releaseInNetworkThread(*this, *observer); }
 };
 
-MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory(String&& testCase)
-    : m_testCase(WTFMove(testCase))
+MockLibWebRTCPeerConnectionFactory::MockLibWebRTCPeerConnectionFactory(const String& testCase)
+    : m_testCase(testCase.isolatedCopy())
 {
 }
 
index 77a2170..be3c63f 100644 (file)
@@ -235,10 +235,10 @@ private:
     
 class MockLibWebRTCPeerConnectionFactory : public webrtc::PeerConnectionFactoryInterface {
 public:
-    static rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> create(String&& testCase) { return new rtc::RefCountedObject<MockLibWebRTCPeerConnectionFactory>(WTFMove(testCase)); }
+    static rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> create(const String& testCase) { return new rtc::RefCountedObject<MockLibWebRTCPeerConnectionFactory>(testCase); }
 
 protected:
-    MockLibWebRTCPeerConnectionFactory(String&&);
+    explicit MockLibWebRTCPeerConnectionFactory(const String&);
 
 private:
     rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(const webrtc::PeerConnectionInterface::RTCConfiguration&, webrtc::PeerConnectionDependencies) final;