| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/mediastream/RTCSessionDescription.h" | 32 #include "modules/mediastream/RTCSessionDescription.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/Dictionary.h" | 34 #include "bindings/core/v8/Dictionary.h" |
| 35 #include "bindings/core/v8/DictionaryHelper.h" |
| 35 #include "bindings/core/v8/ExceptionState.h" | 36 #include "bindings/core/v8/ExceptionState.h" |
| 36 #include "core/dom/ExceptionCode.h" | 37 #include "core/dom/ExceptionCode.h" |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 static bool verifyType(const String& type) | 41 static bool verifyType(const String& type) |
| 41 { | 42 { |
| 42 return type == "offer" || type == "pranswer" || type == "answer"; | 43 return type == "offer" || type == "pranswer" || type == "answer"; |
| 43 } | 44 } |
| 44 | 45 |
| 45 static String constructIllegalTypeExceptionMessage(const String& type) | 46 static String constructIllegalTypeExceptionMessage(const String& type) |
| 46 { | 47 { |
| 47 return "Illegal value of attribute 'type' : " + type; | 48 return "Illegal value of attribute 'type' : " + type; |
| 48 } | 49 } |
| 49 | 50 |
| 50 RTCSessionDescription* RTCSessionDescription::create(const Dictionary& descripti
onInitDict, ExceptionState& exceptionState) | 51 RTCSessionDescription* RTCSessionDescription::create(const Dictionary& descripti
onInitDict, ExceptionState& exceptionState) |
| 51 { | 52 { |
| 52 String type; | 53 String type; |
| 53 bool ok = descriptionInitDict.get("type", type); | 54 bool ok = DictionaryHelper::get(descriptionInitDict, "type", type); |
| 54 if (ok && !verifyType(type)) { | 55 if (ok && !verifyType(type)) { |
| 55 exceptionState.throwDOMException(TypeMismatchError, constructIllegalType
ExceptionMessage(type)); | 56 exceptionState.throwDOMException(TypeMismatchError, constructIllegalType
ExceptionMessage(type)); |
| 56 return nullptr; | 57 return nullptr; |
| 57 } | 58 } |
| 58 | 59 |
| 59 String sdp; | 60 String sdp; |
| 60 descriptionInitDict.get("sdp", sdp); | 61 DictionaryHelper::get(descriptionInitDict, "sdp", sdp); |
| 61 | 62 |
| 62 return new RTCSessionDescription(blink::WebRTCSessionDescription(type, sdp))
; | 63 return new RTCSessionDescription(blink::WebRTCSessionDescription(type, sdp))
; |
| 63 } | 64 } |
| 64 | 65 |
| 65 RTCSessionDescription* RTCSessionDescription::create(blink::WebRTCSessionDescrip
tion webSessionDescription) | 66 RTCSessionDescription* RTCSessionDescription::create(blink::WebRTCSessionDescrip
tion webSessionDescription) |
| 66 { | 67 { |
| 67 return new RTCSessionDescription(webSessionDescription); | 68 return new RTCSessionDescription(webSessionDescription); |
| 68 } | 69 } |
| 69 | 70 |
| 70 RTCSessionDescription::RTCSessionDescription(blink::WebRTCSessionDescription web
SessionDescription) | 71 RTCSessionDescription::RTCSessionDescription(blink::WebRTCSessionDescription web
SessionDescription) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 { | 96 { |
| 96 m_webSessionDescription.setSDP(sdp); | 97 m_webSessionDescription.setSDP(sdp); |
| 97 } | 98 } |
| 98 | 99 |
| 99 blink::WebRTCSessionDescription RTCSessionDescription::webSessionDescription() | 100 blink::WebRTCSessionDescription RTCSessionDescription::webSessionDescription() |
| 100 { | 101 { |
| 101 return m_webSessionDescription; | 102 return m_webSessionDescription; |
| 102 } | 103 } |
| 103 | 104 |
| 104 } // namespace WebCore | 105 } // namespace WebCore |
| OLD | NEW |