Title: [245858] trunk/Source/WebKit
Revision
245858
Author
[email protected]
Date
2019-05-29 11:36:06 -0700 (Wed, 29 May 2019)

Log Message

UserMediaCaptureManagerProxy::SourceProxy should directly have access to its IPC connection
https://bugs.webkit.org/show_bug.cgi?id=198335

Reviewed by Eric Carlson.

Previously, SourceProxy was getting its IPC connection by going through its manager, then its process proxy.
As some calls can be done from a background thread, it is safer to directly make SourceProxy own a Ref of its IPC connection.

* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy):
(WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (245857 => 245858)


--- trunk/Source/WebKit/ChangeLog	2019-05-29 18:22:00 UTC (rev 245857)
+++ trunk/Source/WebKit/ChangeLog	2019-05-29 18:36:06 UTC (rev 245858)
@@ -1,3 +1,17 @@
+2019-05-29  Youenn Fablet  <[email protected]>
+
+        UserMediaCaptureManagerProxy::SourceProxy should directly have access to its IPC connection
+        https://bugs.webkit.org/show_bug.cgi?id=198335
+
+        Reviewed by Eric Carlson.
+
+        Previously, SourceProxy was getting its IPC connection by going through its manager, then its process proxy.
+        As some calls can be done from a background thread, it is safer to directly make SourceProxy own a Ref of its IPC connection.
+
+        * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+        (WebKit::UserMediaCaptureManagerProxy::SourceProxy::SourceProxy):
+        (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints):
+
 2019-05-28  Geoffrey Garen  <[email protected]>
 
         WeakPtr breaks vtables when upcasting to base classes

Modified: trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (245857 => 245858)


--- trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2019-05-29 18:22:00 UTC (rev 245857)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2019-05-29 18:36:06 UTC (rev 245858)
@@ -46,9 +46,9 @@
 
 class UserMediaCaptureManagerProxy::SourceProxy : public RealtimeMediaSource::Observer, public SharedRingBufferStorage::Client {
 public:
-    SourceProxy(uint64_t id, UserMediaCaptureManagerProxy& manager, Ref<RealtimeMediaSource>&& source)
+    SourceProxy(uint64_t id, Ref<IPC::Connection>&& connection, Ref<RealtimeMediaSource>&& source)
         : m_id(id)
-        , m_manager(manager)
+        , m_connection(WTFMove(connection))
         , m_source(WTFMove(source))
         , m_ringBuffer(makeUniqueRef<SharedRingBufferStorage>(makeUniqueRef<SharedRingBufferStorage>(this)))
     {
@@ -68,18 +68,18 @@
 
     void sourceStopped() final {
         if (m_source->captureDidFail()) {
-            m_manager.process().send(Messages::UserMediaCaptureManager::CaptureFailed(m_id), 0);
+            m_connection->send(Messages::UserMediaCaptureManager::CaptureFailed(m_id), 0);
             return;
         }
-        m_manager.process().send(Messages::UserMediaCaptureManager::SourceStopped(m_id), 0);
+        m_connection->send(Messages::UserMediaCaptureManager::SourceStopped(m_id), 0);
     }
 
     void sourceMutedChanged() final {
-        m_manager.process().send(Messages::UserMediaCaptureManager::SourceMutedChanged(m_id, m_source->muted()), 0);
+        m_connection->send(Messages::UserMediaCaptureManager::SourceMutedChanged(m_id, m_source->muted()), 0);
     }
 
     void sourceSettingsChanged() final {
-        m_manager.process().send(Messages::UserMediaCaptureManager::SourceSettingsChanged(m_id, m_source->settings()), 0);
+        m_connection->send(Messages::UserMediaCaptureManager::SourceSettingsChanged(m_id, m_source->settings()), 0);
     }
 
     // May get called on a background thread.
@@ -98,7 +98,7 @@
         uint64_t startFrame;
         uint64_t endFrame;
         m_ringBuffer.getCurrentFrameBounds(startFrame, endFrame);
-        m_manager.process().send(Messages::UserMediaCaptureManager::AudioSamplesAvailable(m_id, time, numberOfFrames, startFrame, endFrame), 0);
+        m_connection->send(Messages::UserMediaCaptureManager::AudioSamplesAvailable(m_id, time, numberOfFrames, startFrame, endFrame), 0);
     }
 
     void videoSampleAvailable(MediaSample& sample) final
@@ -106,7 +106,7 @@
 #if HAVE(IOSURFACE)
         auto remoteSample = RemoteVideoSample::create(WTFMove(sample));
         if (remoteSample)
-            m_manager.process().send(Messages::UserMediaCaptureManager::RemoteVideoSampleAvailable(m_id, WTFMove(*remoteSample)), 0);
+            m_connection->send(Messages::UserMediaCaptureManager::RemoteVideoSampleAvailable(m_id, WTFMove(*remoteSample)), 0);
 #else
         ASSERT_NOT_REACHED();
 #endif
@@ -116,12 +116,12 @@
         SharedMemory::Handle handle;
         if (storage)
             storage->createHandle(handle, SharedMemory::Protection::ReadOnly);
-        m_manager.process().send(Messages::UserMediaCaptureManager::StorageChanged(m_id, handle, m_description, m_numberOfFrames), 0);
+        m_connection->send(Messages::UserMediaCaptureManager::StorageChanged(m_id, handle, m_description, m_numberOfFrames), 0);
     }
 
 protected:
     uint64_t m_id;
-    UserMediaCaptureManagerProxy& m_manager;
+    Ref<IPC::Connection> m_connection;
     Ref<RealtimeMediaSource> m_source;
     CARingBuffer m_ringBuffer;
     CAAudioStreamDescription m_description { };
@@ -168,7 +168,7 @@
         source->setIsRemote(true);
         settings = source->settings();
         ASSERT(!m_proxies.contains(id));
-        m_proxies.add(id, std::make_unique<SourceProxy>(id, *this, WTFMove(source)));
+        m_proxies.add(id, std::make_unique<SourceProxy>(id, *m_process.connection(), WTFMove(source)));
     } else
         invalidConstraints = WTFMove(sourceOrError.errorMessage);
     completionHandler(succeeded, invalidConstraints, WTFMove(settings));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to