Introduce a minimal RTCPeerConnection together with Dictionary changes
authortommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 11:59:37 +0000 (11:59 +0000)
committertommyw@google.com <tommyw@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jul 2012 11:59:37 +0000 (11:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92380

Reviewed by Kentaro Hara.

Source/WebCore:

This patch introduces a shell RTCPeerConnection together with neccecary changes to
Dictionary.

The W3C specification can be found here:
http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcpeerconnection

Since Dictionaries can't be fully copied around adding
get(const String& name, Vector<Dictionary>& result)
isn't feasible so I have added a new ArrayValue class.

Test: fast/mediastream/RTCPeerConnection.html

* CMakeLists.txt:
* GNUmakefile.list.am:
* Modules/mediastream/DOMWindowMediaStream.idl:
* Modules/mediastream/RTCPeerConnection.cpp: Added.
(WebCore):
(RTCIceServer):
(WebCore::RTCIceServer::create):
(WebCore::RTCIceServer::~RTCIceServer):
(WebCore::RTCIceServer::uri):
(WebCore::RTCIceServer::credential):
(WebCore::RTCIceServer::RTCIceServer):
(RTCConfiguration):
(WebCore::RTCConfiguration::create):
(WebCore::RTCConfiguration::~RTCConfiguration):
(WebCore::RTCConfiguration::appendServer):
(WebCore::RTCConfiguration::numberOfServers):
(WebCore::RTCConfiguration::server):
(WebCore::RTCConfiguration::RTCConfiguration):
(WebCore::RTCPeerConnection::parseConfiguration):
(WebCore::RTCPeerConnection::create):
(WebCore::RTCPeerConnection::RTCPeerConnection):
(WebCore::RTCPeerConnection::~RTCPeerConnection):
(WebCore::RTCPeerConnection::interfaceName):
(WebCore::RTCPeerConnection::scriptExecutionContext):
(WebCore::RTCPeerConnection::stop):
(WebCore::RTCPeerConnection::eventTargetData):
(WebCore::RTCPeerConnection::ensureEventTargetData):
* Modules/mediastream/RTCPeerConnection.h: Added.
(WebCore):
(RTCPeerConnection):
(WebCore::RTCPeerConnection::refEventTarget):
(WebCore::RTCPeerConnection::derefEventTarget):
* Modules/mediastream/RTCPeerConnection.idl: Added.
* Target.pri:
* UseJSC.cmake:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/generic/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::webkitRTCPeerConnectionEnabled):
* bindings/js/ArrayValue.cpp: Added.
(WebCore):
(WebCore::ArrayValue::ArrayValue):
(WebCore::ArrayValue::operator=):
(WebCore::ArrayValue::isUndefinedOrNull):
(WebCore::ArrayValue::length):
(WebCore::ArrayValue::get):
* bindings/js/ArrayValue.h: Added.
(WebCore):
(ArrayValue):
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSDictionary.cpp:
(WebCore::JSDictionary::convertValue):
(WebCore):
* bindings/js/JSDictionary.h:
(WebCore):
* bindings/v8/ArrayValue.cpp: Added.
(WebCore):
(WebCore::ArrayValue::operator=):
(WebCore::ArrayValue::isUndefinedOrNull):
(WebCore::ArrayValue::length):
(WebCore::ArrayValue::get):
* bindings/v8/ArrayValue.h: Added.
(WebCore):
(ArrayValue):
(WebCore::ArrayValue::ArrayValue):
(WebCore::ArrayValue::~ArrayValue):
* bindings/v8/Dictionary.cpp:
(WebCore::Dictionary::get):
(WebCore):
* bindings/v8/Dictionary.h:
(WebCore):
(Dictionary):
* dom/EventTargetFactory.in:

LayoutTests:

* fast/mediastream/RTCPeerConnection-expected.txt: Added.
* fast/mediastream/RTCPeerConnection.html: Added.

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

26 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/RTCPeerConnection.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/mediastream/DOMWindowMediaStream.idl
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediastream/RTCPeerConnection.h [new file with mode: 0644]
Source/WebCore/Modules/mediastream/RTCPeerConnection.idl [new file with mode: 0644]
Source/WebCore/Target.pri
Source/WebCore/UseJSC.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h
Source/WebCore/bindings/js/ArrayValue.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/ArrayValue.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDictionary.cpp
Source/WebCore/bindings/js/JSDictionary.h
Source/WebCore/bindings/v8/ArrayValue.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/ArrayValue.h [new file with mode: 0644]
Source/WebCore/bindings/v8/Dictionary.cpp
Source/WebCore/bindings/v8/Dictionary.h
Source/WebCore/dom/EventTargetFactory.in

index ef14976..1684f5c 100644 (file)
@@ -1,3 +1,13 @@
+2012-07-31  Tommy Widenflycht  <tommyw@google.com>
+
+        Introduce a minimal RTCPeerConnection together with Dictionary changes
+        https://bugs.webkit.org/show_bug.cgi?id=92380
+
+        Reviewed by Kentaro Hara.
+
+        * fast/mediastream/RTCPeerConnection-expected.txt: Added.
+        * fast/mediastream/RTCPeerConnection.html: Added.
+
 2012-07-31  J├ínos Badics  <jbadics@inf.u-szeged.hu>
 
         [Qt][EFL] New inspector/styles/region-style-crash.html introduced in r124186 fails
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt b/LayoutTests/fast/mediastream/RTCPeerConnection-expected.txt
new file mode 100644 (file)
index 0000000..cf1bbb5
--- /dev/null
@@ -0,0 +1,25 @@
+Tests the RTCPeerConnection constructor.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new webkitRTCPeerConnection(null); did not throw exception.
+PASS new webkitRTCPeerConnection(null, null); did not throw exception.
+PASS new webkitRTCPeerConnection(undefined); did not throw exception.
+PASS new webkitRTCPeerConnection(undefined, undefined); did not throw exception.
+PASS new webkitRTCPeerConnection({iceServers:[]}, null); did not throw exception.
+PASS new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null); did not throw exception.
+PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null); did not throw exception.
+PASS new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null); did not throw exception.
+PASS new webkitRTCPeerConnection(); threw exception TypeError: Not enough arguments.
+PASS new webkitRTCPeerConnection(''); threw exception TypeError: Not an object..
+PASS new webkitRTCPeerConnection(null, ''); threw exception TypeError: Not an object..
+PASS new webkitRTCPeerConnection({fooServers:[]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS new webkitRTCPeerConnection({iceServers:true}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS new webkitRTCPeerConnection({iceServers:[{}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null); threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/RTCPeerConnection.html b/LayoutTests/fast/mediastream/RTCPeerConnection.html
new file mode 100644 (file)
index 0000000..0f29e6b
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests the RTCPeerConnection constructor.");
+
+shouldNotThrow("new webkitRTCPeerConnection(null);");
+shouldNotThrow("new webkitRTCPeerConnection(null, null);");
+shouldNotThrow("new webkitRTCPeerConnection(undefined);");
+shouldNotThrow("new webkitRTCPeerConnection(undefined, undefined);");
+shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]}, null);");
+shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'stun:foo.com'}]}, null);");
+shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'}]}, null);");
+shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{uri:'turn:foo.com', credential:'x'},{uri:'stun:bar.com'}]}, null);");
+
+shouldThrow("new webkitRTCPeerConnection();");
+shouldThrow("new webkitRTCPeerConnection('');");
+shouldThrow("new webkitRTCPeerConnection(null, '');");
+shouldThrow("new webkitRTCPeerConnection({fooServers:[]}, null);");
+shouldThrow("new webkitRTCPeerConnection({iceServers:true}, null);");
+shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]}, null);");
+shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]}, null);");
+shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]}, null);");
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 6756bd5..53610df 100644 (file)
@@ -206,6 +206,7 @@ SET(WebCore_IDL_FILES
     Modules/mediastream/NavigatorUserMediaErrorCallback.idl
     Modules/mediastream/NavigatorUserMediaSuccessCallback.idl
     Modules/mediastream/PeerConnection00.idl
+    Modules/mediastream/RTCPeerConnection.idl
     Modules/mediastream/SessionDescription.idl
 
     Modules/networkinfo/NavigatorNetworkInfoConnection.idl
@@ -825,6 +826,7 @@ SET(WebCore_SOURCES
     Modules/mediastream/MediaStreamTrackList.cpp
     Modules/mediastream/NavigatorMediaStream.cpp
     Modules/mediastream/PeerConnection00.cpp
+    Modules/mediastream/RTCPeerConnection.cpp
     Modules/mediastream/SessionDescription.cpp
     Modules/mediastream/UserMediaController.cpp
     Modules/mediastream/UserMediaRequest.cpp
index 0ce218b..c1fe1a9 100644 (file)
@@ -1,3 +1,97 @@
+2012-07-31  Tommy Widenflycht  <tommyw@google.com>
+
+        Introduce a minimal RTCPeerConnection together with Dictionary changes
+        https://bugs.webkit.org/show_bug.cgi?id=92380
+
+        Reviewed by Kentaro Hara.
+
+        This patch introduces a shell RTCPeerConnection together with neccecary changes to
+        Dictionary.
+
+        The W3C specification can be found here:
+        http://dev.w3.org/2011/webrtc/editor/webrtc.html#rtcpeerconnection
+
+        Since Dictionaries can't be fully copied around adding
+        get(const String& name, Vector<Dictionary>& result)
+        isn't feasible so I have added a new ArrayValue class.
+
+        Test: fast/mediastream/RTCPeerConnection.html
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Modules/mediastream/DOMWindowMediaStream.idl:
+        * Modules/mediastream/RTCPeerConnection.cpp: Added.
+        (WebCore):
+        (RTCIceServer):
+        (WebCore::RTCIceServer::create):
+        (WebCore::RTCIceServer::~RTCIceServer):
+        (WebCore::RTCIceServer::uri):
+        (WebCore::RTCIceServer::credential):
+        (WebCore::RTCIceServer::RTCIceServer):
+        (RTCConfiguration):
+        (WebCore::RTCConfiguration::create):
+        (WebCore::RTCConfiguration::~RTCConfiguration):
+        (WebCore::RTCConfiguration::appendServer):
+        (WebCore::RTCConfiguration::numberOfServers):
+        (WebCore::RTCConfiguration::server):
+        (WebCore::RTCConfiguration::RTCConfiguration):
+        (WebCore::RTCPeerConnection::parseConfiguration):
+        (WebCore::RTCPeerConnection::create):
+        (WebCore::RTCPeerConnection::RTCPeerConnection):
+        (WebCore::RTCPeerConnection::~RTCPeerConnection):
+        (WebCore::RTCPeerConnection::interfaceName):
+        (WebCore::RTCPeerConnection::scriptExecutionContext):
+        (WebCore::RTCPeerConnection::stop):
+        (WebCore::RTCPeerConnection::eventTargetData):
+        (WebCore::RTCPeerConnection::ensureEventTargetData):
+        * Modules/mediastream/RTCPeerConnection.h: Added.
+        (WebCore):
+        (RTCPeerConnection):
+        (WebCore::RTCPeerConnection::refEventTarget):
+        (WebCore::RTCPeerConnection::derefEventTarget):
+        * Modules/mediastream/RTCPeerConnection.idl: Added.
+        * Target.pri:
+        * UseJSC.cmake:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/generic/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::webkitRTCPeerConnectionEnabled):
+        * bindings/js/ArrayValue.cpp: Added.
+        (WebCore):
+        (WebCore::ArrayValue::ArrayValue):
+        (WebCore::ArrayValue::operator=):
+        (WebCore::ArrayValue::isUndefinedOrNull):
+        (WebCore::ArrayValue::length):
+        (WebCore::ArrayValue::get):
+        * bindings/js/ArrayValue.h: Added.
+        (WebCore):
+        (ArrayValue):
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSDictionary.cpp:
+        (WebCore::JSDictionary::convertValue):
+        (WebCore):
+        * bindings/js/JSDictionary.h:
+        (WebCore):
+        * bindings/v8/ArrayValue.cpp: Added.
+        (WebCore):
+        (WebCore::ArrayValue::operator=):
+        (WebCore::ArrayValue::isUndefinedOrNull):
+        (WebCore::ArrayValue::length):
+        (WebCore::ArrayValue::get):
+        * bindings/v8/ArrayValue.h: Added.
+        (WebCore):
+        (ArrayValue):
+        (WebCore::ArrayValue::ArrayValue):
+        (WebCore::ArrayValue::~ArrayValue):
+        * bindings/v8/Dictionary.cpp:
+        (WebCore::Dictionary::get):
+        (WebCore):
+        * bindings/v8/Dictionary.h:
+        (WebCore):
+        (Dictionary):
+        * dom/EventTargetFactory.in:
+
 2012-07-31  Raul Hudea  <rhudea@adobe.com>
 
         Inspector crashes when trying to inspect a page with CSS region styling
index f48d7d7..55679a3 100644 (file)
@@ -491,6 +491,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSRect.h \
        DerivedSources/WebCore/JSRGBColor.cpp \
        DerivedSources/WebCore/JSRGBColor.h \
+       DerivedSources/WebCore/JSRTCPeerConnection.cpp \
+       DerivedSources/WebCore/JSRTCPeerConnection.h \
        DerivedSources/WebCore/JSScreen.cpp \
        DerivedSources/WebCore/JSScreen.h \
        DerivedSources/WebCore/JSScriptProfile.cpp \
@@ -715,6 +717,7 @@ dom_binding_idls += \
        $(WebCore)/Modules/mediastream/NavigatorUserMediaErrorCallback.idl \
        $(WebCore)/Modules/mediastream/NavigatorUserMediaSuccessCallback.idl \
        $(WebCore)/Modules/mediastream/PeerConnection00.idl \
+       $(WebCore)/Modules/mediastream/RTCPeerConnection.idl \
        $(WebCore)/Modules/mediastream/SessionDescription.idl \
        $(WebCore)/Modules/notifications/Notification.idl \
        $(WebCore)/Modules/notifications/NotificationCenter.idl \
@@ -1199,6 +1202,8 @@ webcore_modules_sources += \
        Source/WebCore/Modules/mediastream/NavigatorUserMediaSuccessCallback.h \
        Source/WebCore/Modules/mediastream/PeerConnection00.cpp \
        Source/WebCore/Modules/mediastream/PeerConnection00.h \
+       Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp \
+       Source/WebCore/Modules/mediastream/RTCPeerConnection.h \
        Source/WebCore/Modules/mediastream/SessionDescription.cpp \
        Source/WebCore/Modules/mediastream/SessionDescription.h \
        Source/WebCore/Modules/mediastream/UserMediaClient.h \
@@ -1364,6 +1369,8 @@ webcore_sources += \
        Source/WebCore/bindings/generic/GenericBinding.h \
        Source/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp \
        Source/WebCore/bindings/generic/RuntimeEnabledFeatures.h \
+       Source/WebCore/bindings/js/ArrayValue.cpp \
+       Source/WebCore/bindings/js/ArrayValue.h \
        Source/WebCore/bindings/js/CachedScriptSourceProvider.h \
        Source/WebCore/bindings/js/CallbackFunction.cpp \
        Source/WebCore/bindings/js/CallbackFunction.h \
index 742a624..ea946a4 100644 (file)
@@ -32,6 +32,7 @@ module window {
     ] DOMWindowMediaStream {
         attribute [V8EnabledAtRuntime] MediaStreamConstructor webkitMediaStream;
         attribute [V8EnabledAtRuntime] PeerConnection00Constructor webkitPeerConnection00;
+        attribute [V8EnabledAtRuntime] RTCPeerConnectionConstructor webkitRTCPeerConnection;
         attribute SessionDescriptionConstructor SessionDescription;
         attribute IceCandidateConstructor IceCandidate;
         attribute MediaStreamEventConstructor MediaStreamEvent;
diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp b/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
new file mode 100644 (file)
index 0000000..84c0709
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "RTCPeerConnection.h"
+
+#include "ArrayValue.h"
+#include "ExceptionCode.h"
+#include "KURL.h"
+#include "ScriptExecutionContext.h"
+
+namespace WebCore {
+
+// FIXME: RTCIceServer and RTCConfigration are placed here temporarily.
+// Their final place is in Source/WebCore/platform/mediastream.
+class RTCIceServer : public RefCounted<RTCIceServer> {
+public:
+    static PassRefPtr<RTCIceServer> create(const KURL& uri, const String& credential) { return adoptRef(new RTCIceServer(uri, credential)); }
+    virtual ~RTCIceServer() { }
+
+    const KURL& uri() { return m_uri; }
+    const String& credential() { return m_credential; }
+
+private:
+    RTCIceServer(const KURL& uri, const String& credential)
+        : m_uri(uri)
+        , m_credential(credential)
+    {
+    }
+
+    KURL m_uri;
+    String m_credential;
+};
+
+class RTCConfiguration : public RefCounted<RTCConfiguration> {
+public:
+    static PassRefPtr<RTCConfiguration> create() { return adoptRef(new RTCConfiguration()); }
+    virtual ~RTCConfiguration() { }
+
+    void appendServer(PassRefPtr<RTCIceServer> server) { m_servers.append(server); }
+    size_t numberOfServers() { return m_servers.size(); }
+    RTCIceServer* server(size_t index) { return m_servers[index].get(); }
+
+private:
+    RTCConfiguration() { }
+
+    Vector<RefPtr<RTCIceServer> > m_servers;
+};
+
+PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionCode& ec)
+{
+    if (configuration.isUndefinedOrNull())
+        return 0;
+
+    ArrayValue iceServers;
+    bool ok = configuration.get("iceServers", iceServers);
+    if (!ok || iceServers.isUndefinedOrNull()) {
+        ec = TYPE_MISMATCH_ERR;
+        return 0;
+    }
+
+    size_t numberOfServers;
+    ok = iceServers.length(numberOfServers);
+    if (!ok) {
+        ec = TYPE_MISMATCH_ERR;
+        return 0;
+    }
+
+    RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();
+
+    for (size_t i = 0; i < numberOfServers; ++i) {
+        Dictionary iceServer;
+        ok = iceServers.get(i, iceServer);
+        if (!ok) {
+            ec = TYPE_MISMATCH_ERR;
+            return 0;
+        }
+
+        String uri, credential;
+        ok = iceServer.get("uri", uri);
+        if (!ok) {
+            ec = TYPE_MISMATCH_ERR;
+            return 0;
+        }
+        KURL url(KURL(), uri);
+        if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun"))) {
+            ec = TYPE_MISMATCH_ERR;
+            return 0;
+        }
+
+        iceServer.get("credential", credential);
+
+        rtcConfiguration->appendServer(RTCIceServer::create(url, credential));
+    }
+    return rtcConfiguration.release();
+}
+
+PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary&, ExceptionCode& ec)
+{
+    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
+    if (ec)
+        return 0;
+
+    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), ec));
+    if (ec)
+        return 0;
+
+    peerConnection->suspendIfNeeded();
+    return peerConnection.release();
+}
+
+RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext* context, PassRefPtr<RTCConfiguration>, ExceptionCode& ec)
+    : ActiveDOMObject(context, this)
+{
+}
+
+RTCPeerConnection::~RTCPeerConnection()
+{
+}
+
+const AtomicString& RTCPeerConnection::interfaceName() const
+{
+    return eventNames().interfaceForRTCPeerConnection;
+}
+
+ScriptExecutionContext* RTCPeerConnection::scriptExecutionContext() const
+{
+    return ActiveDOMObject::scriptExecutionContext();
+}
+
+void RTCPeerConnection::stop()
+{
+    // FIXME: Make sure that this object stops posting events and releases resources at this stage.
+}
+
+EventTargetData* RTCPeerConnection::eventTargetData()
+{
+    return &m_eventTargetData;
+}
+
+EventTargetData* RTCPeerConnection::ensureEventTargetData()
+{
+    return &m_eventTargetData;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.h b/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
new file mode 100644 (file)
index 0000000..a7f28d1
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef RTCPeerConnection_h
+#define RTCPeerConnection_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "ActiveDOMObject.h"
+#include "Dictionary.h"
+#include "EventTarget.h"
+#include "ExceptionBase.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+class RTCConfiguration;
+
+class RTCPeerConnection : public RefCounted<RTCPeerConnection>, public EventTarget, public ActiveDOMObject {
+public:
+    static PassRefPtr<RTCPeerConnection> create(ScriptExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode&);
+    ~RTCPeerConnection();
+
+    // EventTarget
+    virtual const AtomicString& interfaceName() const OVERRIDE;
+    virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE;
+
+    // ActiveDOMObject
+    virtual void stop() OVERRIDE;
+
+    using RefCounted<RTCPeerConnection>::ref;
+    using RefCounted<RTCPeerConnection>::deref;
+
+private:
+    RTCPeerConnection(ScriptExecutionContext*, PassRefPtr<RTCConfiguration>, ExceptionCode&);
+
+    static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionCode&);
+
+    // EventTarget implementation.
+    virtual EventTargetData* eventTargetData();
+    virtual EventTargetData* ensureEventTargetData();
+    virtual void refEventTarget() { ref(); }
+    virtual void derefEventTarget() { deref(); }
+    EventTargetData m_eventTargetData;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // RTCPeerConnection_h
diff --git a/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl b/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl
new file mode 100644 (file)
index 0000000..44ad723
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer
+ *    in the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this
+ *    software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+module mediastream {
+
+    interface [
+        Conditional=MEDIA_STREAM,
+        ActiveDOMObject,
+        Constructor(in Dictionary rtcICEServers, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints),
+        ConstructorRaisesException,
+        CallWith=ScriptExecutionContext,
+        EventTarget
+    ] RTCPeerConnection {
+        // EventTarget interface
+        void addEventListener(in DOMString type,
+                              in EventListener listener,
+                              in [Optional] boolean useCapture);
+        void removeEventListener(in DOMString type,
+                                 in EventListener listener,
+                                 in [Optional] boolean useCapture);
+        boolean dispatchEvent(in Event event)
+            raises(EventException);
+    };
+
+}
index d15c883..984378f 100644 (file)
@@ -73,6 +73,7 @@ SOURCES += \
 
 SOURCES += \
      bindings/ScriptControllerBase.cpp \
+     bindings/js/ArrayValue.cpp \
      bindings/js/CallbackFunction.cpp \
      bindings/js/DOMObjectHashTableMap.cpp \
      bindings/js/DOMWrapperWorld.cpp \
index 00f1be1..95895ed 100644 (file)
@@ -22,6 +22,7 @@ IF (PORT MATCHES "BlackBerry")
 ENDIF ()
 
 LIST(APPEND WebCore_SOURCES
+    bindings/js/ArrayValue.cpp
     bindings/js/CallbackFunction.cpp
     bindings/js/DOMObjectHashTableMap.cpp
     bindings/js/DOMWrapperWorld.cpp
index 61f78dc..84210cc 100644 (file)
             'Modules/mediastream/NavigatorUserMediaErrorCallback.idl',
             'Modules/mediastream/NavigatorUserMediaSuccessCallback.idl',
             'Modules/mediastream/PeerConnection00.idl',
+            'Modules/mediastream/RTCPeerConnection.idl',
             'Modules/mediastream/SessionDescription.idl',
             'Modules/notifications/DOMWindowNotifications.idl',
             'Modules/notifications/Notification.idl',
             'Modules/mediastream/NavigatorUserMediaSuccessCallback.h',
             'Modules/mediastream/PeerConnection00.cpp',
             'Modules/mediastream/PeerConnection00.h',
+            'Modules/mediastream/RTCPeerConnection.cpp',
+            'Modules/mediastream/RTCPeerConnection.h',
             'Modules/mediastream/SessionDescription.cpp',
             'Modules/mediastream/SessionDescription.h',
             'Modules/mediastream/UserMediaClient.h',
             'bindings/gobject/WebKitDOMObject.h',
             'bindings/gobject/WebKitHTMLElementWrapperFactory.cpp',
             'bindings/gobject/WebKitHTMLElementWrapperFactory.h',
+            'bindings/js/ArrayValue.cpp',
+            'bindings/js/ArrayValue.h',
             'bindings/js/CachedScriptSourceProvider.h',
             'bindings/js/CallbackFunction.cpp',
             'bindings/js/CallbackFunction.h',
             'bindings/objc/ObjCNodeFilterCondition.mm',
             'bindings/objc/PublicDOMInterfaces.h',
             'bindings/objc/WebScriptObject.mm',
+            'bindings/v8/ArrayValue.cpp',
+            'bindings/v8/ArrayValue.h',
             'bindings/v8/DOMData.cpp',
             'bindings/v8/DOMData.h',
             'bindings/v8/DOMDataStore.cpp',
index e82b5c8..3e1d0b5 100755 (executable)
                        <Filter
                                Name="js"
                                >
+                                <File
+                                        RelativePath="..\bindings\js\ArrayValue.cpp"
+                                       >
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_All|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Production|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                        RelativePath="..\bindings\js\ArrayValue.h"
+                                       >
+                               </File>
                                <File
                                        RelativePath="..\bindings\js\CachedScriptSourceProvider.h"
                                        >
index 30d62c8..49ed6ca 100644 (file)
                49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AE2D95134EE5F90072920A /* CalculationValue.h */; };
                49AF2D6914435D050016A784 /* DisplayRefreshMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */; };
                49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */; };
+               49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49B3760A15C6C6840059131D /* ArrayValue.cpp */; };
+               49B3760D15C6C6840059131D /* ArrayValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 49B3760B15C6C6840059131D /* ArrayValue.h */; };
                49C7B9931042D2D30009D447 /* JSWebGLBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */; };
                49C7B9941042D2D30009D447 /* JSWebGLBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */; };
                49C7B9951042D2D30009D447 /* JSInt8Array.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49C7B9821042D2D30009D447 /* JSInt8Array.cpp */; };
                49AE2D95134EE5F90072920A /* CalculationValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CalculationValue.h; sourceTree = "<group>"; };
                49AF2D6814435D050016A784 /* DisplayRefreshMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayRefreshMonitor.h; sourceTree = "<group>"; };
                49AF2D6B14435D210016A784 /* DisplayRefreshMonitorMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayRefreshMonitorMac.cpp; sourceTree = "<group>"; };
+               49B3760A15C6C6840059131D /* ArrayValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ArrayValue.cpp; sourceTree = "<group>"; };
+               49B3760B15C6C6840059131D /* ArrayValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArrayValue.h; sourceTree = "<group>"; };
                49C7B9801042D2D30009D447 /* JSWebGLBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLBuffer.cpp; sourceTree = "<group>"; };
                49C7B9811042D2D30009D447 /* JSWebGLBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLBuffer.h; sourceTree = "<group>"; };
                49C7B9821042D2D30009D447 /* JSInt8Array.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInt8Array.cpp; sourceTree = "<group>"; };
                                BCCE58B41061E925008FB35A /* Constructors */,
                                BC4EDEF70C08F414007EDD49 /* Custom */,
                                14DFB33F0A7DF7630018F769 /* Derived Sources */,
+                               49B3760A15C6C6840059131D /* ArrayValue.cpp */,
+                               49B3760B15C6C6840059131D /* ArrayValue.h */,
                                BCD533630ED6848900887468 /* CachedScriptSourceProvider.h */,
                                93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */,
                                312D67B01535691F00563D0D /* Dictionary.cpp */,
                                1059457A15B42A43004D37FD /* JSMicroDataItemValue.h in Headers */,
                                1059459915B42AA0004D37FD /* PropertyNodeList.h in Headers */,
                                1059459F15B42B1A004D37FD /* JSPropertyNodeList.h in Headers */,
+                               49B3760D15C6C6840059131D /* ArrayValue.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1059459715B42A8E004D37FD /* PropertyNodeList.cpp in Sources */,
                                1059459D15B42B0C004D37FD /* JSPropertyNodeList.cpp in Sources */,
                                CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */,
+                               49B3760C15C6C6840059131D /* ArrayValue.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index d0ee26c..c68c3a8 100644 (file)
@@ -188,6 +188,7 @@ public:
     static bool peerConnectionEnabled() { return isMediaStreamEnabled && isPeerConnectionEnabled; }
     static void setPeerConnectionEnabled(bool isEnabled) { isPeerConnectionEnabled = isEnabled; }
     static bool webkitPeerConnection00Enabled() { return peerConnectionEnabled(); }
+    static bool webkitRTCPeerConnectionEnabled() { return peerConnectionEnabled(); }
 #endif
 
 #if ENABLE(GAMEPAD)
diff --git a/Source/WebCore/bindings/js/ArrayValue.cpp b/Source/WebCore/bindings/js/ArrayValue.cpp
new file mode 100644 (file)
index 0000000..afa53bf
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ArrayValue.h"
+
+#include "Dictionary.h"
+#include <runtime/JSArray.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+ArrayValue::ArrayValue()
+    : m_exec(0)
+{
+}
+
+ArrayValue::ArrayValue(JSC::ExecState* exec, JSC::JSValue value)
+    : m_exec(exec)
+{
+    if (!value.isUndefinedOrNull() && isJSArray(value))
+        m_value = value;
+}
+
+ArrayValue& ArrayValue::operator=(const ArrayValue& other)
+{
+    m_exec = other.m_exec;
+    m_value = other.m_value;
+    return *this;
+}
+
+bool ArrayValue::isUndefinedOrNull() const
+{
+    return m_value.isEmpty() || m_value.isUndefinedOrNull();
+}
+
+bool ArrayValue::length(size_t& length) const
+{
+    if (isUndefinedOrNull())
+        return false;
+
+    JSArray* array = asArray(m_value);
+    length = array->length();
+    return true;
+}
+
+bool ArrayValue::get(size_t index, Dictionary& value) const
+{
+    if (isUndefinedOrNull())
+        return false;
+
+    JSArray* array = asArray(m_value);
+    if (!array->canGetIndex(index))
+        return false;
+
+    JSValue indexedValue = array->getIndex(index);
+    if (indexedValue.isUndefinedOrNull() || !indexedValue.isObject())
+        return false;
+
+    value = Dictionary(m_exec, indexedValue);
+    return true;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/js/ArrayValue.h b/Source/WebCore/bindings/js/ArrayValue.h
new file mode 100644 (file)
index 0000000..084f8c3
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ArrayValue_h
+#define ArrayValue_h
+
+#include <interpreter/CallFrame.h>
+
+namespace WebCore {
+
+class Dictionary;
+
+class ArrayValue {
+public:
+    ArrayValue();
+    ArrayValue(JSC::ExecState*, JSC::JSValue);
+
+    ArrayValue& operator=(const ArrayValue&);
+
+    bool isUndefinedOrNull() const;
+
+    bool length(size_t&) const;
+    bool get(size_t index, Dictionary&) const;
+
+private:
+    JSC::ExecState* m_exec;
+    JSC::JSValue m_value;
+};
+
+}
+
+#endif // ArrayValue_h
index 59b9fe6..cf1f42b 100644 (file)
@@ -25,6 +25,7 @@
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
 
+#include "ArrayValue.cpp"
 #include "CallbackFunction.cpp"
 #include "DOMObjectHashTableMap.cpp"
 #include "DOMWrapperWorld.cpp"
index 1f39882..d88d535 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "JSDictionary.h"
 
+#include "ArrayValue.h"
 #include "Dictionary.h"
 #include "JSDOMWindow.h"
 #include "JSEventTarget.h"
@@ -33,8 +34,8 @@
 #include "JSNode.h"
 #include "JSStorage.h"
 #include "JSTrackCustom.h"
-#include "SerializedScriptValue.h"
 #include "ScriptValue.h"
+#include "SerializedScriptValue.h"
 #include <wtf/HashMap.h>
 #include <wtf/MathExtras.h>
 #include <wtf/text/AtomicString.h>
@@ -185,6 +186,14 @@ void JSDictionary::convertValue(ExecState* exec, JSValue value, HashSet<AtomicSt
 }
 #endif
 
+void JSDictionary::convertValue(ExecState* exec, JSValue value, ArrayValue& result)
+{
+    if (value.isUndefinedOrNull())
+        return;
+
+    result = ArrayValue(exec, value);
+}
+
 bool JSDictionary::getWithUndefinedOrNullCheck(const String& propertyName, String& result) const
 {
     JSValue value;
index 3e7ee55..717b588 100644 (file)
@@ -32,6 +32,7 @@
 
 namespace WebCore {
 
+class ArrayValue;
 class Dictionary;
 class DOMWindow;
 class EventTarget;
@@ -105,6 +106,7 @@ private:
 #if ENABLE(MUTATION_OBSERVERS) || ENABLE(WEB_INTENTS)
     static void convertValue(JSC::ExecState*, JSC::JSValue, HashSet<AtomicString>& result);
 #endif
+    static void convertValue(JSC::ExecState*, JSC::JSValue, ArrayValue& result);
 
     JSC::ExecState* m_exec;
     JSC::JSObject* m_initializerObject;
diff --git a/Source/WebCore/bindings/v8/ArrayValue.cpp b/Source/WebCore/bindings/v8/ArrayValue.cpp
new file mode 100644 (file)
index 0000000..f990078
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ArrayValue.h"
+
+#include "Dictionary.h"
+#include "V8Binding.h"
+
+namespace WebCore {
+
+ArrayValue& ArrayValue::operator=(const ArrayValue& other)
+{
+    m_array = other.m_array;
+    return *this;
+}
+
+bool ArrayValue::isUndefinedOrNull() const
+{
+    return m_array.IsEmpty() || WebCore::isUndefinedOrNull(m_array);
+}
+
+bool ArrayValue::length(size_t& length) const
+{
+    if (isUndefinedOrNull())
+        return false;
+
+    length = m_array->Length();
+    return true;
+}
+
+bool ArrayValue::get(size_t index, Dictionary& value) const
+{
+    if (isUndefinedOrNull())
+        return false;
+
+    if (index >= m_array->Length())
+        return false;
+
+    v8::Local<v8::Value> indexedValue = m_array->Get(v8UnsignedInteger(index));
+    if (indexedValue.IsEmpty() || !indexedValue->IsObject())
+        return false;
+
+    value = Dictionary(indexedValue);
+    return true;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/ArrayValue.h b/Source/WebCore/bindings/v8/ArrayValue.h
new file mode 100644 (file)
index 0000000..be01541
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ArrayValue_h
+#define ArrayValue_h
+
+#include <v8.h>
+
+namespace WebCore {
+
+class Dictionary;
+
+class ArrayValue {
+public:
+    ArrayValue() { }
+    explicit ArrayValue(const v8::Local<v8::Array>& array) : m_array(array) { }
+    ~ArrayValue() { }
+
+    ArrayValue& operator=(const ArrayValue&);
+
+    bool isUndefinedOrNull() const;
+
+    bool length(size_t&) const;
+    bool get(size_t index, Dictionary&) const;
+
+private:
+    // This object can only be used safely when stack allocated because of v8::Local.
+    static void* operator new(size_t);
+    static void* operator new[](size_t);
+    static void operator delete(void *);
+
+    v8::Local<v8::Array> m_array;
+};
+
+}
+
+#endif // ArrayValue_h
index 7d692e7..6cf5679 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "Dictionary.h"
 
+#include "ArrayValue.h"
 #include "DOMStringList.h"
 #include "V8Binding.h"
 #include "V8DOMWindow.h"
@@ -442,6 +443,19 @@ bool Dictionary::get(const String& key, Vector<String>& value) const
     return true;
 }
 
+bool Dictionary::get(const String& key, ArrayValue& value) const
+{
+    v8::Local<v8::Value> v8Value;
+    if (!getKey(key, v8Value))
+        return false;
+
+    if (!v8Value->IsArray())
+        return false;
+
+    value = ArrayValue(v8::Local<v8::Array>::Cast(v8Value));
+    return true;
+}
+
 bool Dictionary::getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>& hashMap) const
 {
     if (!isObject())
index f153ea9..192b31f 100644 (file)
@@ -38,6 +38,7 @@
 
 namespace WebCore {
 
+class ArrayValue;
 class DOMWindow;
 class IDBKeyRange;
 class MediaKeyError;
@@ -86,6 +87,8 @@ public:
     bool get(const String&, HashSet<AtomicString>&) const;
     bool get(const String&, Dictionary&) const;
     bool get(const String&, Vector<String>&) const;
+    bool get(const String&, ArrayValue&) const;
+
     bool getOwnPropertiesAsStringHashMap(WTF::HashMap<String, String>&) const;
 
     bool getWithUndefinedOrNullCheck(const String&, String&) const;
index ff60aad..44e8d8e 100644 (file)
@@ -24,6 +24,7 @@ Node
 Notification conditional=NOTIFICATIONS|LEGACY_NOTIFICATIONS
 PeerConnection00 conditional=MEDIA_STREAM
 Performance conditional=WEB_TIMING
+RTCPeerConnection conditional=MEDIA_STREAM
 SharedWorker conditional=SHARED_WORKERS
 SharedWorkerContext conditional=SHARED_WORKERS
 SourceBufferList conditional=MEDIA_SOURCE