Title: [130270] trunk/Source
Revision
130270
Author
[email protected]
Date
2012-10-03 02:52:19 -0700 (Wed, 03 Oct 2012)

Log Message

MediaStream API: RTCPeerConnection should send down its handler via the FrameLoaderClient directly after creation.
https://bugs.webkit.org/show_bug.cgi?id=98149

Reviewed by Adam Barth.

Source/WebCore:

The chromium implementation needs to know which Frame created a PeerConnection so
that the right housekeeping can take place correctly.

Not testable in DRT, but have verified the change manually and with our pyautotests.

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::RTCPeerConnection):
* loader/FrameLoaderClient.h:
(WebCore):
(FrameLoaderClient):
(WebCore::FrameLoaderClient::dispatchWillStartUsingPeerConnectionHandler):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
(WebCore::RTCPeerConnectionHandlerChromium::toWebRTCPeerConnectionHandler):
(WebCore):
(WebCore::RTCPeerConnectionHandlerChromium::RTCPeerConnectionHandlerChromium):
(WebCore::RTCPeerConnectionHandlerChromium::initialize):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
(RTCPeerConnectionHandlerChromium):

Source/WebKit/chromium:

Adding willStartUsingPeerConnectionHandler to the WebFrameClient.

* public/WebFrameClient.h:
(WebKit):
(WebFrameClient):
(WebKit::WebFrameClient::willStartUsingPeerConnectionHandler):
* src/FrameLoaderClientImpl.cpp:
(WebKit):
(WebKit::FrameLoaderClientImpl::dispatchWillStartUsingPeerConnectionHandler):
* src/FrameLoaderClientImpl.h:
(FrameLoaderClientImpl):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130269 => 130270)


--- trunk/Source/WebCore/ChangeLog	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebCore/ChangeLog	2012-10-03 09:52:19 UTC (rev 130270)
@@ -1,3 +1,29 @@
+2012-10-03  Tommy Widenflycht  <[email protected]>
+
+        MediaStream API: RTCPeerConnection should send down its handler via the FrameLoaderClient directly after creation.
+        https://bugs.webkit.org/show_bug.cgi?id=98149
+
+        Reviewed by Adam Barth.
+
+        The chromium implementation needs to know which Frame created a PeerConnection so
+        that the right housekeeping can take place correctly.
+
+        Not testable in DRT, but have verified the change manually and with our pyautotests.
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::RTCPeerConnection):
+        * loader/FrameLoaderClient.h:
+        (WebCore):
+        (FrameLoaderClient):
+        (WebCore::FrameLoaderClient::dispatchWillStartUsingPeerConnectionHandler):
+        * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
+        (WebCore::RTCPeerConnectionHandlerChromium::toWebRTCPeerConnectionHandler):
+        (WebCore):
+        (WebCore::RTCPeerConnectionHandlerChromium::RTCPeerConnectionHandlerChromium):
+        (WebCore::RTCPeerConnectionHandlerChromium::initialize):
+        * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
+        (RTCPeerConnectionHandlerChromium):
+
 2012-10-03  Eugene Klyuchnikov  <[email protected]>
 
         Web Inspector: Profiles: taking heap snapshot causes error message in console.

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (130269 => 130270)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2012-10-03 09:52:19 UTC (rev 130270)
@@ -35,8 +35,11 @@
 #include "RTCPeerConnection.h"
 
 #include "ArrayValue.h"
+#include "Document.h"
 #include "Event.h"
 #include "ExceptionCode.h"
+#include "Frame.h"
+#include "FrameLoaderClient.h"
 #include "MediaConstraintsImpl.h"
 #include "MediaStreamEvent.h"
 #include "RTCConfiguration.h"
@@ -130,9 +133,26 @@
     , m_localStreams(MediaStreamList::create())
     , m_remoteStreams(MediaStreamList::create())
 {
+    ASSERT(m_scriptExecutionContext->isDocument());
+    Document* document = static_cast<Document*>(m_scriptExecutionContext);
+
+    if (!document->frame()) {
+        ec = NOT_SUPPORTED_ERR;
+        return;
+    }
+
     m_peerHandler = RTCPeerConnectionHandler::create(this);
-    if (!m_peerHandler || !m_peerHandler->initialize(configuration, constraints))
+    if (!m_peerHandler) {
         ec = NOT_SUPPORTED_ERR;
+        return;
+    }
+
+    document->frame()->loader()->client()->dispatchWillStartUsingPeerConnectionHandler(m_peerHandler.get());
+
+    if (!m_peerHandler->initialize(configuration, constraints)) {
+        ec = NOT_SUPPORTED_ERR;
+        return;
+    }
 }
 
 RTCPeerConnection::~RTCPeerConnection()

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (130269 => 130270)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2012-10-03 09:52:19 UTC (rev 130270)
@@ -96,6 +96,9 @@
     class ResourceLoader;
     class ResourceRequest;
     class ResourceResponse;
+#if ENABLE(MEDIA_STREAM)
+    class RTCPeerConnectionHandler;
+#endif
     class SecurityOrigin;
     class SharedBuffer;
     class SocketStreamHandle;
@@ -341,6 +344,10 @@
         virtual void dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(DOMWindowExtension*) { }
         virtual void dispatchDidReconnectDOMWindowExtensionToGlobalObject(DOMWindowExtension*) { }
         virtual void dispatchWillDestroyGlobalObjectForDOMWindowExtension(DOMWindowExtension*) { }
+
+#if ENABLE(MEDIA_STREAM)
+        virtual void dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler*) { }
+#endif
     };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp (130269 => 130270)


--- trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp	2012-10-03 09:52:19 UTC (rev 130270)
@@ -55,6 +55,11 @@
 
 namespace WebCore {
 
+WebKit::WebRTCPeerConnectionHandler* RTCPeerConnectionHandlerChromium::toWebRTCPeerConnectionHandler(RTCPeerConnectionHandler* handler)
+{
+    return static_cast<RTCPeerConnectionHandlerChromium*>(handler)->m_webHandler.get();
+}
+
 PassOwnPtr<RTCPeerConnectionHandler> RTCPeerConnectionHandler::create(RTCPeerConnectionHandlerClient* client)
 {
     return adoptPtr(new RTCPeerConnectionHandlerChromium(client));
@@ -64,6 +69,7 @@
     : m_client(client)
 {
     ASSERT(m_client);
+    m_webHandler = adoptPtr(WebKit::Platform::current()->createRTCPeerConnectionHandler(this));
 }
 
 RTCPeerConnectionHandlerChromium::~RTCPeerConnectionHandlerChromium()
@@ -72,8 +78,10 @@
 
 bool RTCPeerConnectionHandlerChromium::initialize(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints)
 {
-    m_webHandler = adoptPtr(WebKit::Platform::current()->createRTCPeerConnectionHandler(this));
-    return m_webHandler ? m_webHandler->initialize(configuration, constraints) : false;
+    if (!m_webHandler)
+        return false;
+
+    return m_webHandler->initialize(configuration, constraints);
 }
 
 void RTCPeerConnectionHandlerChromium::createOffer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)

Modified: trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h (130269 => 130270)


--- trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h	2012-10-03 09:52:19 UTC (rev 130270)
@@ -49,7 +49,7 @@
 
 class RTCPeerConnectionHandlerChromium : public RTCPeerConnectionHandler, public WebKit::WebRTCPeerConnectionHandlerClient {
 public:
-    RTCPeerConnectionHandlerChromium(RTCPeerConnectionHandlerClient*);
+    explicit RTCPeerConnectionHandlerChromium(RTCPeerConnectionHandlerClient*);
     virtual ~RTCPeerConnectionHandlerChromium();
 
     virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
@@ -75,6 +75,8 @@
     virtual void didAddRemoteStream(const WebKit::WebMediaStreamDescriptor&) OVERRIDE;
     virtual void didRemoveRemoteStream(const WebKit::WebMediaStreamDescriptor&) OVERRIDE;
 
+    static WebKit::WebRTCPeerConnectionHandler* toWebRTCPeerConnectionHandler(RTCPeerConnectionHandler*);
+
 private:
     OwnPtr<WebKit::WebRTCPeerConnectionHandler> m_webHandler;
     RTCPeerConnectionHandlerClient* m_client;

Modified: trunk/Source/WebKit/chromium/ChangeLog (130269 => 130270)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-03 09:52:19 UTC (rev 130270)
@@ -1,3 +1,22 @@
+2012-10-03  Tommy Widenflycht  <[email protected]>
+
+        MediaStream API: RTCPeerConnection should send down its handler via the FrameLoaderClient directly after creation.
+        https://bugs.webkit.org/show_bug.cgi?id=98149
+
+        Reviewed by Adam Barth.
+
+        Adding willStartUsingPeerConnectionHandler to the WebFrameClient.
+
+        * public/WebFrameClient.h:
+        (WebKit):
+        (WebFrameClient):
+        (WebKit::WebFrameClient::willStartUsingPeerConnectionHandler):
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit):
+        (WebKit::FrameLoaderClientImpl::dispatchWillStartUsingPeerConnectionHandler):
+        * src/FrameLoaderClientImpl.h:
+        (FrameLoaderClientImpl):
+
 2012-10-03  Peter Kotwicz  <[email protected]>
 
         WebImage::framesFromData should skip corrupted frames

Modified: trunk/Source/WebKit/chromium/public/WebFrameClient.h (130269 => 130270)


--- trunk/Source/WebKit/chromium/public/WebFrameClient.h	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebKit/chromium/public/WebFrameClient.h	2012-10-03 09:52:19 UTC (rev 130270)
@@ -62,6 +62,7 @@
 class WebMediaPlayerClient;
 class WebNode;
 class WebPlugin;
+class WebRTCPeerConnectionHandler;
 class WebSharedWorker;
 class WebSharedWorkerClient;
 class WebSocketStreamHandle;
@@ -398,6 +399,11 @@
     // A WebSocket object is going to open new stream connection.
     virtual void willOpenSocketStream(WebSocketStreamHandle*) { }
 
+    // MediaStream -----------------------------------------------------
+
+    // A new WebRTCPeerConnectionHandler is created.
+    virtual void willStartUsingPeerConnectionHandler(WebFrame*, WebRTCPeerConnectionHandler*) { }
+
     // Messages ------------------------------------------------------
 
     // Notifies the embedder that a postMessage was issued on this frame, and

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp (130269 => 130270)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2012-10-03 09:52:19 UTC (rev 130270)
@@ -57,6 +57,9 @@
 #include "ProgressTracker.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceLoader.h"
+#if ENABLE(MEDIA_STREAM)
+#include "RTCPeerConnectionHandlerChromium.h"
+#endif
 #include "Settings.h"
 #include "SocketStreamHandleInternal.h"
 #include "WebDOMEvent.h"
@@ -1638,4 +1641,12 @@
     m_webFrame->client()->willOpenSocketStream(SocketStreamHandleInternal::toWebSocketStreamHandle(handle));
 }
 
+#if ENABLE(MEDIA_STREAM)
+void FrameLoaderClientImpl::dispatchWillStartUsingPeerConnectionHandler(RTCPeerConnectionHandler* handler)
+{
+    m_webFrame->client()->willStartUsingPeerConnectionHandler(webFrame(), RTCPeerConnectionHandlerChromium::toWebRTCPeerConnectionHandler(handler));
+}
+#endif
+
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h (130269 => 130270)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2012-10-03 09:50:06 UTC (rev 130269)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2012-10-03 09:52:19 UTC (rev 130270)
@@ -220,6 +220,10 @@
 
     virtual void dispatchWillOpenSocketStream(WebCore::SocketStreamHandle*) OVERRIDE;
 
+#if ENABLE(MEDIA_STREAM)
+    virtual void dispatchWillStartUsingPeerConnectionHandler(WebCore::RTCPeerConnectionHandler*) OVERRIDE;
+#endif
+
 private:
     void makeDocumentView();
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to