Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/RTCIceCandidate.cpp

Issue 2007923003: Use Init dictionaries in RTCPeerConnection legacy methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
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 "modules/mediastream/RTCIceCandidate.h" 31 #include "modules/mediastream/RTCIceCandidate.h"
32 32
33 #include "bindings/core/v8/ExceptionMessages.h" 33 #include "bindings/core/v8/ExceptionMessages.h"
34 #include "bindings/core/v8/ExceptionState.h" 34 #include "bindings/core/v8/ExceptionState.h"
35 #include "bindings/core/v8/ScriptValue.h" 35 #include "bindings/core/v8/ScriptValue.h"
36 #include "bindings/core/v8/V8ObjectBuilder.h" 36 #include "bindings/core/v8/V8ObjectBuilder.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/dom/ExecutionContext.h"
39 #include "core/frame/UseCounter.h"
38 #include "modules/mediastream/RTCIceCandidateInit.h" 40 #include "modules/mediastream/RTCIceCandidateInit.h"
39 41
40 namespace blink { 42 namespace blink {
41 43
42 RTCIceCandidate* RTCIceCandidate::create(const RTCIceCandidateInit& candidateIni t, ExceptionState& exceptionState) 44 RTCIceCandidate* RTCIceCandidate::create(ExecutionContext* context, const RTCIce CandidateInit& candidateInit, ExceptionState& exceptionState)
43 { 45 {
44 if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) { 46 if (!candidateInit.hasCandidate() || !candidateInit.candidate().length()) {
45 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::i ncorrectPropertyType("candidate", "is not a string, or is empty.")); 47 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::i ncorrectPropertyType("candidate", "is not a string, or is empty."));
46 return nullptr; 48 return nullptr;
47 } 49 }
48 50
49 String sdpMid; 51 String sdpMid;
50 if (candidateInit.hasSdpMid()) 52 if (candidateInit.hasSdpMid())
51 sdpMid = candidateInit.sdpMid(); 53 sdpMid = candidateInit.sdpMid();
52 54
55 // TODO(guidou): Change default value to -1. crbug.com/614958.
53 unsigned short sdpMLineIndex = 0; 56 unsigned short sdpMLineIndex = 0;
54 if (candidateInit.hasSdpMLineIndex()) 57 if (candidateInit.hasSdpMLineIndex())
55 sdpMLineIndex = candidateInit.sdpMLineIndex(); 58 sdpMLineIndex = candidateInit.sdpMLineIndex();
59 else
60 UseCounter::count(context, UseCounter::RTCIceCandidateDefaultSdpMLineInd ex);
56 61
57 return new RTCIceCandidate(WebRTCICECandidate(candidateInit.candidate(), sdp Mid, sdpMLineIndex)); 62 return new RTCIceCandidate(WebRTCICECandidate(candidateInit.candidate(), sdp Mid, sdpMLineIndex));
58 } 63 }
59 64
60 RTCIceCandidate* RTCIceCandidate::create(WebRTCICECandidate webCandidate) 65 RTCIceCandidate* RTCIceCandidate::create(WebRTCICECandidate webCandidate)
61 { 66 {
62 return new RTCIceCandidate(webCandidate); 67 return new RTCIceCandidate(webCandidate);
63 } 68 }
64 69
65 RTCIceCandidate::RTCIceCandidate(WebRTCICECandidate webCandidate) 70 RTCIceCandidate::RTCIceCandidate(WebRTCICECandidate webCandidate)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ScriptValue RTCIceCandidate::toJSONForBinding(ScriptState* scriptState) 110 ScriptValue RTCIceCandidate::toJSONForBinding(ScriptState* scriptState)
106 { 111 {
107 V8ObjectBuilder result(scriptState); 112 V8ObjectBuilder result(scriptState);
108 result.addString("candidate", m_webCandidate.candidate()); 113 result.addString("candidate", m_webCandidate.candidate());
109 result.addString("sdpMid", m_webCandidate.sdpMid()); 114 result.addString("sdpMid", m_webCandidate.sdpMid());
110 result.addNumber("sdpMLineIndex", m_webCandidate.sdpMLineIndex()); 115 result.addNumber("sdpMLineIndex", m_webCandidate.sdpMLineIndex());
111 return result.scriptValue(); 116 return result.scriptValue();
112 } 117 }
113 118
114 } // namespace blink 119 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698