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

Side by Side Diff: Source/modules/mediastream/RTCPeerConnection.cpp

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 namespace WebCore { 65 namespace WebCore {
66 66
67 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction ary& configuration, ExceptionState& es) 67 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction ary& configuration, ExceptionState& es)
68 { 68 {
69 if (configuration.isUndefinedOrNull()) 69 if (configuration.isUndefinedOrNull())
70 return 0; 70 return 0;
71 71
72 ArrayValue iceServers; 72 ArrayValue iceServers;
73 bool ok = configuration.get("iceServers", iceServers); 73 bool ok = configuration.get("iceServers", iceServers);
74 if (!ok || iceServers.isUndefinedOrNull()) { 74 if (!ok || iceServers.isUndefinedOrNull()) {
75 es.throwDOMException(TypeMismatchError); 75 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
76 return 0; 76 return 0;
77 } 77 }
78 78
79 size_t numberOfServers; 79 size_t numberOfServers;
80 ok = iceServers.length(numberOfServers); 80 ok = iceServers.length(numberOfServers);
81 if (!ok) { 81 if (!ok) {
82 es.throwDOMException(TypeMismatchError); 82 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
83 return 0; 83 return 0;
84 } 84 }
85 85
86 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); 86 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();
87 87
88 for (size_t i = 0; i < numberOfServers; ++i) { 88 for (size_t i = 0; i < numberOfServers; ++i) {
89 Dictionary iceServer; 89 Dictionary iceServer;
90 ok = iceServers.get(i, iceServer); 90 ok = iceServers.get(i, iceServer);
91 if (!ok) { 91 if (!ok) {
92 es.throwDOMException(TypeMismatchError); 92 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
93 return 0; 93 return 0;
94 } 94 }
95 95
96 String urlString, username, credential; 96 String urlString, username, credential;
97 ok = iceServer.get("url", urlString); 97 ok = iceServer.get("url", urlString);
98 if (!ok) { 98 if (!ok) {
99 es.throwDOMException(TypeMismatchError); 99 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
100 return 0; 100 return 0;
101 } 101 }
102 KURL url(KURL(), urlString); 102 KURL url(KURL(), urlString);
103 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns" ) || url.protocolIs("stun"))) { 103 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("turns" ) || url.protocolIs("stun"))) {
104 es.throwDOMException(TypeMismatchError); 104 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
105 return 0; 105 return 0;
106 } 106 }
107 107
108 iceServer.get("username", username); 108 iceServer.get("username", username);
109 iceServer.get("credential", credential); 109 iceServer.get("credential", credential);
110 110
111 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede ntial)); 111 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede ntial));
112 } 112 }
113 113
114 return rtcConfiguration.release(); 114 return rtcConfiguration.release();
(...skipping 22 matching lines...) Expand all
137 , m_signalingState(SignalingStateStable) 137 , m_signalingState(SignalingStateStable)
138 , m_iceGatheringState(IceGatheringStateNew) 138 , m_iceGatheringState(IceGatheringStateNew)
139 , m_iceConnectionState(IceConnectionStateNew) 139 , m_iceConnectionState(IceConnectionStateNew)
140 , m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired) 140 , m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired)
141 , m_stopped(false) 141 , m_stopped(false)
142 { 142 {
143 ScriptWrappable::init(this); 143 ScriptWrappable::init(this);
144 Document* document = toDocument(scriptExecutionContext()); 144 Document* document = toDocument(scriptExecutionContext());
145 145
146 if (!document->frame()) { 146 if (!document->frame()) {
147 es.throwDOMException(NotSupportedError); 147 es.throwUninformativeAndGenericDOMException(NotSupportedError);
148 return; 148 return;
149 } 149 }
150 150
151 m_peerHandler = RTCPeerConnectionHandler::create(this); 151 m_peerHandler = RTCPeerConnectionHandler::create(this);
152 if (!m_peerHandler) { 152 if (!m_peerHandler) {
153 es.throwDOMException(NotSupportedError); 153 es.throwUninformativeAndGenericDOMException(NotSupportedError);
154 return; 154 return;
155 } 155 }
156 156
157 document->frame()->loader()->client()->dispatchWillStartUsingPeerConnectionH andler(m_peerHandler.get()); 157 document->frame()->loader()->client()->dispatchWillStartUsingPeerConnectionH andler(m_peerHandler.get());
158 158
159 if (!m_peerHandler->initialize(configuration, constraints)) { 159 if (!m_peerHandler->initialize(configuration, constraints)) {
160 es.throwDOMException(NotSupportedError); 160 es.throwUninformativeAndGenericDOMException(NotSupportedError);
161 return; 161 return;
162 } 162 }
163 } 163 }
164 164
165 RTCPeerConnection::~RTCPeerConnection() 165 RTCPeerConnection::~RTCPeerConnection()
166 { 166 {
167 stop(); 167 stop();
168 } 168 }
169 169
170 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& es) 170 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& es)
171 { 171 {
172 if (m_signalingState == SignalingStateClosed) { 172 if (m_signalingState == SignalingStateClosed) {
173 es.throwDOMException(InvalidStateError); 173 es.throwUninformativeAndGenericDOMException(InvalidStateError);
174 return; 174 return;
175 } 175 }
176 176
177 if (!successCallback) { 177 if (!successCallback) {
178 es.throwDOMException(TypeMismatchError); 178 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
179 return; 179 return;
180 } 180 }
181 181
182 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 182 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es);
183 if (es.hadException()) 183 if (es.hadException())
184 return; 184 return;
185 185
186 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(scriptExecutionContext(), successCallback, errorCallback); 186 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(scriptExecutionContext(), successCallback, errorCallback);
187 m_peerHandler->createOffer(request.release(), constraints); 187 m_peerHandler->createOffer(request.release(), constraints);
188 } 188 }
189 189
190 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& es) 190 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& es)
191 { 191 {
192 if (m_signalingState == SignalingStateClosed) { 192 if (m_signalingState == SignalingStateClosed) {
193 es.throwDOMException(InvalidStateError); 193 es.throwUninformativeAndGenericDOMException(InvalidStateError);
194 return; 194 return;
195 } 195 }
196 196
197 if (!successCallback) { 197 if (!successCallback) {
198 es.throwDOMException(TypeMismatchError); 198 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
199 return; 199 return;
200 } 200 }
201 201
202 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 202 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es);
203 if (es.hadException()) 203 if (es.hadException())
204 return; 204 return;
205 205
206 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(scriptExecutionContext(), successCallback, errorCallback); 206 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(scriptExecutionContext(), successCallback, errorCallback);
207 m_peerHandler->createAnswer(request.release(), constraints.release()); 207 m_peerHandler->createAnswer(request.release(), constraints.release());
208 } 208 }
209 209
210 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr orCallback> errorCallback, ExceptionState& es) 210 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr orCallback> errorCallback, ExceptionState& es)
211 { 211 {
212 if (m_signalingState == SignalingStateClosed) { 212 if (m_signalingState == SignalingStateClosed) {
213 es.throwDOMException(InvalidStateError); 213 es.throwUninformativeAndGenericDOMException(InvalidStateError);
214 return; 214 return;
215 } 215 }
216 216
217 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 217 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
218 if (!sessionDescription) { 218 if (!sessionDescription) {
219 es.throwDOMException(TypeMismatchError); 219 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
220 return; 220 return;
221 } 221 }
222 222
223 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback); 223 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback);
224 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 224 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
225 } 225 }
226 226
227 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& es) 227 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& es)
228 { 228 {
229 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->loca lDescription(); 229 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->loca lDescription();
230 if (webSessionDescription.isNull()) 230 if (webSessionDescription.isNull())
231 return 0; 231 return 0;
232 232
233 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); 233 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription);
234 return sessionDescription.release(); 234 return sessionDescription.release();
235 } 235 }
236 236
237 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr rorCallback> errorCallback, ExceptionState& es) 237 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr rorCallback> errorCallback, ExceptionState& es)
238 { 238 {
239 if (m_signalingState == SignalingStateClosed) { 239 if (m_signalingState == SignalingStateClosed) {
240 es.throwDOMException(InvalidStateError); 240 es.throwUninformativeAndGenericDOMException(InvalidStateError);
241 return; 241 return;
242 } 242 }
243 243
244 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 244 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
245 if (!sessionDescription) { 245 if (!sessionDescription) {
246 es.throwDOMException(TypeMismatchError); 246 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
247 return; 247 return;
248 } 248 }
249 249
250 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback); 250 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback);
251 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); 251 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription());
252 } 252 }
253 253
254 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& es) 254 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& es)
255 { 255 {
256 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->remo teDescription(); 256 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->remo teDescription();
257 if (webSessionDescription.isNull()) 257 if (webSessionDescription.isNull())
258 return 0; 258 return 0;
259 259
260 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); 260 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription);
261 return desc.release(); 261 return desc.release();
262 } 262 }
263 263
264 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& es) 264 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& es)
265 { 265 {
266 if (m_signalingState == SignalingStateClosed) { 266 if (m_signalingState == SignalingStateClosed) {
267 es.throwDOMException(InvalidStateError); 267 es.throwUninformativeAndGenericDOMException(InvalidStateError);
268 return; 268 return;
269 } 269 }
270 270
271 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , es); 271 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , es);
272 if (es.hadException()) 272 if (es.hadException())
273 return; 273 return;
274 274
275 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 275 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es);
276 if (es.hadException()) 276 if (es.hadException())
277 return; 277 return;
278 278
279 bool valid = m_peerHandler->updateIce(configuration, constraints); 279 bool valid = m_peerHandler->updateIce(configuration, constraints);
280 if (!valid) 280 if (!valid)
281 es.throwDOMException(SyntaxError); 281 es.throwUninformativeAndGenericDOMException(SyntaxError);
282 } 282 }
283 283
284 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& es) 284 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception State& es)
285 { 285 {
286 if (m_signalingState == SignalingStateClosed) { 286 if (m_signalingState == SignalingStateClosed) {
287 es.throwDOMException(InvalidStateError); 287 es.throwUninformativeAndGenericDOMException(InvalidStateError);
288 return; 288 return;
289 } 289 }
290 290
291 if (!iceCandidate) { 291 if (!iceCandidate) {
292 es.throwDOMException(TypeMismatchError); 292 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
293 return; 293 return;
294 } 294 }
295 295
296 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate()); 296 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate());
297 if (!valid) 297 if (!valid)
298 es.throwDOMException(SyntaxError); 298 es.throwUninformativeAndGenericDOMException(SyntaxError);
299 } 299 }
300 300
301 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback, Exc eptionState& es) 301 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback, Exc eptionState& es)
302 { 302 {
303 if (m_signalingState == SignalingStateClosed) { 303 if (m_signalingState == SignalingStateClosed) {
304 es.throwDOMException(InvalidStateError); 304 es.throwUninformativeAndGenericDOMException(InvalidStateError);
305 return; 305 return;
306 } 306 }
307 307
308 if (!iceCandidate || !successCallback || !errorCallback) { 308 if (!iceCandidate || !successCallback || !errorCallback) {
309 es.throwDOMException(TypeMismatchError); 309 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
310 return; 310 return;
311 } 311 }
312 312
313 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback); 313 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut ionContext(), successCallback, errorCallback);
314 314
315 bool implemented = m_peerHandler->addIceCandidate(request.release(), iceCand idate->webCandidate()); 315 bool implemented = m_peerHandler->addIceCandidate(request.release(), iceCand idate->webCandidate());
316 if (!implemented) 316 if (!implemented)
317 es.throwDOMException(NotSupportedError); 317 es.throwUninformativeAndGenericDOMException(NotSupportedError);
318 } 318 }
319 319
320 String RTCPeerConnection::signalingState() const 320 String RTCPeerConnection::signalingState() const
321 { 321 {
322 switch (m_signalingState) { 322 switch (m_signalingState) {
323 case SignalingStateStable: 323 case SignalingStateStable:
324 return "stable"; 324 return "stable";
325 case SignalingStateHaveLocalOffer: 325 case SignalingStateHaveLocalOffer:
326 return "have-local-offer"; 326 return "have-local-offer";
327 case SignalingStateHaveRemoteOffer: 327 case SignalingStateHaveRemoteOffer:
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 return "closed"; 372 return "closed";
373 } 373 }
374 374
375 ASSERT_NOT_REACHED(); 375 ASSERT_NOT_REACHED();
376 return String(); 376 return String();
377 } 377 }
378 378
379 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& es) 379 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& es)
380 { 380 {
381 if (m_signalingState == SignalingStateClosed) { 381 if (m_signalingState == SignalingStateClosed) {
382 es.throwDOMException(InvalidStateError); 382 es.throwUninformativeAndGenericDOMException(InvalidStateError);
383 return; 383 return;
384 } 384 }
385 385
386 RefPtr<MediaStream> stream = prpStream; 386 RefPtr<MediaStream> stream = prpStream;
387 if (!stream) { 387 if (!stream) {
388 es.throwDOMException(TypeMismatchError); 388 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
389 return; 389 return;
390 } 390 }
391 391
392 if (m_localStreams.contains(stream)) 392 if (m_localStreams.contains(stream))
393 return; 393 return;
394 394
395 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es); 395 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, es);
396 if (es.hadException()) 396 if (es.hadException())
397 return; 397 return;
398 398
399 m_localStreams.append(stream); 399 m_localStreams.append(stream);
400 400
401 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); 401 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints);
402 if (!valid) 402 if (!valid)
403 es.throwDOMException(SyntaxError); 403 es.throwUninformativeAndGenericDOMException(SyntaxError);
404 } 404 }
405 405
406 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& es) 406 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& es)
407 { 407 {
408 if (m_signalingState == SignalingStateClosed) { 408 if (m_signalingState == SignalingStateClosed) {
409 es.throwDOMException(InvalidStateError); 409 es.throwUninformativeAndGenericDOMException(InvalidStateError);
410 return; 410 return;
411 } 411 }
412 412
413 if (!prpStream) { 413 if (!prpStream) {
414 es.throwDOMException(TypeMismatchError); 414 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
415 return; 415 return;
416 } 416 }
417 417
418 RefPtr<MediaStream> stream = prpStream; 418 RefPtr<MediaStream> stream = prpStream;
419 419
420 size_t pos = m_localStreams.find(stream); 420 size_t pos = m_localStreams.find(stream);
421 if (pos == kNotFound) 421 if (pos == kNotFound)
422 return; 422 return;
423 423
424 m_localStreams.remove(pos); 424 m_localStreams.remove(pos);
(...skipping 29 matching lines...) Expand all
454 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 454 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
455 { 455 {
456 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(scrip tExecutionContext(), successCallback, selector); 456 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(scrip tExecutionContext(), successCallback, selector);
457 // FIXME: Add passing selector as part of the statsRequest. 457 // FIXME: Add passing selector as part of the statsRequest.
458 m_peerHandler->getStats(statsRequest.release()); 458 m_peerHandler->getStats(statsRequest.release());
459 } 459 }
460 460
461 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& es) 461 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& es)
462 { 462 {
463 if (m_signalingState == SignalingStateClosed) { 463 if (m_signalingState == SignalingStateClosed) {
464 es.throwDOMException(InvalidStateError); 464 es.throwUninformativeAndGenericDOMException(InvalidStateError);
465 return 0; 465 return 0;
466 } 466 }
467 467
468 WebKit::WebRTCDataChannelInit init; 468 WebKit::WebRTCDataChannelInit init;
469 options.get("ordered", init.ordered); 469 options.get("ordered", init.ordered);
470 options.get("negotiated", init.negotiated); 470 options.get("negotiated", init.negotiated);
471 471
472 unsigned short value = 0; 472 unsigned short value = 0;
473 if (options.get("id", value)) 473 if (options.get("id", value))
474 init.id = value; 474 init.id = value;
(...skipping 18 matching lines...) Expand all
493 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { 493 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) {
494 if ((*iter)->getTrackById(trackId)) 494 if ((*iter)->getTrackById(trackId))
495 return true; 495 return true;
496 } 496 }
497 return false; 497 return false;
498 } 498 }
499 499
500 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& es) 500 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& es)
501 { 501 {
502 if (m_signalingState == SignalingStateClosed) { 502 if (m_signalingState == SignalingStateClosed) {
503 es.throwDOMException(InvalidStateError); 503 es.throwUninformativeAndGenericDOMException(InvalidStateError);
504 return 0; 504 return 0;
505 } 505 }
506 506
507 if (!prpTrack) { 507 if (!prpTrack) {
508 es.throwTypeError(); 508 es.throwTypeError();
509 return 0; 509 return 0;
510 } 510 }
511 511
512 RefPtr<MediaStreamTrack> track = prpTrack; 512 RefPtr<MediaStreamTrack> track = prpTrack;
513 513
514 if (!hasLocalStreamWithTrackId(track->id())) { 514 if (!hasLocalStreamWithTrackId(track->id())) {
515 es.throwDOMException(SyntaxError); 515 es.throwUninformativeAndGenericDOMException(SyntaxError);
516 return 0; 516 return 0;
517 } 517 }
518 518
519 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(scriptExecutionCont ext(), m_peerHandler.get(), track.release(), es); 519 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(scriptExecutionCont ext(), m_peerHandler.get(), track.release(), es);
520 if (es.hadException()) 520 if (es.hadException())
521 return 0; 521 return 0;
522 return dtmfSender.release(); 522 return dtmfSender.release();
523 } 523 }
524 524
525 void RTCPeerConnection::close(ExceptionState& es) 525 void RTCPeerConnection::close(ExceptionState& es)
526 { 526 {
527 if (m_signalingState == SignalingStateClosed) { 527 if (m_signalingState == SignalingStateClosed) {
528 es.throwDOMException(InvalidStateError); 528 es.throwUninformativeAndGenericDOMException(InvalidStateError);
529 return; 529 return;
530 } 530 }
531 531
532 m_peerHandler->stop(); 532 m_peerHandler->stop();
533 533
534 changeIceConnectionState(IceConnectionStateClosed); 534 changeIceConnectionState(IceConnectionStateClosed);
535 changeIceGatheringState(IceGatheringStateComplete); 535 changeIceGatheringState(IceGatheringStateComplete);
536 changeSignalingState(SignalingStateClosed); 536 changeSignalingState(SignalingStateClosed);
537 } 537 }
538 538
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 events.swap(m_scheduledEvents); 686 events.swap(m_scheduledEvents);
687 687
688 Vector<RefPtr<Event> >::iterator it = events.begin(); 688 Vector<RefPtr<Event> >::iterator it = events.begin();
689 for (; it != events.end(); ++it) 689 for (; it != events.end(); ++it)
690 dispatchEvent((*it).release()); 690 dispatchEvent((*it).release());
691 691
692 events.clear(); 692 events.clear();
693 } 693 }
694 694
695 } // namespace WebCore 695 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCIceCandidate.cpp ('k') | Source/modules/mediastream/RTCSessionDescription.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698