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

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: Use SetWrapperReferenceTo. Created 5 years, 7 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(m_peerHandler->localDescr iption());
279 m_remoteDescription = RTCSessionDescription::create(m_peerHandler->remoteDes cription());
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 330 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
329 return; 331 return;
330 332
331 if (!sessionDescription) { 333 if (!sessionDescription) {
332 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 334 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
333 return; 335 return;
334 } 336 }
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());
340 m_localDescription = sessionDescription;
338 } 341 }
339 342
340 RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& excep tionState) 343 RTCSessionDescription* RTCPeerConnection::localDescription()
341 { 344 {
345 if (!m_peerHandler)
346 return nullptr;
342 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion(); 347 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip tion();
343 if (webSessionDescription.isNull()) 348 if (webSessionDescription.isNull())
344 return nullptr; 349 return nullptr;
345 350
346 return RTCSessionDescription::create(webSessionDescription); 351 if (!m_localDescription || m_localDescription->webSessionDescription() != we bSessionDescription) {
352 m_localDescription = RTCSessionDescription::create(webSessionDescription );
353 }
354 return m_localDescription;
347 } 355 }
348 356
349 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio nState& exceptionState) 357 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio nState& exceptionState)
350 { 358 {
351 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 359 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
352 return; 360 return;
353 361
354 if (!sessionDescription) { 362 if (!sessionDescription) {
355 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); 363 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription"));
356 return; 364 return;
357 } 365 }
358 366
359 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback); 367 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi s, successCallback, errorCallback);
360 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription()); 368 m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionD escription());
369 m_remoteDescription = sessionDescription;
Jens Widell 2015/05/04 06:44:23 I'm unsure exactly how things work here, but I sus
changbin 2015/05/04 10:12:23 Agree and thanks:) Current implemention will give
Jens Widell 2015/05/04 10:20:50 Now you no longer keep the object passed to setRem
361 } 370 }
362 371
363 RTCSessionDescription* RTCPeerConnection::remoteDescription(ExceptionState& exce ptionState) 372 RTCSessionDescription* RTCPeerConnection::remoteDescription()
364 { 373 {
374 if (!m_peerHandler)
375 return nullptr;
365 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption(); 376 WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescri ption();
366 if (webSessionDescription.isNull()) 377 if (webSessionDescription.isNull())
367 return nullptr; 378 return nullptr;
368 379
369 return RTCSessionDescription::create(webSessionDescription); 380 if (!m_remoteDescription || m_remoteDescription->webSessionDescription() != webSessionDescription) {
381 m_remoteDescription = RTCSessionDescription::create(webSessionDescriptio n);
382 }
383 return m_remoteDescription;
370 } 384 }
371 385
372 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) 386 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState)
373 { 387 {
374 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 388 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
375 return; 389 return;
376 390
377 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep tionState); 391 RTCConfiguration* configuration = parseConfiguration(rtcConfiguration, excep tionState);
378 if (exceptionState.hadException()) 392 if (exceptionState.hadException())
379 return; 393 return;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 dispatchEvent((*it).release()); 831 dispatchEvent((*it).release());
818 832
819 events.clear(); 833 events.clear();
820 } 834 }
821 835
822 DEFINE_TRACE(RTCPeerConnection) 836 DEFINE_TRACE(RTCPeerConnection)
823 { 837 {
824 visitor->trace(m_localStreams); 838 visitor->trace(m_localStreams);
825 visitor->trace(m_remoteStreams); 839 visitor->trace(m_remoteStreams);
826 visitor->trace(m_dataChannels); 840 visitor->trace(m_dataChannels);
841 visitor->trace(m_localDescription);
842 visitor->trace(m_remoteDescription);
827 #if ENABLE(OILPAN) 843 #if ENABLE(OILPAN)
828 visitor->trace(m_scheduledEvents); 844 visitor->trace(m_scheduledEvents);
829 #endif 845 #endif
830 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); 846 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor);
831 ActiveDOMObject::trace(visitor); 847 ActiveDOMObject::trace(visitor);
832 } 848 }
833 849
834 } // namespace blink 850 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCPeerConnection.h ('k') | Source/modules/mediastream/RTCPeerConnection.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698