| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return 0; | 130 return 0; |
| 131 | 131 |
| 132 return peerConnection.release(); | 132 return peerConnection.release(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo
nfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionS
tate& es) | 135 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo
nfiguration> configuration, PassRefPtr<MediaConstraints> constraints, ExceptionS
tate& es) |
| 136 : ActiveDOMObject(context) | 136 : ActiveDOMObject(context) |
| 137 , m_signalingState(SignalingStateStable) | 137 , m_signalingState(SignalingStateStable) |
| 138 , m_iceGatheringState(IceGatheringStateNew) | 138 , m_iceGatheringState(IceGatheringStateNew) |
| 139 , m_iceConnectionState(IceConnectionStateNew) | 139 , m_iceConnectionState(IceConnectionStateNew) |
| 140 , m_scheduledEventTimer(this, &RTCPeerConnection::scheduledEventTimerFired) | 140 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled
Event) |
| 141 , m_stopped(false) | 141 , m_stopped(false) |
| 142 { | 142 { |
| 143 ScriptWrappable::init(this); | 143 ScriptWrappable::init(this); |
| 144 Document* document = toDocument(executionContext()); | 144 Document* document = toDocument(executionContext()); |
| 145 | 145 |
| 146 if (!document->frame()) { | 146 if (!document->frame()) { |
| 147 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 147 es.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 148 return; | 148 return; |
| 149 } | 149 } |
| 150 | 150 |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 const AtomicString& RTCPeerConnection::interfaceName() const | 617 const AtomicString& RTCPeerConnection::interfaceName() const |
| 618 { | 618 { |
| 619 return EventTargetNames::RTCPeerConnection; | 619 return EventTargetNames::RTCPeerConnection; |
| 620 } | 620 } |
| 621 | 621 |
| 622 ExecutionContext* RTCPeerConnection::executionContext() const | 622 ExecutionContext* RTCPeerConnection::executionContext() const |
| 623 { | 623 { |
| 624 return ActiveDOMObject::executionContext(); | 624 return ActiveDOMObject::executionContext(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 void RTCPeerConnection::suspend() |
| 628 { |
| 629 m_dispatchScheduledEventRunner.suspend(); |
| 630 } |
| 631 |
| 632 void RTCPeerConnection::resume() |
| 633 { |
| 634 m_dispatchScheduledEventRunner.resume(); |
| 635 } |
| 636 |
| 627 void RTCPeerConnection::stop() | 637 void RTCPeerConnection::stop() |
| 628 { | 638 { |
| 629 if (m_stopped) | 639 if (m_stopped) |
| 630 return; | 640 return; |
| 631 | 641 |
| 632 m_stopped = true; | 642 m_stopped = true; |
| 633 m_iceConnectionState = IceConnectionStateClosed; | 643 m_iceConnectionState = IceConnectionStateClosed; |
| 634 m_signalingState = SignalingStateClosed; | 644 m_signalingState = SignalingStateClosed; |
| 635 | 645 |
| 636 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); | 646 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); |
| 637 for (; i != m_dataChannels.end(); ++i) | 647 for (; i != m_dataChannels.end(); ++i) |
| 638 (*i)->stop(); | 648 (*i)->stop(); |
| 649 |
| 650 m_dispatchScheduledEventRunner.stop(); |
| 639 } | 651 } |
| 640 | 652 |
| 641 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) | 653 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) |
| 642 { | 654 { |
| 643 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin
gState) { | 655 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin
gState) { |
| 644 m_signalingState = signalingState; | 656 m_signalingState = signalingState; |
| 645 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); | 657 scheduleDispatchEvent(Event::create(EventTypeNames::signalingstatechange
)); |
| 646 } | 658 } |
| 647 } | 659 } |
| 648 | 660 |
| 649 void RTCPeerConnection::changeIceGatheringState(IceGatheringState iceGatheringSt
ate) | 661 void RTCPeerConnection::changeIceGatheringState(IceGatheringState iceGatheringSt
ate) |
| 650 { | 662 { |
| 651 m_iceGatheringState = iceGatheringState; | 663 m_iceGatheringState = iceGatheringState; |
| 652 } | 664 } |
| 653 | 665 |
| 654 void RTCPeerConnection::changeIceConnectionState(IceConnectionState iceConnectio
nState) | 666 void RTCPeerConnection::changeIceConnectionState(IceConnectionState iceConnectio
nState) |
| 655 { | 667 { |
| 656 if (m_iceConnectionState != IceConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { | 668 if (m_iceConnectionState != IceConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { |
| 657 m_iceConnectionState = iceConnectionState; | 669 m_iceConnectionState = iceConnectionState; |
| 658 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange)); | 670 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange)); |
| 659 } | 671 } |
| 660 } | 672 } |
| 661 | 673 |
| 662 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtr<Event> event) | 674 void RTCPeerConnection::scheduleDispatchEvent(PassRefPtr<Event> event) |
| 663 { | 675 { |
| 664 m_scheduledEvents.append(event); | 676 m_scheduledEvents.append(event); |
| 665 | 677 |
| 666 if (!m_scheduledEventTimer.isActive()) | 678 m_dispatchScheduledEventRunner.runAsync(); |
| 667 m_scheduledEventTimer.startOneShot(0); | |
| 668 } | 679 } |
| 669 | 680 |
| 670 void RTCPeerConnection::scheduledEventTimerFired(Timer<RTCPeerConnection>*) | 681 void RTCPeerConnection::dispatchScheduledEvent() |
| 671 { | 682 { |
| 672 if (m_stopped) | 683 if (m_stopped) |
| 673 return; | 684 return; |
| 674 | 685 |
| 675 Vector<RefPtr<Event> > events; | 686 Vector<RefPtr<Event> > events; |
| 676 events.swap(m_scheduledEvents); | 687 events.swap(m_scheduledEvents); |
| 677 | 688 |
| 678 Vector<RefPtr<Event> >::iterator it = events.begin(); | 689 Vector<RefPtr<Event> >::iterator it = events.begin(); |
| 679 for (; it != events.end(); ++it) | 690 for (; it != events.end(); ++it) |
| 680 dispatchEvent((*it).release()); | 691 dispatchEvent((*it).release()); |
| 681 | 692 |
| 682 events.clear(); | 693 events.clear(); |
| 683 } | 694 } |
| 684 | 695 |
| 685 } // namespace WebCore | 696 } // namespace WebCore |
| OLD | NEW |