| OLD | NEW |
| 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 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 return; | 1324 return; |
| 1325 | 1325 |
| 1326 RTCDataChannel* channel = | 1326 RTCDataChannel* channel = |
| 1327 RTCDataChannel::create(getExecutionContext(), WTF::wrapUnique(handler)); | 1327 RTCDataChannel::create(getExecutionContext(), WTF::wrapUnique(handler)); |
| 1328 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachannel, | 1328 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachannel, |
| 1329 false, false, channel)); | 1329 false, false, channel)); |
| 1330 m_hasDataChannels = true; | 1330 m_hasDataChannels = true; |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 void RTCPeerConnection::releasePeerConnectionHandler() { | 1333 void RTCPeerConnection::releasePeerConnectionHandler() { |
| 1334 contextDestroyed(); | 1334 if (m_stopped) |
| 1335 return; |
| 1336 |
| 1337 m_stopped = true; |
| 1338 m_iceConnectionState = ICEConnectionStateClosed; |
| 1339 m_signalingState = SignalingStateClosed; |
| 1340 |
| 1341 m_dispatchScheduledEventRunner->stop(); |
| 1342 |
| 1343 m_peerHandler.reset(); |
| 1335 } | 1344 } |
| 1336 | 1345 |
| 1337 void RTCPeerConnection::closePeerConnection() { | 1346 void RTCPeerConnection::closePeerConnection() { |
| 1338 DCHECK(m_signalingState != RTCPeerConnection::SignalingStateClosed); | 1347 DCHECK(m_signalingState != RTCPeerConnection::SignalingStateClosed); |
| 1339 closeInternal(); | 1348 closeInternal(); |
| 1340 } | 1349 } |
| 1341 | 1350 |
| 1342 const AtomicString& RTCPeerConnection::interfaceName() const { | 1351 const AtomicString& RTCPeerConnection::interfaceName() const { |
| 1343 return EventTargetNames::RTCPeerConnection; | 1352 return EventTargetNames::RTCPeerConnection; |
| 1344 } | 1353 } |
| 1345 | 1354 |
| 1346 ExecutionContext* RTCPeerConnection::getExecutionContext() const { | 1355 ExecutionContext* RTCPeerConnection::getExecutionContext() const { |
| 1347 return SuspendableObject::getExecutionContext(); | 1356 return SuspendableObject::getExecutionContext(); |
| 1348 } | 1357 } |
| 1349 | 1358 |
| 1350 void RTCPeerConnection::suspend() { | 1359 void RTCPeerConnection::suspend() { |
| 1351 m_dispatchScheduledEventRunner->suspend(); | 1360 m_dispatchScheduledEventRunner->suspend(); |
| 1352 } | 1361 } |
| 1353 | 1362 |
| 1354 void RTCPeerConnection::resume() { | 1363 void RTCPeerConnection::resume() { |
| 1355 m_dispatchScheduledEventRunner->resume(); | 1364 m_dispatchScheduledEventRunner->resume(); |
| 1356 } | 1365 } |
| 1357 | 1366 |
| 1358 void RTCPeerConnection::contextDestroyed() { | 1367 void RTCPeerConnection::contextDestroyed(ExecutionContext*) { |
| 1359 if (m_stopped) | 1368 releasePeerConnectionHandler(); |
| 1360 return; | |
| 1361 | |
| 1362 m_stopped = true; | |
| 1363 m_iceConnectionState = ICEConnectionStateClosed; | |
| 1364 m_signalingState = SignalingStateClosed; | |
| 1365 | |
| 1366 m_dispatchScheduledEventRunner->stop(); | |
| 1367 | |
| 1368 m_peerHandler.reset(); | |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) { | 1371 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) { |
| 1372 if (m_signalingState != SignalingStateClosed && | 1372 if (m_signalingState != SignalingStateClosed && |
| 1373 m_signalingState != signalingState) { | 1373 m_signalingState != signalingState) { |
| 1374 m_signalingState = signalingState; | 1374 m_signalingState = signalingState; |
| 1375 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange)); | 1375 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange)); |
| 1376 } | 1376 } |
| 1377 } | 1377 } |
| 1378 | 1378 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 DEFINE_TRACE(RTCPeerConnection) { | 1472 DEFINE_TRACE(RTCPeerConnection) { |
| 1473 visitor->trace(m_localStreams); | 1473 visitor->trace(m_localStreams); |
| 1474 visitor->trace(m_remoteStreams); | 1474 visitor->trace(m_remoteStreams); |
| 1475 visitor->trace(m_dispatchScheduledEventRunner); | 1475 visitor->trace(m_dispatchScheduledEventRunner); |
| 1476 visitor->trace(m_scheduledEvents); | 1476 visitor->trace(m_scheduledEvents); |
| 1477 EventTargetWithInlineData::trace(visitor); | 1477 EventTargetWithInlineData::trace(visitor); |
| 1478 SuspendableObject::trace(visitor); | 1478 SuspendableObject::trace(visitor); |
| 1479 } | 1479 } |
| 1480 | 1480 |
| 1481 } // namespace blink | 1481 } // namespace blink |
| OLD | NEW |