Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(877)

Unified Diff: Source/modules/mediastream/RTCPeerConnection.h

Issue 329093002: Allow PeerConnection to be garbage collected after close(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Data channel now has a weak ptr to the peer connection that created it. Stops itself if creator goe… Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/mediastream/RTCPeerConnection.h
diff --git a/Source/modules/mediastream/RTCPeerConnection.h b/Source/modules/mediastream/RTCPeerConnection.h
index 03c6137400bfefde3f731e99e64024106e89e41d..f7311dc0a8e9b9da947094468e8a0359c7314c70 100644
--- a/Source/modules/mediastream/RTCPeerConnection.h
+++ b/Source/modules/mediastream/RTCPeerConnection.h
@@ -104,6 +104,10 @@ public:
void close(ExceptionState&);
+ // We allow getStats after close, but not other calls or callbacks.
+ bool requestMayFireNonStatsCallback() { return !m_closed && !m_stopped; }
+ bool requestMayFireStatsCallback() { return !m_stopped; }
+
DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded);
DEFINE_ATTRIBUTE_EVENT_LISTENER(icecandidate);
DEFINE_ATTRIBUTE_EVENT_LISTENER(signalingstatechange);
@@ -131,7 +135,20 @@ public:
virtual void suspend() OVERRIDE;
virtual void resume() OVERRIDE;
virtual void stop() OVERRIDE;
- virtual bool hasPendingActivity() const OVERRIDE { return !m_stopped; }
+ // We require a call to close() or stop() before the object can be garbage
+ // collected. In close(), stop() is called on |m_peer_handler|, after which
+ // no events are fired on this object
+ // (blink::WebRTCPeerConnectionHandlerClient interface). In stop(),
+ // |m_peer_handler| is deleted. Note that async operations such as
+ // createOffer or getStats doesn't respond through this object, but through
+ // a request object containing the callback. The request object is handed to
+ // the client. Hence, we don't need to keep track of if there are still
+ // outstandning requests. The request is given a pointer to this object and
+ // checks if it should fire the callback before doing so.
+ virtual bool hasPendingActivity() const OVERRIDE
+ {
+ return !m_closed && !m_stopped;
+ }
virtual void trace(Visitor*) OVERRIDE;
@@ -161,7 +178,10 @@ private:
AsyncMethodRunner<RTCPeerConnection> m_dispatchScheduledEventRunner;
WillBeHeapVector<RefPtrWillBeMember<Event> > m_scheduledEvents;
+ WeakPtrFactory<RTCPeerConnection> m_weakPtrFactory;
keishi 2014/06/17 07:58:21 Could you wrap this in !ENABLE(OILPAN)?
Henrik Grunell 2014/06/17 08:08:27 Done.
+
bool m_stopped;
+ bool m_closed;
};
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698