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

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

Issue 85263006: Make IDL Callbacks non-refcounted by default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 years 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r); 159 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro r);
160 return; 160 return;
161 } 161 }
162 } 162 }
163 163
164 RTCPeerConnection::~RTCPeerConnection() 164 RTCPeerConnection::~RTCPeerConnection()
165 { 165 {
166 stop(); 166 stop();
167 } 167 }
168 168
169 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) 169 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState)
170 { 170 {
171 if (m_signalingState == SignalingStateClosed) { 171 if (m_signalingState == SignalingStateClosed) {
172 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 172 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
173 return; 173 return;
174 } 174 }
175 175
176 if (!successCallback) { 176 if (!successCallback) {
177 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 177 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
178 return; 178 return;
179 } 179 }
180 180
181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState); 181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
182 if (exceptionState.hadException()) 182 if (exceptionState.hadException())
183 return; 183 return;
184 184
185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback); 185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback);
186 m_peerHandler->createOffer(request.release(), constraints); 186 m_peerHandler->createOffer(request.release(), constraints);
187 } 187 }
188 188
189 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState) 189 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState)
190 { 190 {
191 if (m_signalingState == SignalingStateClosed) { 191 if (m_signalingState == SignalingStateClosed) {
192 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 192 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
193 return; 193 return;
194 } 194 }
195 195
196 if (!successCallback) { 196 if (!successCallback) {
197 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 197 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
198 return; 198 return;
199 } 199 }
200 200
201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState); 201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon straints, exceptionState);
202 if (exceptionState.hadException()) 202 if (exceptionState.hadException())
203 return; 203 return;
204 204
205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback); 205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ estImpl::create(executionContext(), successCallback, errorCallback);
206 m_peerHandler->createAnswer(request.release(), constraints.release()); 206 m_peerHandler->createAnswer(request.release(), constraints.release());
207 } 207 }
208 208
209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState) 209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState)
210 { 210 {
211 if (m_signalingState == SignalingStateClosed) { 211 if (m_signalingState == SignalingStateClosed) {
212 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 212 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
213 return; 213 return;
214 } 214 }
215 215
216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
217 if (!sessionDescription) { 217 if (!sessionDescription) {
218 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 218 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
219 return; 219 return;
220 } 220 }
221 221
222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback); 222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(executionCon text(), successCallback, errorCallback);
223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
224 } 224 }
225 225
226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState) 226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState)
227 { 227 {
228 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); 228 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description();
229 if (webSessionDescription.isNull()) 229 if (webSessionDescription.isNull())
230 return 0; 230 return 0;
231 231
232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); 232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription);
233 return sessionDescription.release(); 233 return sessionDescription.release();
234 } 234 }
235 235
236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState) 236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState)
237 { 237 {
238 if (m_signalingState == SignalingStateClosed) { 238 if (m_signalingState == SignalingStateClosed) {
239 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 239 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
240 return; 240 return;
241 } 241 }
242 242
243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription;
244 if (!sessionDescription) { 244 if (!sessionDescription) {
245 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 245 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
246 return; 246 return;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (!iceCandidate) { 290 if (!iceCandidate) {
291 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 291 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
292 return; 292 return;
293 } 293 }
294 294
295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate()); 295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate());
296 if (!valid) 296 if (!valid)
297 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); 297 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError);
298 } 298 }
299 299
300 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassRefPtr<RTCErrorCallback> errorCallback, Exc eptionState& exceptionState) 300 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassRefPt r<VoidCallback> successCallback, PassOwnPtr<RTCErrorCallback> errorCallback, Exc eptionState& exceptionState)
301 { 301 {
302 if (m_signalingState == SignalingStateClosed) { 302 if (m_signalingState == SignalingStateClosed) {
303 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 303 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
304 return; 304 return;
305 } 305 }
306 306
307 if (!iceCandidate || !successCallback || !errorCallback) { 307 if (!iceCandidate || !successCallback || !errorCallback) {
308 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r); 308 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro r);
309 return; 309 return;
310 } 310 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 443 }
444 444
445 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { 445 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) {
446 if ((*iter)->id() == streamId) 446 if ((*iter)->id() == streamId)
447 return iter->get(); 447 return iter->get();
448 } 448 }
449 449
450 return 0; 450 return 0;
451 } 451 }
452 452
453 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 453 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
454 { 454 {
455 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(execu tionContext(), successCallback, selector); 455 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(execu tionContext(), successCallback, selector);
456 // FIXME: Add passing selector as part of the statsRequest. 456 // FIXME: Add passing selector as part of the statsRequest.
457 m_peerHandler->getStats(statsRequest.release()); 457 m_peerHandler->getStats(statsRequest.release());
458 } 458 }
459 459
460 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState) 460 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState)
461 { 461 {
462 if (m_signalingState == SignalingStateClosed) { 462 if (m_signalingState == SignalingStateClosed) {
463 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r); 463 exceptionState.throwUninformativeAndGenericDOMException(InvalidStateErro r);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 events.swap(m_scheduledEvents); 686 events.swap(m_scheduledEvents);
687 687
688 Vector<RefPtr<Event> >::iterator it = events.begin(); 688 Vector<RefPtr<Event> >::iterator it = events.begin();
689 for (; it != events.end(); ++it) 689 for (; it != events.end(); ++it)
690 dispatchEvent((*it).release()); 690 dispatchEvent((*it).release());
691 691
692 events.clear(); 692 events.clear();
693 } 693 }
694 694
695 } // namespace WebCore 695 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/mediastream/RTCPeerConnection.h ('k') | Source/modules/mediastream/RTCSessionDescriptionCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698