summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h')
-rw-r--r--chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h79
1 files changed, 46 insertions, 33 deletions
diff --git a/chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h b/chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h
index 3b74ce98257..6725ef24243 100644
--- a/chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h
+++ b/chromium/third_party/WebKit/Source/modules/mediastream/RTCPeerConnection.h
@@ -34,18 +34,18 @@
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ScriptWrappable.h"
#include "core/dom/ActiveDOMObject.h"
-#include "core/events/EventTarget.h"
-#include "core/platform/mediastream/RTCPeerConnectionHandler.h"
-#include "core/platform/mediastream/RTCPeerConnectionHandlerClient.h"
+#include "modules/EventTargetModules.h"
#include "modules/mediastream/MediaStream.h"
#include "modules/mediastream/RTCIceCandidate.h"
#include "platform/AsyncMethodRunner.h"
+#include "public/platform/WebMediaConstraints.h"
+#include "public/platform/WebRTCPeerConnectionHandler.h"
+#include "public/platform/WebRTCPeerConnectionHandlerClient.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExceptionState;
-class MediaConstraints;
class MediaStreamTrack;
class RTCConfiguration;
class RTCDTMFSender;
@@ -56,21 +56,22 @@ class RTCSessionDescriptionCallback;
class RTCStatsCallback;
class VoidCallback;
-class RTCPeerConnection : public RefCounted<RTCPeerConnection>, public ScriptWrappable, public RTCPeerConnectionHandlerClient, public EventTargetWithInlineData, public ActiveDOMObject {
+class RTCPeerConnection FINAL : public RefCountedWillBeRefCountedGarbageCollected<RTCPeerConnection>, public ScriptWrappable, public blink::WebRTCPeerConnectionHandlerClient, public EventTargetWithInlineData, public ActiveDOMObject {
REFCOUNTED_EVENT_TARGET(RTCPeerConnection);
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RTCPeerConnection);
public:
- static PassRefPtr<RTCPeerConnection> create(ExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&);
- ~RTCPeerConnection();
+ static PassRefPtrWillBeRawPtr<RTCPeerConnection> create(ExecutionContext*, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState&);
+ virtual ~RTCPeerConnection();
void createOffer(PassOwnPtr<RTCSessionDescriptionCallback>, PassOwnPtr<RTCErrorCallback>, const Dictionary& mediaConstraints, ExceptionState&);
void createAnswer(PassOwnPtr<RTCSessionDescriptionCallback>, PassOwnPtr<RTCErrorCallback>, const Dictionary& mediaConstraints, ExceptionState&);
- void setLocalDescription(PassRefPtr<RTCSessionDescription>, PassOwnPtr<VoidCallback>, PassOwnPtr<RTCErrorCallback>, ExceptionState&);
- PassRefPtr<RTCSessionDescription> localDescription(ExceptionState&);
+ void setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDescription>, PassOwnPtr<VoidCallback>, PassOwnPtr<RTCErrorCallback>, ExceptionState&);
+ PassRefPtrWillBeRawPtr<RTCSessionDescription> localDescription(ExceptionState&);
- void setRemoteDescription(PassRefPtr<RTCSessionDescription>, PassOwnPtr<VoidCallback>, PassOwnPtr<RTCErrorCallback>, ExceptionState&);
- PassRefPtr<RTCSessionDescription> remoteDescription(ExceptionState&);
+ void setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDescription>, PassOwnPtr<VoidCallback>, PassOwnPtr<RTCErrorCallback>, ExceptionState&);
+ PassRefPtrWillBeRawPtr<RTCSessionDescription> remoteDescription(ExceptionState&);
String signalingState() const;
@@ -91,18 +92,22 @@ public:
MediaStream* getStreamById(const String& streamId);
- void addStream(PassRefPtr<MediaStream>, const Dictionary& mediaConstraints, ExceptionState&);
+ void addStream(PassRefPtrWillBeRawPtr<MediaStream>, const Dictionary& mediaConstraints, ExceptionState&);
- void removeStream(PassRefPtr<MediaStream>, ExceptionState&);
+ void removeStream(PassRefPtrWillBeRawPtr<MediaStream>, ExceptionState&);
void getStats(PassOwnPtr<RTCStatsCallback> successCallback, PassRefPtr<MediaStreamTrack> selector);
- PassRefPtr<RTCDataChannel> createDataChannel(String label, const Dictionary& dataChannelDict, ExceptionState&);
+ PassRefPtrWillBeRawPtr<RTCDataChannel> createDataChannel(String label, const Dictionary& dataChannelDict, ExceptionState&);
- PassRefPtr<RTCDTMFSender> createDTMFSender(PassRefPtr<MediaStreamTrack>, ExceptionState&);
+ PassRefPtrWillBeRawPtr<RTCDTMFSender> createDTMFSender(PassRefPtrWillBeRawPtr<MediaStreamTrack>, ExceptionState&);
void close(ExceptionState&);
+ // We allow getStats after close, but not other calls or callbacks.
+ bool shouldFireDefaultCallbacks() { return !m_closed && !m_stopped; }
+ bool shouldFireGetStatsCallback() { return !m_stopped; }
+
DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded);
DEFINE_ATTRIBUTE_EVENT_LISTENER(icecandidate);
DEFINE_ATTRIBUTE_EVENT_LISTENER(signalingstatechange);
@@ -111,15 +116,16 @@ public:
DEFINE_ATTRIBUTE_EVENT_LISTENER(iceconnectionstatechange);
DEFINE_ATTRIBUTE_EVENT_LISTENER(datachannel);
- // RTCPeerConnectionHandlerClient
+ // blink::WebRTCPeerConnectionHandlerClient
virtual void negotiationNeeded() OVERRIDE;
- virtual void didGenerateIceCandidate(blink::WebRTCICECandidate) OVERRIDE;
+ virtual void didGenerateICECandidate(const blink::WebRTCICECandidate&) OVERRIDE;
virtual void didChangeSignalingState(SignalingState) OVERRIDE;
- virtual void didChangeIceGatheringState(IceGatheringState) OVERRIDE;
- virtual void didChangeIceConnectionState(IceConnectionState) OVERRIDE;
- virtual void didAddRemoteStream(PassRefPtr<MediaStreamDescriptor>) OVERRIDE;
- virtual void didRemoveRemoteStream(MediaStreamDescriptor*) OVERRIDE;
- virtual void didAddRemoteDataChannel(PassOwnPtr<RTCDataChannelHandler>) OVERRIDE;
+ virtual void didChangeICEGatheringState(ICEGatheringState) OVERRIDE;
+ virtual void didChangeICEConnectionState(ICEConnectionState) OVERRIDE;
+ virtual void didAddRemoteStream(const blink::WebMediaStream&) OVERRIDE;
+ virtual void didRemoveRemoteStream(const blink::WebMediaStream&) OVERRIDE;
+ virtual void didAddRemoteDataChannel(blink::WebRTCDataChannelHandler*) OVERRIDE;
+ virtual void releasePeerConnectionHandler() OVERRIDE;
// EventTarget
virtual const AtomicString& interfaceName() const OVERRIDE;
@@ -129,35 +135,42 @@ public:
virtual void suspend() OVERRIDE;
virtual void resume() OVERRIDE;
virtual void stop() OVERRIDE;
- virtual bool hasPendingActivity() const OVERRIDE { return !m_stopped; }
+ // We keep the this object alive until either stopped or closed.
+ virtual bool hasPendingActivity() const OVERRIDE
+ {
+ return !m_closed && !m_stopped;
+ }
+
+ virtual void trace(Visitor*) OVERRIDE;
private:
- RTCPeerConnection(ExecutionContext*, PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>, ExceptionState&);
+ RTCPeerConnection(ExecutionContext*, PassRefPtr<RTCConfiguration>, blink::WebMediaConstraints, ExceptionState&);
static PassRefPtr<RTCConfiguration> parseConfiguration(const Dictionary& configuration, ExceptionState&);
- void scheduleDispatchEvent(PassRefPtr<Event>);
+ void scheduleDispatchEvent(PassRefPtrWillBeRawPtr<Event>);
void dispatchScheduledEvent();
bool hasLocalStreamWithTrackId(const String& trackId);
- void changeSignalingState(SignalingState);
- void changeIceGatheringState(IceGatheringState);
- void changeIceConnectionState(IceConnectionState);
+ void changeSignalingState(blink::WebRTCPeerConnectionHandlerClient::SignalingState);
+ void changeIceGatheringState(blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState);
+ void changeIceConnectionState(blink::WebRTCPeerConnectionHandlerClient::ICEConnectionState);
SignalingState m_signalingState;
- IceGatheringState m_iceGatheringState;
- IceConnectionState m_iceConnectionState;
+ ICEGatheringState m_iceGatheringState;
+ ICEConnectionState m_iceConnectionState;
MediaStreamVector m_localStreams;
MediaStreamVector m_remoteStreams;
- Vector<RefPtr<RTCDataChannel> > m_dataChannels;
+ WillBeHeapVector<RefPtrWillBeMember<RTCDataChannel> > m_dataChannels;
- OwnPtr<RTCPeerConnectionHandler> m_peerHandler;
+ OwnPtr<blink::WebRTCPeerConnectionHandler> m_peerHandler;
AsyncMethodRunner<RTCPeerConnection> m_dispatchScheduledEventRunner;
- Vector<RefPtr<Event> > m_scheduledEvents;
+ WillBeHeapVector<RefPtrWillBeMember<Event> > m_scheduledEvents;
bool m_stopped;
+ bool m_closed;
};
} // namespace WebCore