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

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

Issue 1010393002: Fix issue of localDescription and remoteDescription getter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: ActiveDomObject. Created 5 years, 8 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 268 }
269 269
270 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); 270 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get());
271 271
272 if (!m_peerHandler->initialize(configuration, constraints)) { 272 if (!m_peerHandler->initialize(configuration, constraints)) {
273 m_closed = true; 273 m_closed = true;
274 m_stopped = true; 274 m_stopped = true;
275 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); 275 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection.");
276 return; 276 return;
277 } 277 }
278 m_localDescription = RTCSessionDescription::create(context, m_peerHandler->l ocalDescription());
279 m_remoteDescription = RTCSessionDescription::create(context, m_peerHandler-> remoteDescription());
278 } 280 }
279 281
280 RTCPeerConnection::~RTCPeerConnection() 282 RTCPeerConnection::~RTCPeerConnection()
281 { 283 {
282 // This checks that close() or stop() is called before the destructor. 284 // This checks that close() or stop() is called before the destructor.
283 // We are assuming that a wrapper is always created when RTCPeerConnection i s created. 285 // We are assuming that a wrapper is always created when RTCPeerConnection i s created.
284 ASSERT(m_closed || m_stopped); 286 ASSERT(m_closed || m_stopped);
285 } 287 }
286 288
287 void RTCPeerConnection::createOffer(RTCSessionDescriptionCallback* successCallba ck, RTCErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, Exceptio nState& exceptionState) 289 void RTCPeerConnection::createOffer(RTCSessionDescriptionCallback* successCallba ck, RTCErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, Exceptio nState& exceptionState)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 337
336 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 338 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
337 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription()); 339 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe scription());
338 } 340 }
339 341
340 RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& excep tionState) 342 RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& excep tionState)
341 { 343 {
342 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion(); 344 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion();
343 if (webSessionDescription.isNull()) 345 if (webSessionDescription.isNull())
344 return nullptr; 346 return nullptr;
345 347 m_localDescription->setWebSessionDescription(webSessionDescription);
Jens Widell 2015/04/28 10:59:22 I think the semantics might be somewhat incorrect
346 return RTCSessionDescription::create(webSessionDescription); 348 return m_localDescription;
347 } 349 }
348 350
349 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio nState& exceptionState) 351 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio nState& exceptionState)
350 { 352 {
351 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 353 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
352 return; 354 return;
353 355
354 if (!sessionDescription) { 356 if (!sessionDescription) {
355 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 357 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
356 return; 358 return;
357 } 359 }
358 360
359 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 361 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
360 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription()); 362 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription());
361 } 363 }
362 364
363 RTCSessionDescription* RTCPeerConnection::remoteDescription(ExceptionState& exce ptionState) 365 RTCSessionDescription* RTCPeerConnection::remoteDescription(ExceptionState& exce ptionState)
364 { 366 {
365 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption(); 367 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption();
366 if (webSessionDescription.isNull()) 368 if (webSessionDescription.isNull())
367 return nullptr; 369 return nullptr;
370 m_remoteDescription->setWebSessionDescription(webSessionDescription);
368 371
369 return RTCSessionDescription::create(webSessionDescription); 372 return m_remoteDescription;
370 } 373 }
371 374
372 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) 375 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState)
373 { 376 {
374 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 377 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
375 return; 378 return;
376 379
377 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep tionState); 380 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep tionState);
378 if (exceptionState.hadException()) 381 if (exceptionState.hadException())
379 return; 382 return;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 m_iceConnectionState = ICEConnectionStateClosed; 758 m_iceConnectionState = ICEConnectionStateClosed;
756 m_signalingState = SignalingStateClosed; 759 m_signalingState = SignalingStateClosed;
757 760
758 HeapVector<Member<RTCDataChannel>>::iterator i = m_dataChannels.begin(); 761 HeapVector<Member<RTCDataChannel>>::iterator i = m_dataChannels.begin();
759 for (; i != m_dataChannels.end(); ++i) 762 for (; i != m_dataChannels.end(); ++i)
760 (*i)->stop(); 763 (*i)->stop();
761 m_dataChannels.clear(); 764 m_dataChannels.clear();
762 765
763 m_dispatchScheduledEventRunner.stop(); 766 m_dispatchScheduledEventRunner.stop();
764 767
768 m_localDescription->stop();
769 m_remoteDescription->stop();
770
765 m_peerHandler.clear(); 771 m_peerHandler.clear();
766 } 772 }
767 773
768 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) 774 void RTCPeerConnection::changeSignalingState(SignalingState signalingState)
769 { 775 {
770 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { 776 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) {
771 m_signalingState = signalingState; 777 m_signalingState = signalingState;
772 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange )); 778 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange ));
773 } 779 }
774 } 780 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 dispatchEvent((*it).release()); 823 dispatchEvent((*it).release());
818 824
819 events.clear(); 825 events.clear();
820 } 826 }
821 827
822 DEFINE_TRACE(RTCPeerConnection) 828 DEFINE_TRACE(RTCPeerConnection)
823 { 829 {
824 visitor->trace(m_localStreams); 830 visitor->trace(m_localStreams);
825 visitor->trace(m_remoteStreams); 831 visitor->trace(m_remoteStreams);
826 visitor->trace(m_dataChannels); 832 visitor->trace(m_dataChannels);
833 visitor->trace(m_localDescription);
834 visitor->trace(m_remoteDescription);
827 #if ENABLE(OILPAN) 835 #if ENABLE(OILPAN)
828 visitor->trace(m_scheduledEvents); 836 visitor->trace(m_scheduledEvents);
829 #endif 837 #endif
830 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 838 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
831 ActiveDOMObject::trace(visitor); 839 ActiveDOMObject::trace(visitor);
832 } 840 }
833 841
834 } // namespace blink 842 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698