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

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

Issue 329093002: Allow PeerConnection to be garbage collected after close(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 return peerConnection.release(); 175 return peerConnection.release();
176 } 176 }
177 177
178 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) 178 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState)
179 : ActiveDOMObject(context) 179 : ActiveDOMObject(context)
180 , m_signalingState(SignalingStateStable) 180 , m_signalingState(SignalingStateStable)
181 , m_iceGatheringState(ICEGatheringStateNew) 181 , m_iceGatheringState(ICEGatheringStateNew)
182 , m_iceConnectionState(ICEConnectionStateNew) 182 , m_iceConnectionState(ICEConnectionStateNew)
183 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event) 183 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event)
184 , m_stopped(false) 184 , m_stopped(false)
185 , m_closed(false)
185 { 186 {
186 ScriptWrappable::init(this); 187 ScriptWrappable::init(this);
187 Document* document = toDocument(executionContext()); 188 Document* document = toDocument(executionContext());
188 189
190 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the assert in the destructor.
191
189 if (!document->frame()) { 192 if (!document->frame()) {
193 m_closed = true;
194 m_stopped = true;
190 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may not be created in detached documents."); 195 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may not be created in detached documents.");
191 return; 196 return;
192 } 197 }
193 198
194 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection Handler(this)); 199 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection Handler(this));
195 if (!m_peerHandler) { 200 if (!m_peerHandler) {
201 m_closed = true;
202 m_stopped = true;
196 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h andler can be created, perhaps WebRTC is disabled?"); 203 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h andler can be created, perhaps WebRTC is disabled?");
197 return; 204 return;
198 } 205 }
199 206
200 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); 207 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get());
201 208
202 if (!m_peerHandler->initialize(configuration, constraints)) { 209 if (!m_peerHandler->initialize(configuration, constraints)) {
210 m_closed = true;
211 m_stopped = true;
203 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); 212 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection.");
204 return; 213 return;
205 } 214 }
206 } 215 }
207 216
208 RTCPeerConnection::~RTCPeerConnection() 217 RTCPeerConnection::~RTCPeerConnection()
209 { 218 {
210 // This checks that stop() is called if necessary before the destructor. 219 // This checks that close() or stop() is called before the destructor.
211 // We are assuming that a wrapper is always created when RTCPeerConnection i s created 220 // We are assuming that a wrapper is always created when RTCPeerConnection i s created.
212 ASSERT(m_dataChannels.isEmpty()); 221 ASSERT(m_closed || m_stopped);
222 stop();
haraken 2014/06/15 13:43:57 This is not allowed in oilpan, because in oilpan d
Henrik Grunell 2014/06/16 07:48:59 Help me understand this, RTCDataChannel is ref cou
keishi 2014/06/16 08:04:01 I think we might need to use weak processing to ca
Henrik Grunell 2014/06/16 08:34:38 Thanks for the input. Actually, the right thing co
213 } 223 }
214 224
215 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) 225 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState)
216 { 226 {
217 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 227 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
218 return; 228 return;
219 229
220 ASSERT(successCallback); 230 ASSERT(successCallback);
221 231
222 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 232 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
223 if (exceptionState.hadException()) 233 if (exceptionState.hadException())
224 return; 234 return;
225 235
226 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); 236 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), this, successCallback, errorCallback);
227 m_peerHandler->createOffer(request.release(), constraints); 237 m_peerHandler->createOffer(request.release(), constraints);
228 } 238 }
229 239
230 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState) 240 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState)
231 { 241 {
232 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 242 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
233 return; 243 return;
234 244
235 ASSERT(successCallback); 245 ASSERT(successCallback);
236 246
237 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 247 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
238 if (exceptionState.hadException()) 248 if (exceptionState.hadException())
239 return; 249 return;
240 250
241 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); 251 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), this, successCallback, errorCallback);
242 m_peerHandler->createAnswer(request.release(), constraints); 252 m_peerHandler->createAnswer(request.release(), constraints);
243 } 253 }
244 254
245 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) 255 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
246 { 256 {
247 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 257 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
248 return; 258 return;
249 259
250 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; 260 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
251 if (!sessionDescription) { 261 if (!sessionDescription) {
252 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 262 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
253 return; 263 return;
254 } 264 }
255 265
256 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 266 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback);
257 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 267 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
258 } 268 }
259 269
260 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState) 270 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState)
261 { 271 {
262 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); 272 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description();
263 if (webSessionDescription.isNull()) 273 if (webSessionDescription.isNull())
264 return nullptr; 274 return nullptr;
265 275
266 return RTCSessionDescription::create(webSessionDescription); 276 return RTCSessionDescription::create(webSessionDescription);
267 } 277 }
268 278
269 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) 279 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
270 { 280 {
271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 281 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
272 return; 282 return;
273 283
274 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; 284 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
275 if (!sessionDescription) { 285 if (!sessionDescription) {
276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 286 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
277 return; 287 return;
278 } 288 }
279 289
280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 290 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback);
281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); 291 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription());
282 } 292 }
283 293
284 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState) 294 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState)
285 { 295 {
286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); 296 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription();
287 if (webSessionDescription.isNull()) 297 if (webSessionDescription.isNull())
288 return nullptr; 298 return nullptr;
289 299
290 return RTCSessionDescription::create(webSessionDescription); 300 return RTCSessionDescription::create(webSessionDescription);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 338 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
329 return; 339 return;
330 340
331 if (!iceCandidate) { 341 if (!iceCandidate) {
332 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCIceCandidate")); 342 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCIceCandidate"));
333 return; 343 return;
334 } 344 }
335 ASSERT(successCallback); 345 ASSERT(successCallback);
336 ASSERT(errorCallback); 346 ASSERT(errorCallback);
337 347
338 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 348 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback);
339 349
340 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand idate->webCandidate()); 350 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand idate->webCandidate());
341 if (!implemented) 351 if (!implemented) {
342 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented."); 352 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented.");
353 }
343 } 354 }
344 355
345 String RTCPeerConnection::signalingState() const 356 String RTCPeerConnection::signalingState() const
346 { 357 {
347 switch (m_signalingState) { 358 switch (m_signalingState) {
348 case SignalingStateStable: 359 case SignalingStateStable:
349 return "stable"; 360 return "stable";
350 case SignalingStateHaveLocalOffer: 361 case SignalingStateHaveLocalOffer:
351 return "have-local-offer"; 362 return "have-local-offer";
352 case SignalingStateHaveRemoteOffer: 363 case SignalingStateHaveRemoteOffer:
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { 478 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) {
468 if ((*iter)->id() == streamId) 479 if ((*iter)->id() == streamId)
469 return iter->get(); 480 return iter->get();
470 } 481 }
471 482
472 return 0; 483 return 0;
473 } 484 }
474 485
475 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 486 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
476 { 487 {
477 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); 488 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), this, successCallback, selector);
478 // FIXME: Add passing selector as part of the statsRequest. 489 // FIXME: Add passing selector as part of the statsRequest.
479 m_peerHandler->getStats(statsRequest.release()); 490 m_peerHandler->getStats(statsRequest.release());
480 } 491 }
481 492
482 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState) 493 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState)
483 { 494 {
484 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 495 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
485 return nullptr; 496 return nullptr;
486 497
487 blink::WebRTCDataChannelInit init; 498 blink::WebRTCDataChannelInit init;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return nullptr; 549 return nullptr;
539 return dtmfSender.release(); 550 return dtmfSender.release();
540 } 551 }
541 552
542 void RTCPeerConnection::close(ExceptionState& exceptionState) 553 void RTCPeerConnection::close(ExceptionState& exceptionState)
543 { 554 {
544 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 555 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
545 return; 556 return;
546 557
547 m_peerHandler->stop(); 558 m_peerHandler->stop();
559 m_closed = true;
548 560
549 changeIceConnectionState(ICEConnectionStateClosed); 561 changeIceConnectionState(ICEConnectionStateClosed);
550 changeIceGatheringState(ICEGatheringStateComplete); 562 changeIceGatheringState(ICEGatheringStateComplete);
551 changeSignalingState(SignalingStateClosed); 563 changeSignalingState(SignalingStateClosed);
552 } 564 }
553 565
554 void RTCPeerConnection::negotiationNeeded() 566 void RTCPeerConnection::negotiationNeeded()
555 { 567 {
568 ASSERT(!m_closed);
556 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); 569 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded));
557 } 570 }
558 571
559 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) 572 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate)
560 { 573 {
574 ASSERT(!m_closed);
561 ASSERT(executionContext()->isContextThread()); 575 ASSERT(executionContext()->isContextThread());
562 if (webCandidate.isNull()) 576 if (webCandidate.isNull())
563 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); 577 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr ));
564 else { 578 else {
565 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate); 579 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate);
566 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); 580 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release()));
567 } 581 }
568 } 582 }
569 583
570 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) 584 void RTCPeerConnection::didChangeSignalingState(SignalingState newState)
571 { 585 {
586 ASSERT(!m_closed);
572 ASSERT(executionContext()->isContextThread()); 587 ASSERT(executionContext()->isContextThread());
573 changeSignalingState(newState); 588 changeSignalingState(newState);
574 } 589 }
575 590
576 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) 591 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState)
577 { 592 {
593 ASSERT(!m_closed);
keishi 2014/06/16 08:06:35 When I run your patch locally I hit this assertion
Henrik Grunell 2014/06/16 08:34:38 Ah, right, it's a problem in the mock in Chromium.
578 ASSERT(executionContext()->isContextThread()); 594 ASSERT(executionContext()->isContextThread());
579 changeIceGatheringState(newState); 595 changeIceGatheringState(newState);
580 } 596 }
581 597
582 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) 598 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState)
583 { 599 {
600 ASSERT(!m_closed);
584 ASSERT(executionContext()->isContextThread()); 601 ASSERT(executionContext()->isContextThread());
585 changeIceConnectionState(newState); 602 changeIceConnectionState(newState);
586 } 603 }
587 604
588 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) 605 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream)
589 { 606 {
607 ASSERT(!m_closed);
590 ASSERT(executionContext()->isContextThread()); 608 ASSERT(executionContext()->isContextThread());
591 609
592 if (m_signalingState == SignalingStateClosed) 610 if (m_signalingState == SignalingStateClosed)
593 return; 611 return;
594 612
595 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream); 613 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream);
596 m_remoteStreams.append(stream); 614 m_remoteStreams.append(stream);
597 615
598 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); 616 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release()));
599 } 617 }
600 618
601 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) 619 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream)
602 { 620 {
621 ASSERT(!m_closed);
603 ASSERT(executionContext()->isContextThread()); 622 ASSERT(executionContext()->isContextThread());
604 623
605 MediaStreamDescriptor* streamDescriptor = remoteStream; 624 MediaStreamDescriptor* streamDescriptor = remoteStream;
606 ASSERT(streamDescriptor->client()); 625 ASSERT(streamDescriptor->client());
607 626
608 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client()); 627 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client());
609 stream->streamEnded(); 628 stream->streamEnded();
610 629
611 if (m_signalingState == SignalingStateClosed) 630 if (m_signalingState == SignalingStateClosed)
612 return; 631 return;
613 632
614 size_t pos = m_remoteStreams.find(stream); 633 size_t pos = m_remoteStreams.find(stream);
615 ASSERT(pos != kNotFound); 634 ASSERT(pos != kNotFound);
616 m_remoteStreams.remove(pos); 635 m_remoteStreams.remove(pos);
617 636
618 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); 637 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release()));
619 } 638 }
620 639
621 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) 640 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler)
622 { 641 {
642 ASSERT(!m_closed);
623 ASSERT(executionContext()->isContextThread()); 643 ASSERT(executionContext()->isContextThread());
624 644
625 if (m_signalingState == SignalingStateClosed) 645 if (m_signalingState == SignalingStateClosed)
626 return; 646 return;
627 647
628 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler)); 648 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler));
629 m_dataChannels.append(channel); 649 m_dataChannels.append(channel);
630 650
631 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); 651 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release()));
632 } 652 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 void RTCPeerConnection::trace(Visitor* visitor) 741 void RTCPeerConnection::trace(Visitor* visitor)
722 { 742 {
723 visitor->trace(m_localStreams); 743 visitor->trace(m_localStreams);
724 visitor->trace(m_remoteStreams); 744 visitor->trace(m_remoteStreams);
725 visitor->trace(m_dataChannels); 745 visitor->trace(m_dataChannels);
726 visitor->trace(m_scheduledEvents); 746 visitor->trace(m_scheduledEvents);
727 EventTargetWithInlineData::trace(visitor); 747 EventTargetWithInlineData::trace(visitor);
728 } 748 }
729 749
730 } // namespace WebCore 750 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698