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

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

Issue 173363002: Move mediastream module to oilpan transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: WIP Created 6 years, 10 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 #include "public/platform/WebRTCDataChannelHandler.h" 63 #include "public/platform/WebRTCDataChannelHandler.h"
64 #include "public/platform/WebRTCDataChannelInit.h" 64 #include "public/platform/WebRTCDataChannelInit.h"
65 #include "public/platform/WebRTCICECandidate.h" 65 #include "public/platform/WebRTCICECandidate.h"
66 #include "public/platform/WebRTCSessionDescription.h" 66 #include "public/platform/WebRTCSessionDescription.h"
67 #include "public/platform/WebRTCSessionDescriptionRequest.h" 67 #include "public/platform/WebRTCSessionDescriptionRequest.h"
68 #include "public/platform/WebRTCStatsRequest.h" 68 #include "public/platform/WebRTCStatsRequest.h"
69 #include "public/platform/WebRTCVoidRequest.h" 69 #include "public/platform/WebRTCVoidRequest.h"
70 70
71 namespace WebCore { 71 namespace WebCore {
72 72
73 DEFINE_GC_INFO(RTCPeerConnection);
74
73 namespace { 75 namespace {
74 76
75 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState) 77 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState)
76 { 78 {
77 if (state == RTCPeerConnection::SignalingStateClosed) { 79 if (state == RTCPeerConnection::SignalingStateClosed) {
78 exceptionState.throwDOMException(InvalidStateError, "The RTCPeerConnecti on's signalingState is 'closed'."); 80 exceptionState.throwDOMException(InvalidStateError, "The RTCPeerConnecti on's signalingState is 'closed'.");
79 return true; 81 return true;
80 } 82 }
81 83
82 return false; 84 return false;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return nullptr; 153 return nullptr;
152 } 154 }
153 155
154 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); 156 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential));
155 } 157 }
156 } 158 }
157 159
158 return rtcConfiguration.release(); 160 return rtcConfiguration.release();
159 } 161 }
160 162
161 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* contex t, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, Excep tionState& exceptionState) 163 PassRefPtrWillBeRawPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionCon text* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstr aints, ExceptionState& exceptionState)
162 { 164 {
163 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); 165 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
164 if (exceptionState.hadException()) 166 if (exceptionState.hadException())
165 return nullptr; 167 return nullptr;
166 168
167 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 169 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
168 if (exceptionState.hadException()) 170 if (exceptionState.hadException())
169 return nullptr; 171 return nullptr;
170 172
171 RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(co ntext, configuration.release(), constraints, exceptionState)); 173 RefPtrWillBeRawPtr<RTCPeerConnection> peerConnection = adoptRefCountedWillBe RefCountedGarbageCollected(new RTCPeerConnection(context, configuration.release( ), constraints, exceptionState));
172 peerConnection->suspendIfNeeded(); 174 peerConnection->suspendIfNeeded();
173 if (exceptionState.hadException()) 175 if (exceptionState.hadException())
174 return nullptr; 176 return nullptr;
175 177
176 return peerConnection.release(); 178 return peerConnection.release();
177 } 179 }
178 180
179 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) 181 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState)
180 : ActiveDOMObject(context) 182 : ActiveDOMObject(context)
181 , m_signalingState(SignalingStateStable) 183 , m_signalingState(SignalingStateStable)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 ASSERT(successCallback); 236 ASSERT(successCallback);
235 237
236 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 238 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
237 if (exceptionState.hadException()) 239 if (exceptionState.hadException())
238 return; 240 return;
239 241
240 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); 242 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback);
241 m_peerHandler->createAnswer(request.release(), constraints); 243 m_peerHandler->createAnswer(request.release(), constraints);
242 } 244 }
243 245
244 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState) 246 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
245 { 247 {
246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 248 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
247 return; 249 return;
248 250
249 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 251 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
250 if (!sessionDescription) { 252 if (!sessionDescription) {
251 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 253 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
252 return; 254 return;
253 } 255 }
254 256
255 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 257 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback);
256 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 258 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
257 } 259 }
258 260
259 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState) 261 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState)
260 { 262 {
261 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); 263 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description();
262 if (webSessionDescription.isNull()) 264 if (webSessionDescription.isNull())
263 return nullptr; 265 return nullptr;
264 266
265 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); 267 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = RTCSessionDes cription::create(webSessionDescription);
266 return sessionDescription.release(); 268 return sessionDescription.release();
267 } 269 }
268 270
269 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState) 271 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
270 { 272 {
271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 273 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
272 return; 274 return;
273 275
274 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 276 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
275 if (!sessionDescription) { 277 if (!sessionDescription) {
276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 278 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
277 return; 279 return;
278 } 280 }
279 281
280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 282 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback);
281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); 283 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription());
282 } 284 }
283 285
284 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& exceptionState) 286 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState)
285 { 287 {
286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); 288 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription();
287 if (webSessionDescription.isNull()) 289 if (webSessionDescription.isNull())
288 return nullptr; 290 return nullptr;
289 291
290 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); 292 RefPtrWillBeRawPtr<RTCSessionDescription> desc = RTCSessionDescription::crea te(webSessionDescription);
291 return desc.release(); 293 return desc.release();
292 } 294 }
293 295
294 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) 296 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState)
295 { 297 {
296 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 298 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
297 return; 299 return;
298 300
299 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); 301 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
300 if (exceptionState.hadException()) 302 if (exceptionState.hadException())
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 case ICEConnectionStateDisconnected: 397 case ICEConnectionStateDisconnected:
396 return "disconnected"; 398 return "disconnected";
397 case ICEConnectionStateClosed: 399 case ICEConnectionStateClosed:
398 return "closed"; 400 return "closed";
399 } 401 }
400 402
401 ASSERT_NOT_REACHED(); 403 ASSERT_NOT_REACHED();
402 return String(); 404 return String();
403 } 405 }
404 406
405 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& exceptionState) 407 void RTCPeerConnection::addStream(PassRefPtrWillBeRawPtr<MediaStream> prpStream, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
406 { 408 {
407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 409 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
408 return; 410 return;
409 411
410 RefPtr<MediaStream> stream = prpStream; 412 RefPtrWillBeRawPtr<MediaStream> stream = prpStream;
411 if (!stream) { 413 if (!stream) {
412 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); 414 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream"));
413 return; 415 return;
414 } 416 }
415 417
416 if (m_localStreams.contains(stream)) 418 if (m_localStreams.contains(stream))
417 return; 419 return;
418 420
419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 421 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
420 if (exceptionState.hadException()) 422 if (exceptionState.hadException())
421 return; 423 return;
422 424
423 m_localStreams.append(stream); 425 m_localStreams.append(stream);
424 426
425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); 427 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints);
426 if (!valid) 428 if (!valid)
427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); 429 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream.");
428 } 430 }
429 431
430 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& exceptionState) 432 void RTCPeerConnection::removeStream(PassRefPtrWillBeRawPtr<MediaStream> prpStre am, ExceptionState& exceptionState)
431 { 433 {
432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 434 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
433 return; 435 return;
434 436
435 if (!prpStream) { 437 if (!prpStream) {
436 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); 438 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream"));
437 return; 439 return;
438 } 440 }
439 441
440 RefPtr<MediaStream> stream = prpStream; 442 RefPtrWillBeRawPtr<MediaStream> stream = prpStream;
441 443
442 size_t pos = m_localStreams.find(stream); 444 size_t pos = m_localStreams.find(stream);
443 if (pos == kNotFound) 445 if (pos == kNotFound)
444 return; 446 return;
445 447
446 m_localStreams.remove(pos); 448 m_localStreams.remove(pos);
447 449
448 m_peerHandler->removeStream(stream->descriptor()); 450 m_peerHandler->removeStream(stream->descriptor());
449 } 451 }
450 452
(...skipping 22 matching lines...) Expand all
473 return 0; 475 return 0;
474 } 476 }
475 477
476 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 478 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
477 { 479 {
478 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); 480 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector);
479 // FIXME: Add passing selector as part of the statsRequest. 481 // FIXME: Add passing selector as part of the statsRequest.
480 m_peerHandler->getStats(statsRequest.release()); 482 m_peerHandler->getStats(statsRequest.release());
481 } 483 }
482 484
483 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState) 485 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState)
484 { 486 {
485 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 487 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
486 return nullptr; 488 return nullptr;
487 489
488 blink::WebRTCDataChannelInit init; 490 blink::WebRTCDataChannelInit init;
489 options.get("ordered", init.ordered); 491 options.get("ordered", init.ordered);
490 options.get("negotiated", init.negotiated); 492 options.get("negotiated", init.negotiated);
491 493
492 unsigned short value = 0; 494 unsigned short value = 0;
493 if (options.get("id", value)) 495 if (options.get("id", value))
494 init.id = value; 496 init.id = value;
495 if (options.get("maxRetransmits", value)) 497 if (options.get("maxRetransmits", value))
496 init.maxRetransmits = value; 498 init.maxRetransmits = value;
497 if (options.get("maxRetransmitTime", value)) 499 if (options.get("maxRetransmitTime", value))
498 init.maxRetransmitTime = value; 500 init.maxRetransmitTime = value;
499 501
500 String protocolString; 502 String protocolString;
501 options.get("protocol", protocolString); 503 options.get("protocol", protocolString);
502 init.protocol = protocolString; 504 init.protocol = protocolString;
503 505
504 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, exceptionState); 506 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_peerHandler.get(), label, init, exceptionState);
505 if (exceptionState.hadException()) 507 if (exceptionState.hadException())
506 return nullptr; 508 return nullptr;
507 m_dataChannels.append(channel); 509 m_dataChannels.append(channel);
508 return channel.release(); 510 return channel.release();
509 } 511 }
510 512
511 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) 513 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId)
512 { 514 {
513 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { 515 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) {
514 if ((*iter)->getTrackById(trackId)) 516 if ((*iter)->getTrackById(trackId))
515 return true; 517 return true;
516 } 518 }
517 return false; 519 return false;
518 } 520 }
519 521
520 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& exceptionState) 522 PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRe fPtrWillBeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState)
521 { 523 {
522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 524 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
523 return nullptr; 525 return nullptr;
524 526
525 if (!prpTrack) { 527 if (!prpTrack) {
526 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack")); 528 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack"));
527 return nullptr; 529 return nullptr;
528 } 530 }
529 531
530 RefPtr<MediaStreamTrack> track = prpTrack; 532 RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack;
531 533
532 if (!hasLocalStreamWithTrackId(track->id())) { 534 if (!hasLocalStreamWithTrackId(track->id())) {
533 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); 535 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided.");
534 return nullptr; 536 return nullptr;
535 } 537 }
536 538
537 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), exceptionState); 539 RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executi onContext(), m_peerHandler.get(), track.release(), exceptionState);
538 if (exceptionState.hadException()) 540 if (exceptionState.hadException())
539 return nullptr; 541 return nullptr;
540 return dtmfSender.release(); 542 return dtmfSender.release();
541 } 543 }
542 544
543 void RTCPeerConnection::close(ExceptionState& exceptionState) 545 void RTCPeerConnection::close(ExceptionState& exceptionState)
544 { 546 {
545 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 547 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
546 return; 548 return;
547 549
548 m_peerHandler->stop(); 550 m_peerHandler->stop();
549 551
550 changeIceConnectionState(ICEConnectionStateClosed); 552 changeIceConnectionState(ICEConnectionStateClosed);
551 changeIceGatheringState(ICEGatheringStateComplete); 553 changeIceGatheringState(ICEGatheringStateComplete);
552 changeSignalingState(SignalingStateClosed); 554 changeSignalingState(SignalingStateClosed);
553 } 555 }
554 556
555 void RTCPeerConnection::negotiationNeeded() 557 void RTCPeerConnection::negotiationNeeded()
556 { 558 {
557 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); 559 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded));
558 } 560 }
559 561
560 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) 562 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate)
561 { 563 {
562 ASSERT(executionContext()->isContextThread()); 564 ASSERT(executionContext()->isContextThread());
563 if (webCandidate.isNull()) 565 if (webCandidate.isNull())
564 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); 566 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr ));
565 else { 567 else {
566 RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(webCandid ate); 568 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate);
567 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); 569 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release()));
568 } 570 }
569 } 571 }
570 572
571 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) 573 void RTCPeerConnection::didChangeSignalingState(SignalingState newState)
572 { 574 {
573 ASSERT(executionContext()->isContextThread()); 575 ASSERT(executionContext()->isContextThread());
574 changeSignalingState(newState); 576 changeSignalingState(newState);
575 } 577 }
576 578
577 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) 579 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState)
578 { 580 {
579 ASSERT(executionContext()->isContextThread()); 581 ASSERT(executionContext()->isContextThread());
580 changeIceGatheringState(newState); 582 changeIceGatheringState(newState);
581 } 583 }
582 584
583 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) 585 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState)
584 { 586 {
585 ASSERT(executionContext()->isContextThread()); 587 ASSERT(executionContext()->isContextThread());
586 changeIceConnectionState(newState); 588 changeIceConnectionState(newState);
587 } 589 }
588 590
589 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) 591 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream)
590 { 592 {
591 ASSERT(executionContext()->isContextThread()); 593 ASSERT(executionContext()->isContextThread());
592 594
593 if (m_signalingState == SignalingStateClosed) 595 if (m_signalingState == SignalingStateClosed)
594 return; 596 return;
595 597
596 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), remoteS tream); 598 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream);
597 m_remoteStreams.append(stream); 599 m_remoteStreams.append(stream);
598 600
599 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); 601 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release()));
600 } 602 }
601 603
602 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) 604 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream)
603 { 605 {
604 ASSERT(executionContext()->isContextThread()); 606 ASSERT(executionContext()->isContextThread());
605 607
606 MediaStreamDescriptor* streamDescriptor = remoteStream; 608 MediaStreamDescriptor* streamDescriptor = remoteStream;
607 ASSERT(streamDescriptor->client()); 609 ASSERT(streamDescriptor->client());
608 610
609 RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->cli ent()); 611 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client());
610 stream->streamEnded(); 612 stream->streamEnded();
611 613
612 if (m_signalingState == SignalingStateClosed) 614 if (m_signalingState == SignalingStateClosed)
613 return; 615 return;
614 616
615 size_t pos = m_remoteStreams.find(stream); 617 size_t pos = m_remoteStreams.find(stream);
616 ASSERT(pos != kNotFound); 618 ASSERT(pos != kNotFound);
617 m_remoteStreams.remove(pos); 619 m_remoteStreams.remove(pos);
618 620
619 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); 621 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release()));
620 } 622 }
621 623
622 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) 624 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler)
623 { 625 {
624 ASSERT(executionContext()->isContextThread()); 626 ASSERT(executionContext()->isContextThread());
625 627
626 if (m_signalingState == SignalingStateClosed) 628 if (m_signalingState == SignalingStateClosed)
627 return; 629 return;
628 630
629 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), adoptPtr(handler)); 631 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler));
630 m_dataChannels.append(channel); 632 m_dataChannels.append(channel);
631 633
632 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); 634 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release()));
633 } 635 }
634 636
635 const AtomicString& RTCPeerConnection::interfaceName() const 637 const AtomicString& RTCPeerConnection::interfaceName() const
636 { 638 {
637 return EventTargetNames::RTCPeerConnection; 639 return EventTargetNames::RTCPeerConnection;
638 } 640 }
639 641
(...skipping 14 matching lines...) Expand all
654 656
655 void RTCPeerConnection::stop() 657 void RTCPeerConnection::stop()
656 { 658 {
657 if (m_stopped) 659 if (m_stopped)
658 return; 660 return;
659 661
660 m_stopped = true; 662 m_stopped = true;
661 m_iceConnectionState = ICEConnectionStateClosed; 663 m_iceConnectionState = ICEConnectionStateClosed;
662 m_signalingState = SignalingStateClosed; 664 m_signalingState = SignalingStateClosed;
663 665
664 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); 666 WillBeHeapVector<RefPtrWillBeMember<RTCDataChannel> >::iterator i = m_dataCh annels.begin();
665 for (; i != m_dataChannels.end(); ++i) 667 for (; i != m_dataChannels.end(); ++i)
666 (*i)->stop(); 668 (*i)->stop();
667 669
668 m_dispatchScheduledEventRunner.stop(); 670 m_dispatchScheduledEventRunner.stop();
669 } 671 }
670 672
671 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) 673 void RTCPeerConnection::changeSignalingState(SignalingState signalingState)
672 { 674 {
673 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { 675 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) {
674 m_signalingState = signalingState; 676 m_signalingState = signalingState;
(...skipping 29 matching lines...) Expand all
704 Vector<RefPtr<Event> > events; 706 Vector<RefPtr<Event> > events;
705 events.swap(m_scheduledEvents); 707 events.swap(m_scheduledEvents);
706 708
707 Vector<RefPtr<Event> >::iterator it = events.begin(); 709 Vector<RefPtr<Event> >::iterator it = events.begin();
708 for (; it != events.end(); ++it) 710 for (; it != events.end(); ++it)
709 dispatchEvent((*it).release()); 711 dispatchEvent((*it).release());
710 712
711 events.clear(); 713 events.clear();
712 } 714 }
713 715
716 void RTCPeerConnection::trace(Visitor* visitor)
717 {
718 visitor->trace(m_localStreams);
719 visitor->trace(m_remoteStreams);
720 visitor->trace(m_dataChannels);
721 }
722
714 } // namespace WebCore 723 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698