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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/mediastream/RTCPeerConnection.h ('k') | Source/modules/mediastream/RTCPeerConnection.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediastream/RTCPeerConnection.cpp
diff --git a/Source/modules/mediastream/RTCPeerConnection.cpp b/Source/modules/mediastream/RTCPeerConnection.cpp
index 51a5d99241a3b761e296aeab803183121f94da90..54d847684b922b40a6e12e7ddca4190ed554134b 100644
--- a/Source/modules/mediastream/RTCPeerConnection.cpp
+++ b/Source/modules/mediastream/RTCPeerConnection.cpp
@@ -275,6 +275,8 @@ RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration
exceptionState.throwDOMException(NotSupportedError, "Failed to initialize native PeerConnection.");
return;
}
+ m_localDescription = RTCSessionDescription::create(m_peerHandler->localDescription());
+ m_remoteDescription = RTCSessionDescription::create(m_peerHandler->remoteDescription());
}
RTCPeerConnection::~RTCPeerConnection()
@@ -335,15 +337,21 @@ void RTCPeerConnection::setLocalDescription(RTCSessionDescription* sessionDescri
RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), this, successCallback, errorCallback);
m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDescription());
+ m_localDescription = sessionDescription;
}
-RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& exceptionState)
+RTCSessionDescription* RTCPeerConnection::localDescription()
{
+ if (!m_peerHandler)
+ return nullptr;
WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescription();
if (webSessionDescription.isNull())
return nullptr;
- return RTCSessionDescription::create(webSessionDescription);
+ if (!m_localDescription || m_localDescription->webSessionDescription() != webSessionDescription) {
+ m_localDescription = RTCSessionDescription::create(webSessionDescription);
+ }
+ return m_localDescription;
}
void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallback* errorCallback, ExceptionState& exceptionState)
@@ -358,15 +366,21 @@ void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr
RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), this, successCallback, errorCallback);
m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionDescription());
+ 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
}
-RTCSessionDescription* RTCPeerConnection::remoteDescription(ExceptionState& exceptionState)
+RTCSessionDescription* RTCPeerConnection::remoteDescription()
{
+ if (!m_peerHandler)
+ return nullptr;
WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescription();
if (webSessionDescription.isNull())
return nullptr;
- return RTCSessionDescription::create(webSessionDescription);
+ if (!m_remoteDescription || m_remoteDescription->webSessionDescription() != webSessionDescription) {
+ m_remoteDescription = RTCSessionDescription::create(webSessionDescription);
+ }
+ return m_remoteDescription;
}
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
@@ -824,6 +838,8 @@ DEFINE_TRACE(RTCPeerConnection)
visitor->trace(m_localStreams);
visitor->trace(m_remoteStreams);
visitor->trace(m_dataChannels);
+ visitor->trace(m_localDescription);
+ visitor->trace(m_remoteDescription);
#if ENABLE(OILPAN)
visitor->trace(m_scheduledEvents);
#endif
« 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