Changeset 202337 in webkit


Ignore:
Timestamp:
Jun 22, 2016 11:12:46 AM (8 years ago)
Author:
adam.bergkvist@ericsson.com
Message:

WebRTC: Replace RTCPeerConnection custom constructor with a JS built-in constructor
https://bugs.webkit.org/show_bug.cgi?id=158832

Reviewed by Eric Carlson and Youenn Fablet.

Use a JS built-in constructor instead of a custom constructor. This makes it easier to
initialize private fields for functions implemented as JS built-ins. The constructor
behavior is in need of updating, but that is left to a follow-up change [1].

[1] http://webkit.org/b/158936
No change in behavior.

  • CMakeLists.txt:
  • Modules/mediastream/RTCPeerConnection.cpp:

(WebCore::RTCPeerConnection::create):
(WebCore::RTCPeerConnection::RTCPeerConnection):
(WebCore::RTCPeerConnection::~RTCPeerConnection):
(WebCore::RTCPeerConnection::initializeWith):

  • Modules/mediastream/RTCPeerConnection.h:
  • Modules/mediastream/RTCPeerConnection.idl:
  • Modules/mediastream/RTCPeerConnection.js:

(initializeRTCPeerConnection):
Add JS built-in constructor function.

  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSRTCPeerConnectionCustom.cpp: Removed.

(WebCore::constructJSRTCPeerConnection): Deleted.

Location:
trunk/Source/WebCore
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r202168 r202337  
    12021202    bindings/js/JSReadableStreamPrivateConstructors.cpp
    12031203    bindings/js/JSReadableStreamSourceCustom.cpp
    1204     bindings/js/JSRTCPeerConnectionCustom.cpp
    12051204    bindings/js/JSRTCStatsResponseCustom.cpp
    12061205    bindings/js/JSSQLResultSetRowListCustom.cpp
  • trunk/Source/WebCore/ChangeLog

    r202336 r202337  
     12016-06-22  Adam Bergkvist  <adam.bergkvist@ericsson.com>
     2
     3        WebRTC: Replace RTCPeerConnection custom constructor with a JS built-in constructor
     4        https://bugs.webkit.org/show_bug.cgi?id=158832
     5
     6        Reviewed by Eric Carlson and Youenn Fablet.
     7
     8        Use a JS built-in constructor instead of a custom constructor. This makes it easier to
     9        initialize private fields for functions implemented as JS built-ins. The constructor
     10        behavior is in need of updating, but that is left to a follow-up change [1].
     11
     12        [1] http://webkit.org/b/158936
     13        No change in behavior.
     14
     15        * CMakeLists.txt:
     16        * Modules/mediastream/RTCPeerConnection.cpp:
     17        (WebCore::RTCPeerConnection::create):
     18        (WebCore::RTCPeerConnection::RTCPeerConnection):
     19        (WebCore::RTCPeerConnection::~RTCPeerConnection):
     20        (WebCore::RTCPeerConnection::initializeWith):
     21        * Modules/mediastream/RTCPeerConnection.h:
     22        * Modules/mediastream/RTCPeerConnection.idl:
     23        * Modules/mediastream/RTCPeerConnection.js:
     24        (initializeRTCPeerConnection):
     25        Add JS built-in constructor function.
     26        * WebCore.xcodeproj/project.pbxproj:
     27        * bindings/js/JSRTCPeerConnectionCustom.cpp: Removed.
     28        (WebCore::constructJSRTCPeerConnection): Deleted.
     29
    1302016-06-22  Youenn Fablet  <youenn@apple.com>
    231
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp

    r202105 r202337  
    6060using namespace PeerConnectionStates;
    6161
    62 RefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context, const Dictionary& rtcConfiguration, ExceptionCode& ec)
    63 {
    64     RefPtr<RTCConfiguration> configuration = RTCConfiguration::create(rtcConfiguration, ec);
    65     if (ec)
    66         return nullptr;
    67 
    68     RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, WTFMove(configuration), ec));
     62Ref<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context)
     63{
     64    Ref<RTCPeerConnection> peerConnection = adoptRef(*new RTCPeerConnection(context));
    6965    peerConnection->suspendIfNeeded();
    70     if (ec)
    71         return nullptr;
    7266
    7367    return peerConnection;
    7468}
    7569
    76 RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context, RefPtr<RTCConfiguration>&& configuration, ExceptionCode& ec)
     70RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
    7771    : ActiveDOMObject(&context)
    78     , m_signalingState(SignalingState::Stable)
    79     , m_iceGatheringState(IceGatheringState::New)
    80     , m_iceConnectionState(IceConnectionState::New)
    81     , m_configuration(WTFMove(configuration))
    82 {
    83     Document& document = downcast<Document>(context);
    84 
     72    , m_backend(PeerConnectionBackend::create(this))
     73{
     74}
     75
     76RTCPeerConnection::~RTCPeerConnection()
     77{
     78    stop();
     79}
     80
     81void RTCPeerConnection::initializeWith(Document& document, const Dictionary& rtcConfiguration, ExceptionCode& ec)
     82{
    8583    if (!document.frame()) {
    8684        ec = NOT_SUPPORTED_ERR;
     
    8886    }
    8987
    90     m_backend = PeerConnectionBackend::create(this);
    9188    if (!m_backend) {
    9289        ec = NOT_SUPPORTED_ERR;
     
    9491    }
    9592
    96     m_backend->setConfiguration(*m_configuration);
    97 }
    98 
    99 RTCPeerConnection::~RTCPeerConnection()
    100 {
    101     stop();
     93    setConfiguration(rtcConfiguration, ec);
    10294}
    10395
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h

    r202039 r202337  
    6161class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public PeerConnectionBackendClient, public RTCRtpSenderClient, public EventTargetWithInlineData, public ActiveDOMObject {
    6262public:
    63     static RefPtr<RTCPeerConnection> create(ScriptExecutionContext&, const Dictionary& rtcConfiguration, ExceptionCode&);
     63    static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
    6464    ~RTCPeerConnection();
     65
     66    void initializeWith(Document&, const Dictionary&, ExceptionCode&);
    6567
    6668    const Vector<RefPtr<RTCRtpSender>>& getSenders() const { return m_transceiverSet->getSenders(); }
     
    118120
    119121private:
    120     RTCPeerConnection(ScriptExecutionContext&, RefPtr<RTCConfiguration>&&, ExceptionCode&);
     122    RTCPeerConnection(ScriptExecutionContext&);
    121123
    122124    RefPtr<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpTransceiver>&&, const RtpTransceiverInit&);
     
    148150    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) override;
    149151
    150     PeerConnectionStates::SignalingState m_signalingState;
    151     PeerConnectionStates::IceGatheringState m_iceGatheringState;
    152     PeerConnectionStates::IceConnectionState m_iceConnectionState;
     152    PeerConnectionStates::SignalingState m_signalingState { PeerConnectionStates::SignalingState::Stable };
     153    PeerConnectionStates::IceGatheringState m_iceGatheringState { PeerConnectionStates::IceGatheringState::New };
     154    PeerConnectionStates::IceConnectionState m_iceConnectionState { PeerConnectionStates::IceConnectionState::New };
    153155
    154156    std::unique_ptr<RtpTransceiverSet> m_transceiverSet { std::unique_ptr<RtpTransceiverSet>(new RtpTransceiverSet()) };
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl

    r202275 r202337  
    3535    Conditional=WEB_RTC,
    3636    ConstructorCallWith=ScriptExecutionContext,
    37     ConstructorRaisesException,
    38     CustomConstructor(Dictionary rtcConfiguration),
     37    JSBuiltinConstructor,
    3938    InterfaceName=webkitRTCPeerConnection,
    4039] interface RTCPeerConnection : EventTarget {
     40    // Private initializer
     41    [PrivateIdentifier, CallWith=Document, RaisesException] void initializeWith(Dictionary parameters);
     42
    4143    // RTP Media API extensions
    4244    sequence<RTCRtpSender> getSenders();
  • trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.js

    r202130 r202337  
    3131// @conditional=ENABLE(WEB_RTC)
    3232
     33function initializeRTCPeerConnection(configuration)
     34{
     35    "use strict";
     36
     37    if (arguments.length < 1)
     38        throw new @TypeError("Not enough arguments");
     39
     40    if (!@isObject(configuration))
     41        throw new @TypeError("RTCPeerConnection argument must be a valid Dictionary");
     42
     43    // FIXME: Handle errors in a better way than catching and re-throwing (http://webkit.org/b/158936)
     44    try {
     45        this.@initializeWith(configuration);
     46    } catch (e) {
     47        const message = e.name === "TypeMismatchError" ? "Invalid RTCPeerConnection constructor arguments"
     48            : "Error creating RTCPeerConnection";
     49        throw new @TypeError(message);
     50    }
     51    return this;
     52}
     53
    3354function createOffer()
    3455{
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r202311 r202337  
    306306                07C59B6917F784BA000FBCBB /* MediaSourceSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 07C59B6617F784BA000FBCBB /* MediaSourceSettings.h */; };
    307307                07C59B6E17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07C59B6D17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp */; };
    308                 07CA120E182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */; };
    309308                07CE77D516712A6A00C55A47 /* InbandTextTrackPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    310309                07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */; };
     
    77687767                07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVFoundationMIMETypeCache.mm; sourceTree = "<group>"; };
    77697768                07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationMIMETypeCache.h; sourceTree = "<group>"; };
    7770                 07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCPeerConnectionCustom.cpp; sourceTree = "<group>"; };
    77717769                07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateClient.h; sourceTree = "<group>"; };
    77727770                07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProviderAVFObjC.h; sourceTree = "<group>"; };
     
    2273222730                                FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */,
    2273322731                                A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
    22734                                 07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */,
    2273522732                                07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */,
    2273622733                                51DCE8010CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp */,
     
    3085130848                                073794EB19EE341E00E5A045 /* JSRTCIceServer.cpp in Sources */,
    3085230849                                07969DB917D14151007FF842 /* JSRTCPeerConnection.cpp in Sources */,
    30853                                 07CA120E182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp in Sources */,
    3085430850                                5E2C43711BCF0D750001E2BC /* JSRTCRtpReceiver.cpp in Sources */,
    3085530851                                5E2C43731BCF0D750001E2BC /* JSRTCRtpSender.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.