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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return 0; | 340 return 0; |
341 | 341 |
342 return peerConnection; | 342 return peerConnection; |
343 } | 343 } |
344 | 344 |
345 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration
* configuration, WebMediaConstraints constraints, ExceptionState& exceptionState
) | 345 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration
* configuration, WebMediaConstraints constraints, ExceptionState& exceptionState
) |
346 : ActiveDOMObject(context) | 346 : ActiveDOMObject(context) |
347 , m_signalingState(SignalingStateStable) | 347 , m_signalingState(SignalingStateStable) |
348 , m_iceGatheringState(ICEGatheringStateNew) | 348 , m_iceGatheringState(ICEGatheringStateNew) |
349 , m_iceConnectionState(ICEConnectionStateNew) | 349 , m_iceConnectionState(ICEConnectionStateNew) |
350 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled
Event) | 350 , m_dispatchScheduledEventRunner(AsyncMethodRunner<RTCPeerConnection>::creat
e(this, &RTCPeerConnection::dispatchScheduledEvent)) |
351 , m_stopped(false) | 351 , m_stopped(false) |
352 , m_closed(false) | 352 , m_closed(false) |
353 { | 353 { |
354 Document* document = toDocument(executionContext()); | 354 Document* document = toDocument(executionContext()); |
355 | 355 |
356 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
assert in the destructor. | 356 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
assert in the destructor. |
357 | 357 |
358 if (!document->frame()) { | 358 if (!document->frame()) { |
359 m_closed = true; | 359 m_closed = true; |
360 m_stopped = true; | 360 m_stopped = true; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 return EventTargetNames::RTCPeerConnection; | 932 return EventTargetNames::RTCPeerConnection; |
933 } | 933 } |
934 | 934 |
935 ExecutionContext* RTCPeerConnection::executionContext() const | 935 ExecutionContext* RTCPeerConnection::executionContext() const |
936 { | 936 { |
937 return ActiveDOMObject::executionContext(); | 937 return ActiveDOMObject::executionContext(); |
938 } | 938 } |
939 | 939 |
940 void RTCPeerConnection::suspend() | 940 void RTCPeerConnection::suspend() |
941 { | 941 { |
942 m_dispatchScheduledEventRunner.suspend(); | 942 m_dispatchScheduledEventRunner->suspend(); |
943 } | 943 } |
944 | 944 |
945 void RTCPeerConnection::resume() | 945 void RTCPeerConnection::resume() |
946 { | 946 { |
947 m_dispatchScheduledEventRunner.resume(); | 947 m_dispatchScheduledEventRunner->resume(); |
948 } | 948 } |
949 | 949 |
950 void RTCPeerConnection::stop() | 950 void RTCPeerConnection::stop() |
951 { | 951 { |
952 if (m_stopped) | 952 if (m_stopped) |
953 return; | 953 return; |
954 | 954 |
955 m_stopped = true; | 955 m_stopped = true; |
956 m_iceConnectionState = ICEConnectionStateClosed; | 956 m_iceConnectionState = ICEConnectionStateClosed; |
957 m_signalingState = SignalingStateClosed; | 957 m_signalingState = SignalingStateClosed; |
958 | 958 |
959 HeapVector<Member<RTCDataChannel>>::iterator i = m_dataChannels.begin(); | 959 HeapVector<Member<RTCDataChannel>>::iterator i = m_dataChannels.begin(); |
960 for (; i != m_dataChannels.end(); ++i) | 960 for (; i != m_dataChannels.end(); ++i) |
961 (*i)->stop(); | 961 (*i)->stop(); |
962 m_dataChannels.clear(); | 962 m_dataChannels.clear(); |
963 | 963 |
964 m_dispatchScheduledEventRunner.stop(); | 964 m_dispatchScheduledEventRunner->stop(); |
965 | 965 |
966 m_peerHandler.clear(); | 966 m_peerHandler.clear(); |
967 } | 967 } |
968 | 968 |
969 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) | 969 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) |
970 { | 970 { |
971 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin
gState) { | 971 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin
gState) { |
972 m_signalingState = signalingState; | 972 m_signalingState = signalingState; |
973 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); | 973 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); |
974 } | 974 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t) | 1010 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t) |
1011 { | 1011 { |
1012 scheduleDispatchEvent(event, nullptr); | 1012 scheduleDispatchEvent(event, nullptr); |
1013 } | 1013 } |
1014 | 1014 |
1015 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t, | 1015 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event> even
t, |
1016 PassOwnPtr<BoolFunction> setupFunction) | 1016 PassOwnPtr<BoolFunction> setupFunction) |
1017 { | 1017 { |
1018 m_scheduledEvents.append(new EventWrapper(event, setupFunction)); | 1018 m_scheduledEvents.append(new EventWrapper(event, setupFunction)); |
1019 | 1019 |
1020 m_dispatchScheduledEventRunner.runAsync(); | 1020 m_dispatchScheduledEventRunner->runAsync(); |
1021 } | 1021 } |
1022 | 1022 |
1023 void RTCPeerConnection::dispatchScheduledEvent() | 1023 void RTCPeerConnection::dispatchScheduledEvent() |
1024 { | 1024 { |
1025 if (m_stopped) | 1025 if (m_stopped) |
1026 return; | 1026 return; |
1027 | 1027 |
1028 HeapVector<Member<EventWrapper>> events; | 1028 HeapVector<Member<EventWrapper>> events; |
1029 events.swap(m_scheduledEvents); | 1029 events.swap(m_scheduledEvents); |
1030 | 1030 |
1031 HeapVector<Member<EventWrapper>>::iterator it = events.begin(); | 1031 HeapVector<Member<EventWrapper>>::iterator it = events.begin(); |
1032 for (; it != events.end(); ++it) { | 1032 for (; it != events.end(); ++it) { |
1033 if ((*it)->setup()) { | 1033 if ((*it)->setup()) { |
1034 dispatchEvent((*it)->m_event.release()); | 1034 dispatchEvent((*it)->m_event.release()); |
1035 } | 1035 } |
1036 } | 1036 } |
1037 | 1037 |
1038 events.clear(); | 1038 events.clear(); |
1039 } | 1039 } |
1040 | 1040 |
1041 DEFINE_TRACE(RTCPeerConnection) | 1041 DEFINE_TRACE(RTCPeerConnection) |
1042 { | 1042 { |
1043 visitor->trace(m_localStreams); | 1043 visitor->trace(m_localStreams); |
1044 visitor->trace(m_remoteStreams); | 1044 visitor->trace(m_remoteStreams); |
1045 visitor->trace(m_dataChannels); | 1045 visitor->trace(m_dataChannels); |
| 1046 visitor->trace(m_dispatchScheduledEventRunner); |
1046 visitor->trace(m_scheduledEvents); | 1047 visitor->trace(m_scheduledEvents); |
1047 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); | 1048 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac
e(visitor); |
1048 ActiveDOMObject::trace(visitor); | 1049 ActiveDOMObject::trace(visitor); |
1049 } | 1050 } |
1050 | 1051 |
1051 } // namespace blink | 1052 } // namespace blink |
OLD | NEW |