| 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 15 matching lines...) Expand all Loading... |
| 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 | 32 |
| 33 #include "modules/mediastream/RTCSessionDescription.h" | 33 #include "modules/mediastream/RTCSessionDescription.h" |
| 34 | 34 |
| 35 #include "bindings/v8/Dictionary.h" | 35 #include "bindings/v8/Dictionary.h" |
| 36 #include "bindings/v8/ExceptionState.h" | |
| 37 #include "core/dom/ExceptionCode.h" | 36 #include "core/dom/ExceptionCode.h" |
| 38 #include "public/platform/WebRTCSessionDescription.h" | 37 #include "public/platform/WebRTCSessionDescription.h" |
| 39 | 38 |
| 40 namespace WebCore { | 39 namespace WebCore { |
| 41 | 40 |
| 42 static bool verifyType(const String& type) | 41 static bool verifyType(const String& type) |
| 43 { | 42 { |
| 44 return type == "offer" || type == "pranswer" || type == "answer"; | 43 return type == "offer" || type == "pranswer" || type == "answer"; |
| 45 } | 44 } |
| 46 | 45 |
| 47 PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(const Dictionary
& dictionary, ExceptionState& es) | 46 PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(const Dictionary
& dictionary, ExceptionCode& ec) |
| 48 { | 47 { |
| 49 String type; | 48 String type; |
| 50 bool ok = dictionary.get("type", type); | 49 bool ok = dictionary.get("type", type); |
| 51 if (!ok || !verifyType(type)) { | 50 if (!ok || !verifyType(type)) { |
| 52 es.throwDOMException(TypeMismatchError); | 51 ec = TypeMismatchError; |
| 53 return 0; | 52 return 0; |
| 54 } | 53 } |
| 55 | 54 |
| 56 String sdp; | 55 String sdp; |
| 57 ok = dictionary.get("sdp", sdp); | 56 ok = dictionary.get("sdp", sdp); |
| 58 if (!ok || sdp.isEmpty()) { | 57 if (!ok || sdp.isEmpty()) { |
| 59 es.throwDOMException(TypeMismatchError); | 58 ec = TypeMismatchError; |
| 60 return 0; | 59 return 0; |
| 61 } | 60 } |
| 62 | 61 |
| 63 return adoptRef(new RTCSessionDescription(WebKit::WebRTCSessionDescription(t
ype, sdp))); | 62 return adoptRef(new RTCSessionDescription(WebKit::WebRTCSessionDescription(t
ype, sdp))); |
| 64 } | 63 } |
| 65 | 64 |
| 66 PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(WebKit::WebRTCSe
ssionDescription webSessionDescription) | 65 PassRefPtr<RTCSessionDescription> RTCSessionDescription::create(WebKit::WebRTCSe
ssionDescription webSessionDescription) |
| 67 { | 66 { |
| 68 return adoptRef(new RTCSessionDescription(webSessionDescription)); | 67 return adoptRef(new RTCSessionDescription(webSessionDescription)); |
| 69 } | 68 } |
| 70 | 69 |
| 71 RTCSessionDescription::RTCSessionDescription(WebKit::WebRTCSessionDescription we
bSessionDescription) | 70 RTCSessionDescription::RTCSessionDescription(WebKit::WebRTCSessionDescription we
bSessionDescription) |
| 72 : m_webSessionDescription(webSessionDescription) | 71 : m_webSessionDescription(webSessionDescription) |
| 73 { | 72 { |
| 74 ScriptWrappable::init(this); | 73 ScriptWrappable::init(this); |
| 75 } | 74 } |
| 76 | 75 |
| 77 RTCSessionDescription::~RTCSessionDescription() | 76 RTCSessionDescription::~RTCSessionDescription() |
| 78 { | 77 { |
| 79 } | 78 } |
| 80 | 79 |
| 81 String RTCSessionDescription::type() | 80 String RTCSessionDescription::type() |
| 82 { | 81 { |
| 83 return m_webSessionDescription.type(); | 82 return m_webSessionDescription.type(); |
| 84 } | 83 } |
| 85 | 84 |
| 86 void RTCSessionDescription::setType(const String& type, ExceptionState& es) | 85 void RTCSessionDescription::setType(const String& type, ExceptionCode& ec) |
| 87 { | 86 { |
| 88 if (verifyType(type)) | 87 if (verifyType(type)) |
| 89 m_webSessionDescription.setType(type); | 88 m_webSessionDescription.setType(type); |
| 90 else | 89 else |
| 91 es.throwDOMException(TypeMismatchError); | 90 ec = TypeMismatchError; |
| 92 } | 91 } |
| 93 | 92 |
| 94 String RTCSessionDescription::sdp() | 93 String RTCSessionDescription::sdp() |
| 95 { | 94 { |
| 96 return m_webSessionDescription.sdp(); | 95 return m_webSessionDescription.sdp(); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void RTCSessionDescription::setSdp(const String& sdp, ExceptionState& es) | 98 void RTCSessionDescription::setSdp(const String& sdp, ExceptionCode& ec) |
| 100 { | 99 { |
| 101 m_webSessionDescription.setSDP(sdp); | 100 m_webSessionDescription.setSDP(sdp); |
| 102 } | 101 } |
| 103 | 102 |
| 104 WebKit::WebRTCSessionDescription RTCSessionDescription::webSessionDescription() | 103 WebKit::WebRTCSessionDescription RTCSessionDescription::webSessionDescription() |
| 105 { | 104 { |
| 106 return m_webSessionDescription; | 105 return m_webSessionDescription; |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace WebCore | 108 } // namespace WebCore |
| OLD | NEW |