| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 { | 121 { |
| 122 m_resolver->reject(); | 122 m_resolver->reject(); |
| 123 delete this; | 123 delete this; |
| 124 } | 124 } |
| 125 | 125 |
| 126 Persistent<ScriptPromiseResolver> m_resolver; | 126 Persistent<ScriptPromiseResolver> m_resolver; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 } // namespace | 129 } // namespace |
| 130 | 130 |
| 131 RTCPeerConnection::EventWrapper::EventWrapper( |
| 132 PassRefPtrWillBeRawPtr<Event> event, |
| 133 PassOwnPtrWillBeRawPtr<BoolFunction> function) |
| 134 : m_event(event) |
| 135 , m_setupFunction(function) |
| 136 { |
| 137 } |
| 138 |
| 139 bool RTCPeerConnection::EventWrapper::setup() |
| 140 { |
| 141 if (m_setupFunction) { |
| 142 return (*m_setupFunction)(); |
| 143 } |
| 144 return true; |
| 145 } |
| 146 |
| 131 RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
uration, ExceptionState& exceptionState) | 147 RTCConfiguration* RTCPeerConnection::parseConfiguration(const Dictionary& config
uration, ExceptionState& exceptionState) |
| 132 { | 148 { |
| 133 if (configuration.isUndefinedOrNull()) | 149 if (configuration.isUndefinedOrNull()) |
| 134 return 0; | 150 return 0; |
| 135 | 151 |
| 136 RTCIceTransports iceTransports = RTCIceTransportsAll; | 152 RTCIceTransports iceTransports = RTCIceTransportsAll; |
| 137 String iceTransportsString; | 153 String iceTransportsString; |
| 138 if (DictionaryHelper::get(configuration, "iceTransports", iceTransportsStrin
g)) { | 154 if (DictionaryHelper::get(configuration, "iceTransports", iceTransportsStrin
g)) { |
| 139 if (iceTransportsString == "none") { | 155 if (iceTransportsString == "none") { |
| 140 iceTransports = RTCIceTransportsNone; | 156 iceTransports = RTCIceTransportsNone; |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 m_signalingState = signalingState; | 968 m_signalingState = signalingState; |
| 953 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); | 969 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); |
| 954 } | 970 } |
| 955 } | 971 } |
| 956 | 972 |
| 957 void RTCPeerConnection::changeIceGatheringState(ICEGatheringState iceGatheringSt
ate) | 973 void RTCPeerConnection::changeIceGatheringState(ICEGatheringState iceGatheringSt
ate) |
| 958 { | 974 { |
| 959 m_iceGatheringState = iceGatheringState; | 975 m_iceGatheringState = iceGatheringState; |
| 960 } | 976 } |
| 961 | 977 |
| 978 bool RTCPeerConnection::setIceConnectionState(ICEConnectionState iceConnectionSt
ate) |
| 979 { |
| 980 if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { |
| 981 m_iceConnectionState = iceConnectionState; |
| 982 return true; |
| 983 } |
| 984 return false; |
| 985 } |
| 986 |
| 962 void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectio
nState) | 987 void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectio
nState) |
| 963 { | 988 { |
| 964 if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { | 989 if (m_iceConnectionState != ICEConnectionStateClosed) { |
| 965 m_iceConnectionState = iceConnectionState; | 990 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange), |
| 966 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange)); | 991 WTF::bind(&RTCPeerConnection::setIceConnectionState, this, iceConnec
tionState)); |
| 967 } | 992 } |
| 968 } | 993 } |
| 969 | 994 |
| 970 void RTCPeerConnection::closeInternal() | 995 void RTCPeerConnection::closeInternal() |
| 971 { | 996 { |
| 972 ASSERT(m_signalingState != RTCPeerConnection::SignalingStateClosed); | 997 ASSERT(m_signalingState != RTCPeerConnection::SignalingStateClosed); |
| 973 m_peerHandler->stop(); | 998 m_peerHandler->stop(); |
| 974 m_closed = true; | 999 m_closed = true; |
| 975 | 1000 |
| 976 changeIceConnectionState(ICEConnectionStateClosed); | 1001 changeIceConnectionState(ICEConnectionStateClosed); |
| 977 changeIceGatheringState(ICEGatheringStateComplete); | 1002 changeIceGatheringState(ICEGatheringStateComplete); |
| 978 changeSignalingState(SignalingStateClosed); | 1003 changeSignalingState(SignalingStateClosed); |
| 979 } | 1004 } |
| 980 | 1005 |
| 981 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t) | 1006 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t) |
| 982 { | 1007 { |
| 983 m_scheduledEvents.append(event); | 1008 scheduleDispatchEvent(event, nullptr); |
| 1009 } |
| 1010 |
| 1011 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t, |
| 1012 PassOwnPtrWillBeRawPtr<BoolFunction> setupFunction) |
| 1013 { |
| 1014 m_scheduledEvents.append(EventWrapper(event, setupFunction)); |
| 984 | 1015 |
| 985 m_dispatchScheduledEventRunner.runAsync(); | 1016 m_dispatchScheduledEventRunner.runAsync(); |
| 986 } | 1017 } |
| 987 | 1018 |
| 988 void RTCPeerConnection::dispatchScheduledEvent() | 1019 void RTCPeerConnection::dispatchScheduledEvent() |
| 989 { | 1020 { |
| 990 if (m_stopped) | 1021 if (m_stopped) |
| 991 return; | 1022 return; |
| 992 | 1023 |
| 993 WillBeHeapVector<RefPtrWillBeMember<Event>> events; | 1024 WillBeHeapVector<EventWrapper> events; |
| 994 events.swap(m_scheduledEvents); | 1025 events.swap(m_scheduledEvents); |
| 995 | 1026 |
| 996 WillBeHeapVector<RefPtrWillBeMember<Event>>::iterator it = events.begin(); | 1027 WillBeHeapVector<EventWrapper>::iterator it = events.begin(); |
| 997 for (; it != events.end(); ++it) | 1028 for (; it != events.end(); ++it) { |
| 998 dispatchEvent((*it).release()); | 1029 if ((*it).setup()) { |
| 1030 dispatchEvent((*it).m_event.release()); |
| 1031 } |
| 1032 } |
| 999 | 1033 |
| 1000 events.clear(); | 1034 events.clear(); |
| 1001 } | 1035 } |
| 1002 | 1036 |
| 1003 DEFINE_TRACE(RTCPeerConnection) | 1037 DEFINE_TRACE(RTCPeerConnection) |
| 1004 { | 1038 { |
| 1005 visitor->trace(m_localStreams); | 1039 visitor->trace(m_localStreams); |
| 1006 visitor->trace(m_remoteStreams); | 1040 visitor->trace(m_remoteStreams); |
| 1007 visitor->trace(m_dataChannels); | 1041 visitor->trace(m_dataChannels); |
| 1008 visitor->trace(m_scheduledEvents); | 1042 visitor->trace(m_scheduledEvents); |
| 1009 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1043 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
| 1010 ActiveDOMObject::trace(visitor); | 1044 ActiveDOMObject::trace(visitor); |
| 1011 } | 1045 } |
| 1012 | 1046 |
| 1013 } // namespace blink | 1047 } // namespace blink |
| OLD | NEW |