Make ActiveDOMObject::canSuspend() pure virtual
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 01:05:21 +0000 (01:05 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Feb 2015 01:05:21 +0000 (01:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142096
<rdar://problem/19923085>

Reviewed by Andreas Kling.

Make ActiveDOMObject::canSuspend() pure virtual so that people at least
try to provide an implementation for it. The default implementation was
returning false unconditionally and thus was preventing pages from
entering the PageCache.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180801 268f45cc-cd09-0410-ab3c-d52691b4dbfc

63 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/battery/BatteryManager.cpp
Source/WebCore/Modules/battery/BatteryManager.h
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
Source/WebCore/Modules/geolocation/Geolocation.cpp
Source/WebCore/Modules/geolocation/Geolocation.h
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/MediaSource.h
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/MediaStreamTrack.h
Source/WebCore/Modules/mediastream/RTCDTMFSender.cpp
Source/WebCore/Modules/mediastream/RTCDTMFSender.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/Modules/mediastream/RTCSessionDescriptionRequestImpl.cpp
Source/WebCore/Modules/mediastream/RTCSessionDescriptionRequestImpl.h
Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.cpp
Source/WebCore/Modules/mediastream/RTCStatsRequestImpl.h
Source/WebCore/Modules/mediastream/RTCVoidRequestImpl.cpp
Source/WebCore/Modules/mediastream/RTCVoidRequestImpl.h
Source/WebCore/Modules/notifications/Notification.cpp
Source/WebCore/Modules/notifications/Notification.h
Source/WebCore/Modules/notifications/NotificationCenter.cpp
Source/WebCore/Modules/notifications/NotificationCenter.h
Source/WebCore/Modules/streams/ReadableStream.cpp
Source/WebCore/Modules/streams/ReadableStream.h
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/Modules/websockets/WebSocket.h
Source/WebCore/css/FontLoader.cpp
Source/WebCore/css/FontLoader.h
Source/WebCore/dom/ActiveDOMObject.h
Source/WebCore/dom/DocumentEventQueue.cpp
Source/WebCore/fileapi/FileReader.cpp
Source/WebCore/fileapi/FileReader.h
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/PublicURLManager.cpp
Source/WebCore/html/PublicURLManager.h
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Source/WebCore/page/DOMTimer.cpp
Source/WebCore/page/DOMTimer.h
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/EventSource.h
Source/WebCore/page/SuspendableTimer.h
Source/WebCore/workers/AbstractWorker.cpp
Source/WebCore/workers/AbstractWorker.h
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/Worker.h
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h
Source/WebKit/win/WebView.cpp

index eca8a02..d588051 100644 (file)
@@ -1,3 +1,16 @@
+2015-02-27  Chris Dumez  <cdumez@apple.com>
+
+        Make ActiveDOMObject::canSuspend() pure virtual
+        https://bugs.webkit.org/show_bug.cgi?id=142096
+        <rdar://problem/19923085>
+
+        Reviewed by Andreas Kling.
+
+        Make ActiveDOMObject::canSuspend() pure virtual so that people at least
+        try to provide an implementation for it. The default implementation was
+        returning false unconditionally and thus was preventing pages from
+        entering the PageCache.
+
 2015-02-27  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r180203 and r180210.
index 20c4134..cf62a08 100644 (file)
@@ -88,6 +88,11 @@ void BatteryManager::updateBatteryStatus(PassRefPtr<BatteryStatus> batteryStatus
     m_batteryStatus = batteryStatus;
 }
 
+bool BatteryManager::canSuspend() const
+{
+    return true;
+}
+
 void BatteryManager::suspend(ReasonForSuspension)
 {
     if (m_batteryController)
index 32e2152..56cc812 100644 (file)
@@ -58,12 +58,6 @@ public:
     using RefCounted<BatteryManager>::ref;
     using RefCounted<BatteryManager>::deref;
 
-    // ActiveDOMObject implementation.
-    virtual bool canSuspend() const override { return true; }
-    virtual void suspend(ReasonForSuspension) override;
-    virtual void resume() override;
-    virtual void stop() override;
-
 protected:
     virtual EventTargetData* eventTargetData() override { return &m_eventTargetData; }
     virtual EventTargetData& ensureEventTargetData() override { return m_eventTargetData; }
@@ -71,6 +65,12 @@ protected:
 private:
     explicit BatteryManager(Navigator*);
 
+    // ActiveDOMObject API.
+    bool canSuspend() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    void stop() override;
+
     // EventTarget implementation.
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
index 47e984b..23f9d0d 100644 (file)
@@ -250,6 +250,27 @@ String MediaKeySession::mediaKeysStorageDirectory() const
     return pathByAppendingComponent(storageDirectory, origin->databaseIdentifier());
 }
 
+bool MediaKeySession::hasPendingActivity() const
+{
+    return (m_keys && !isClosed()) || m_asyncEventQueue.hasPendingEvents();
+}
+
+void MediaKeySession::stop()
+{
+    close();
+}
+
+const char* MediaKeySession::activeDOMObjectName() const
+{
+    return "MediaKeySession";
+}
+
+bool MediaKeySession::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 }
 
 #endif
index 4de46f7..7835c49 100644 (file)
@@ -73,10 +73,6 @@ public:
 
     void enqueueEvent(PassRefPtr<Event>);
 
-    // ActiveDOMObject
-    virtual bool hasPendingActivity() const override { return (m_keys && !isClosed()) || m_asyncEventQueue.hasPendingEvents(); }
-    virtual void stop() override { close(); }
-
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyadded);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeyerror);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(webkitkeymessage);
@@ -84,6 +80,9 @@ public:
     virtual EventTargetInterface eventTargetInterface() const override { return MediaKeySessionEventTargetInterfaceType; }
     virtual ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
 
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override;
+
 protected:
     MediaKeySession(ScriptExecutionContext*, MediaKeys*, const String& keySystem);
     void keyRequestTimerFired();
@@ -116,7 +115,10 @@ private:
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
 
-    virtual const char* activeDOMObjectName() const override { return "MediaKeySession"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    bool canSuspend() const override;
+    const char* activeDOMObjectName() const override;
 };
 
 }
index 7dab804..6837a4e 100644 (file)
@@ -293,6 +293,11 @@ void Geolocation::stop()
     m_pendingForPermissionNotifiers.clear();
 }
 
+const char* Geolocation::activeDOMObjectName() const
+{
+    return "Geolocation";
+}
+
 Geoposition* Geolocation::lastPosition()
 {
     Page* page = this->page();
index 3593f13..0b30d32 100644 (file)
@@ -57,9 +57,6 @@ public:
     static Ref<Geolocation> create(ScriptExecutionContext*);
     WEBCORE_EXPORT ~Geolocation();
 
-    virtual bool canSuspend() const override;
-    virtual void suspend(ReasonForSuspension) override;
-    virtual void resume() override;
     WEBCORE_EXPORT void resetAllGeolocationPermission();
     Document* document() const;
     WEBCORE_EXPORT Frame* frame() const;
@@ -80,7 +77,11 @@ private:
     Geoposition* lastPosition();
 
     // ActiveDOMObject
-    virtual void stop() override;
+    void stop() override;
+    bool canSuspend() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    const char* activeDOMObjectName() const override;
 
     bool isDenied() const { return m_allowGeolocation == No; }
 
@@ -140,8 +141,6 @@ private:
     bool haveSuitableCachedPosition(PositionOptions*);
     void makeCachedPositionCallbacks();
 
-    virtual const char* activeDOMObjectName() const override { return "Geolocation"; }
-
     GeoNotifierSet m_oneShots;
     Watchers m_watchers;
     GeoNotifierSet m_pendingForPermissionNotifiers;
index 59eff1c..423f41d 100644 (file)
@@ -361,6 +361,11 @@ void IDBDatabase::stop()
     m_contextStopped = true;
 }
 
+const char* IDBDatabase::activeDOMObjectName() const
+{
+    return "IDBDatabase";
+}
+
 bool IDBDatabase::canSuspend() const
 {
     return m_isClosed;
index 9c9c760..03e5eea 100644 (file)
@@ -80,9 +80,6 @@ public:
     virtual void onAbort(int64_t, PassRefPtr<IDBDatabaseError>);
     virtual void onComplete(int64_t);
 
-    // ActiveDOMObject
-    virtual bool hasPendingActivity() const override;
-
     // EventTarget
     virtual EventTargetInterface eventTargetInterface() const override final { return IDBDatabaseEventTargetInterfaceType; }
     virtual ScriptExecutionContext* scriptExecutionContext() const override final { return ActiveDOMObject::scriptExecutionContext(); }
@@ -108,12 +105,15 @@ public:
     using RefCounted<IDBDatabase>::ref;
     using RefCounted<IDBDatabase>::deref;
 
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override;
+
 private:
     IDBDatabase(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackend>, PassRefPtr<IDBDatabaseCallbacks>);
 
-    // ActiveDOMObject
+    // ActiveDOMObject API.
     void stop() override;
-    const char* activeDOMObjectName() const override { return "IDBDatabase"; }
+    const char* activeDOMObjectName() const override;
     bool canSuspend() const override;
 
     // EventTarget
index 49470ea..3969800 100644 (file)
@@ -448,6 +448,11 @@ bool IDBRequest::canSuspend() const
     return !m_hasPendingActivity;
 }
 
+const char* IDBRequest::activeDOMObjectName() const
+{
+    return "IDBRequest";
+}
+
 EventTargetInterface IDBRequest::eventTargetInterface() const
 {
     return IDBRequestEventTargetInterfaceType;
index 9fd2628..3425c7b 100644 (file)
@@ -93,9 +93,6 @@ public:
     virtual void onSuccess();
     virtual void onSuccess(PassRefPtr<IDBKey>, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer>);
 
-    // ActiveDOMObject
-    virtual bool hasPendingActivity() const override;
-
     // EventTarget
     virtual EventTargetInterface eventTargetInterface() const override;
     virtual ScriptExecutionContext* scriptExecutionContext() const override final { return ActiveDOMObject::scriptExecutionContext(); }
@@ -113,6 +110,9 @@ public:
 
     DOMRequestState* requestState() { return &m_requestState; }
 
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override;
+
 protected:
     IDBRequest(ScriptExecutionContext*, PassRefPtr<IDBAny> source, IDBDatabaseBackend::TaskType, IDBTransaction*);
     void enqueueEvent(PassRefPtr<Event>);
@@ -130,12 +130,12 @@ protected:
     bool m_requestAborted; // May be aborted by transaction then receive async onsuccess; ignore vs. assert.
 
 private:
-    // ActiveDOMObject
+    // ActiveDOMObject API.
     void stop() override;
-    const char* activeDOMObjectName() const override { return "IDBRequest"; }
+    const char* activeDOMObjectName() const override;
     bool canSuspend() const override;
 
-    // EventTarget
+    // EventTarget API.
     virtual void refEventTarget() override final { ref(); }
     virtual void derefEventTarget() override final { deref(); }
 
index c42f945..e249b4f 100644 (file)
@@ -408,6 +408,11 @@ void IDBTransaction::stop()
     abort(IGNORE_EXCEPTION);
 }
 
+const char* IDBTransaction::activeDOMObjectName() const
+{
+    return "IDBTransaction";
+}
+
 void IDBTransaction::enqueueEvent(PassRefPtr<Event> event)
 {
     ASSERT_WITH_MESSAGE(m_state != Finished, "A finished transaction tried to enqueue an event of type %s.", event->type().string().utf8().data());
index f5cd34d..5e9e042 100644 (file)
@@ -111,7 +111,7 @@ public:
     virtual bool dispatchEvent(PassRefPtr<Event>) override;
 
     // ActiveDOMObject
-    virtual bool hasPendingActivity() const override;
+    bool hasPendingActivity() const override;
 
     using RefCounted<IDBTransaction>::ref;
     using RefCounted<IDBTransaction>::deref;
@@ -125,12 +125,12 @@ private:
     void registerOpenCursor(IDBCursor*);
     void unregisterOpenCursor(IDBCursor*);
 
-    // ActiveDOMObject
-    virtual bool canSuspend() const override;
-    virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "IDBTransaction"; }
+    // ActiveDOMObject API.
+    bool canSuspend() const override;
+    void stop() override;
+    const char* activeDOMObjectName() const override;
 
-    // EventTarget
+    // EventTarget API.
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
 
index 7086417..90aca6d 100644 (file)
@@ -814,6 +814,11 @@ bool MediaSource::canSuspend() const
     return isClosed() && !m_asyncEventQueue.hasPendingEvents();
 }
 
+const char* MediaSource::activeDOMObjectName() const
+{
+    return "MediaSource";
+}
+
 void MediaSource::onReadyStateChange(const AtomicString& oldState, const AtomicString& newState)
 {
     if (isOpen()) {
index ae89b04..c2ccd97 100644 (file)
@@ -99,11 +99,6 @@ public:
     void removeSourceBuffer(SourceBuffer*, ExceptionCode&);
     static bool isTypeSupported(const String& type);
 
-    // ActiveDOMObject interface
-    bool hasPendingActivity() const override;
-    void stop() override;
-    bool canSuspend() const override;
-
     // EventTarget interface
     virtual ScriptExecutionContext* scriptExecutionContext() const override final;
     virtual void refEventTarget() override final { ref(); }
@@ -116,10 +111,16 @@ public:
     using RefCounted<MediaSourcePrivateClient>::ref;
     using RefCounted<MediaSourcePrivateClient>::deref;
 
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override;
+
 protected:
     explicit MediaSource(ScriptExecutionContext&);
 
-    virtual const char* activeDOMObjectName() const override { return "MediaSource"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    bool canSuspend() const override;
+    const char* activeDOMObjectName() const override;
 
     void onReadyStateChange(const AtomicString& oldState, const AtomicString& newState);
     Vector<PlatformTimeRanges> activeRanges() const;
index 9a653ba..59b5420 100644 (file)
@@ -515,6 +515,11 @@ bool SourceBuffer::canSuspend() const
     return !hasPendingActivity();
 }
 
+const char* SourceBuffer::activeDOMObjectName() const
+{
+    return "SourceBuffer";
+}
+
 bool SourceBuffer::isRemoved() const
 {
     return !m_source;
index ea11650..49269ff 100644 (file)
@@ -106,11 +106,6 @@ public:
 
     bool active() const { return m_active; }
 
-    // ActiveDOMObject interface
-    virtual bool hasPendingActivity() const override;
-    virtual void stop() override;
-    bool canSuspend() const override;
-
     // EventTarget interface
     virtual ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
     virtual EventTargetInterface eventTargetInterface() const override { return SourceBufferEventTargetInterfaceType; }
@@ -129,6 +124,10 @@ public:
     void setShouldGenerateTimestamps(bool flag) { m_shouldGenerateTimestamps = flag; }
 
     void rangeRemoval(const MediaTime&, const MediaTime&);
+
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override;
+
 protected:
     // EventTarget interface
     virtual void refEventTarget() override { ref(); }
@@ -137,7 +136,10 @@ protected:
 private:
     SourceBuffer(Ref<SourceBufferPrivate>&&, MediaSource*);
 
-    virtual const char* activeDOMObjectName() const override { return "SourceBuffer"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     // SourceBufferPrivateClient
     virtual void sourceBufferPrivateDidEndStream(SourceBufferPrivate*, const WTF::AtomicString&) override;
index 31fc198..dbb105c 100644 (file)
@@ -288,6 +288,17 @@ void MediaStreamTrack::stop()
     m_privateTrack->stop(MediaStreamTrackPrivate::StopTrackOnly);
 }
 
+const char* MediaStreamTrack::activeDOMObjectName() const
+{
+    return "MediaStreamTrack";
+}
+
+bool MediaStreamTrack::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void MediaStreamTrack::scheduleEventDispatch(PassRefPtr<Event> event)
 {
     {
index a769a9e..ece8504 100644 (file)
@@ -112,14 +112,14 @@ protected:
     void setSource(PassRefPtr<MediaStreamSource>);
 
 private:
-
     void configureTrackRendering();
     void trackDidEnd();
     void scheduleEventDispatch(PassRefPtr<Event>);
 
-    // ActiveDOMObject
-    virtual void stop() override final;
-    virtual const char* activeDOMObjectName() const override { return "MediaStreamTrack"; }
+    // ActiveDOMObject API.
+    void stop() override final;
+    const char* activeDOMObjectName() const override final;
+    bool canSuspend() const override final;
 
     // EventTarget
     virtual void refEventTarget() override final { ref(); }
index 9231654..f014b4c 100644 (file)
@@ -131,7 +131,18 @@ void RTCDTMFSender::didPlayTone(const String& tone)
 void RTCDTMFSender::stop()
 {
     m_stopped = true;
-    m_handler->setClient(0);
+    m_handler->setClient(nullptr);
+}
+
+const char* RTCDTMFSender::activeDOMObjectName() const
+{
+    return "RTCDTMFSender";
+}
+
+bool RTCDTMFSender::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
 }
 
 void RTCDTMFSender::scheduleDispatchEvent(PassRefPtr<Event> event)
index fc717f9..d2df1e5 100644 (file)
@@ -62,16 +62,16 @@ public:
     virtual EventTargetInterface eventTargetInterface() const override { return RTCDTMFSenderEventTargetInterfaceType; }
     virtual ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
 
-    // ActiveDOMObject
-    virtual void stop() override;
-
     using RefCounted<RTCDTMFSender>::ref;
     using RefCounted<RTCDTMFSender>::deref;
 
 private:
     RTCDTMFSender(ScriptExecutionContext*, PassRefPtr<MediaStreamTrack>, std::unique_ptr<RTCDTMFSenderHandler>);
 
-    virtual const char* activeDOMObjectName() const override { return "RTCDTMFSender"; }
+    // ActiveDOMObject
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void scheduleDispatchEvent(PassRefPtr<Event>);
     void scheduledEventTimerFired();
index 72e1ffa..e8433e5 100644 (file)
@@ -690,6 +690,17 @@ void RTCPeerConnection::stop()
         (*i)->stop();
 }
 
+const char* RTCPeerConnection::activeDOMObjectName() const
+{
+    return "RTCPeerConnection";
+}
+
+bool RTCPeerConnection::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void RTCPeerConnection::didAddOrRemoveTrack()
 {
     negotiationNeeded();
index e57a4f8..deef601 100644 (file)
@@ -125,9 +125,6 @@ public:
     virtual EventTargetInterface eventTargetInterface() const override { return RTCPeerConnectionEventTargetInterfaceType; }
     virtual ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); }
 
-    // ActiveDOMObject
-    virtual void stop() override;
-
     // MediaStream::Observer
     virtual void didAddOrRemoveTrack() override;
 
@@ -146,7 +143,10 @@ private:
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
 
-    virtual const char* activeDOMObjectName() const override { return "RTCPeerConnection"; }
+    // ActiveDOMObject
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void changeSignalingState(SignalingState);
     void changeIceGatheringState(IceGatheringState);
index 082391a..431485e 100644 (file)
@@ -84,6 +84,17 @@ void RTCSessionDescriptionRequestImpl::stop()
     clear();
 }
 
+const char* RTCSessionDescriptionRequestImpl::activeDOMObjectName() const
+{
+    return "RTCSessionDescriptionRequestImpl";
+}
+
+bool RTCSessionDescriptionRequestImpl::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void RTCSessionDescriptionRequestImpl::clear()
 {
     m_successCallback.clear();
index 5b9433e..67f8ce3 100644 (file)
@@ -51,13 +51,13 @@ public:
     virtual void requestSucceeded(PassRefPtr<RTCSessionDescriptionDescriptor>) override;
     virtual void requestFailed(const String& error) override;
 
-    // ActiveDOMObject
-    virtual void stop() override;
-
 private:
     RTCSessionDescriptionRequestImpl(ScriptExecutionContext*, PassRefPtr<RTCSessionDescriptionCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>);
 
-    virtual const char* activeDOMObjectName() const override { return "RTCSessionDescriptionRequestImpl"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void clear();
 
index d10d1b4..2a2408a 100644 (file)
@@ -91,6 +91,17 @@ void RTCStatsRequestImpl::stop()
     clear();
 }
 
+const char* RTCStatsRequestImpl::activeDOMObjectName() const
+{
+    return "RTCStatsRequestImpl";
+}
+
+bool RTCStatsRequestImpl::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void RTCStatsRequestImpl::clear()
 {
     m_successCallback.clear();
index 973a6ac..cb5d85e 100644 (file)
@@ -51,13 +51,13 @@ public:
     virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>) override;
     virtual void requestFailed(const String&) override;
 
-    // ActiveDOMObject
-    virtual void stop() override;
-
 private:
     RTCStatsRequestImpl(ScriptExecutionContext*, PassRefPtr<RTCStatsCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>, PassRefPtr<MediaStreamTrackPrivate>);
 
-    virtual const char* activeDOMObjectName() const override { return "RTCStatsRequestImpl"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void clear();
 
index d907578..cf0653b 100644 (file)
@@ -81,6 +81,17 @@ void RTCVoidRequestImpl::stop()
     clear();
 }
 
+const char* RTCVoidRequestImpl::activeDOMObjectName() const
+{
+    return "RTCVoidRequestImpl";
+}
+
+bool RTCVoidRequestImpl::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void RTCVoidRequestImpl::clear()
 {
     m_successCallback.clear();
index 748c96c..7a18b88 100644 (file)
@@ -50,16 +50,16 @@ public:
     virtual void requestSucceeded();
     virtual void requestFailed(const String& error);
 
-    // ActiveDOMObject
-    virtual void stop() override;
-
 private:
     RTCVoidRequestImpl(ScriptExecutionContext*, PassRefPtr<VoidCallback>, PassRefPtr<RTCPeerConnectionErrorCallback>);
 
-    virtual const char* activeDOMObjectName() const override { return "RTCVoidRequestImpl"; }
-
     void clear();
 
+    // ActiveDOMObject
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
+
     RefPtr<VoidCallback> m_successCallback;
     RefPtr<RTCPeerConnectionErrorCallback> m_errorCallback;
 };
index 9bd0446..e4d8d7a 100644 (file)
@@ -170,6 +170,17 @@ void Notification::contextDestroyed()
         m_notificationCenter->client()->notificationObjectDestroyed(this);
 }
 
+const char* Notification::activeDOMObjectName() const
+{
+    return "Notification";
+}
+
+bool Notification::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 void Notification::finalize()
 {
     if (m_state == Closed)
index d17cef8..3894be2 100644 (file)
@@ -146,15 +146,15 @@ private:
 
     void setBody(const String& body) { m_body = body; }
 
-    // ActiveDOMObject interface
-    virtual void contextDestroyed() override;
+    // ActiveDOMObject API.
+    void contextDestroyed() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
-    // EventTarget interface
+    // EventTarget API.
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
 
-    virtual const char* activeDOMObjectName() const override { return "Notification"; }
-
     void startLoadingIcon();
     void finishLoadingIcon();
 
index 09582f5..b2c813c 100644 (file)
@@ -102,7 +102,18 @@ void NotificationCenter::stop()
         return;
     m_client->cancelRequestsForPermission(scriptExecutionContext());
     m_client->clearNotifications(scriptExecutionContext());
-    m_client = 0;
+    m_client = nullptr;
+}
+
+const char* NotificationCenter::activeDOMObjectName() const
+{
+    return "NotificationCenter";
+}
+
+bool NotificationCenter::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
 }
 
 void NotificationCenter::requestTimedOut(NotificationCenter::NotificationRequestCallback* request)
index 6f2b808..b3b1a26 100644 (file)
@@ -73,9 +73,10 @@ public:
 private:
     NotificationCenter(ScriptExecutionContext*, NotificationClient*);
 
-    // ActiveDOMObject
-    virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "NotificationCenter"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     class NotificationRequestCallback : public RefCounted<NotificationRequestCallback> {
     public:
index 3e4fc65..f76275a 100644 (file)
@@ -90,6 +90,17 @@ void ReadableStream::ready(SuccessCallback)
     notImplemented();
 }
 
+const char* ReadableStream::activeDOMObjectName() const
+{
+    return "ReadableStream";
+}
+
+bool ReadableStream::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 }
 
 #endif
index c845fed..00b4950 100644 (file)
@@ -58,8 +58,6 @@ public:
     static Ref<ReadableStream> create(ScriptExecutionContext&, Ref<ReadableStreamSource>&&);
     virtual ~ReadableStream();
 
-    virtual const char* activeDOMObjectName() const override { return "ReadableStream"; }
-
     // JS API implementation.
     String state() const;
 
@@ -70,6 +68,10 @@ public:
 private:
     ReadableStream(ScriptExecutionContext&, Ref<ReadableStreamSource>&&);
 
+    // ActiveDOMObject API.
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
+
     State m_state;
     Ref<ReadableStreamSource> m_source;
 };
index 7786837..cd4277d 100644 (file)
@@ -313,6 +313,17 @@ void AudioContext::stop()
     callOnMainThread(stopDispatch, this);
 }
 
+bool AudioContext::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
+const char* AudioContext::activeDOMObjectName() const
+{
+    return "AudioContext";
+}
+
 Document* AudioContext::document() const
 {
     ASSERT(m_scriptExecutionContext);
index 252dbe1..b3b89c3 100644 (file)
@@ -85,9 +85,6 @@ public:
     
     bool isOfflineContext() { return m_isOfflineContext; }
 
-    // Document notification
-    virtual void stop() override;
-
     Document* document() const; // ASSERTs if document no longer exists.
 
     AudioDestinationNode* destination() { return m_destinationNode.get(); }
@@ -264,8 +261,6 @@ protected:
     static bool isSampleRateRangeGood(float sampleRate);
     
 private:
-    virtual const char* activeDOMObjectName() const override { return "AudioContext"; }
-
     void constructCommon();
 
     void lazyInitialize();
@@ -296,6 +291,11 @@ private:
     void refNode(AudioNode*);
     void derefNode(AudioNode*);
 
+    // ActiveDOMObject API.
+    void stop() override;
+    bool canSuspend() const override;
+    const char* activeDOMObjectName() const override;
+
     // When the context goes away, there might still be some sources which haven't finished playing.
     // Make sure to dereference them here.
     void derefUnfinishedSourceNodes();
index e0483c5..57878e7 100644 (file)
@@ -489,6 +489,11 @@ void WebSocket::stop()
         ActiveDOMObject::unsetPendingActivity(this);
 }
 
+const char* WebSocket::activeDOMObjectName() const
+{
+    return "WebSocket";
+}
+
 void WebSocket::didConnect()
 {
     LOG(Network, "WebSocket %p didConnect()", this);
index 4f3ce72..86be2bb 100644 (file)
@@ -113,13 +113,13 @@ public:
 private:
     explicit WebSocket(ScriptExecutionContext&);
 
-    // ActiveDOMObject functions.
-    virtual void contextDestroyed() override;
-    virtual bool canSuspend() const override;
-    virtual void suspend(ReasonForSuspension) override;
-    virtual void resume() override;
-    virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "WebSocket"; }
+    // ActiveDOMObject API.
+    void contextDestroyed() override;
+    bool canSuspend() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    void stop() override;
+    const char* activeDOMObjectName() const override;
 
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
index f45f302..05f6623 100644 (file)
@@ -156,6 +156,16 @@ void FontLoader::didLayout()
     loadingDone();
 }
 
+const char* FontLoader::activeDOMObjectName() const
+{
+    return "FontLoader";
+}
+
+bool FontLoader::canSuspend() const
+{
+    return !m_numLoadingFromCSS && !m_numLoadingFromJS;
+}
+
 void FontLoader::scheduleEvent(PassRefPtr<Event> event)
 {
     m_pendingEvents.append(event);
index 7e00ab1..624d161 100644 (file)
@@ -85,8 +85,6 @@ public:
     void loadError(CSSFontFaceRule*, CSSFontFaceSource*);
     void loadingDone();
 
-    virtual bool canSuspend() const override { return !m_numLoadingFromCSS && !m_numLoadingFromJS; }
-
 private:
     FontLoader(Document*);
 
@@ -95,7 +93,9 @@ private:
     virtual EventTargetData* eventTargetData() override;
     virtual EventTargetData& ensureEventTargetData() override;
 
-    virtual const char* activeDOMObjectName() const override { return "FontLoader"; }
+    // ActiveDOMObject API.
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void pendingEventsTimerFired() { firePendingEvents(); }
     void scheduleEvent(PassRefPtr<Event>);
index e1ec775..1e5cc1f 100644 (file)
@@ -62,7 +62,7 @@ public:
 
     // These three functions must not have a side effect of creating or destroying
     // any ActiveDOMObject. That means they must not result in calls to arbitrary JavaScript.
-    virtual bool canSuspend() const;
+    virtual bool canSuspend() const = 0; // Returning false in canSuspend() will prevent the page from entering the PageCache.
     virtual void suspend(ReasonForSuspension);
     virtual void resume();
 
index d7141f2..a7bb5df 100644 (file)
@@ -51,6 +51,8 @@ private:
         m_eventQueue.pendingEventTimerFired();
     }
 
+    const char* activeDOMObjectName() const override { return "DocumentEventQueueTimer"; }
+
     DocumentEventQueue& m_eventQueue;
 };
 
index 7318188..e61e3f1 100644 (file)
@@ -71,6 +71,11 @@ bool FileReader::canSuspend() const
     return false;
 }
 
+const char* FileReader::activeDOMObjectName() const
+{
+    return "FileReader";
+}
+
 void FileReader::stop()
 {
     terminate();
index c47562f..89fcb2a 100644 (file)
@@ -102,10 +102,10 @@ public:
 private:
     explicit FileReader(ScriptExecutionContext&);
 
-    // ActiveDOMObject
-    virtual const char* activeDOMObjectName() const override { return "FileReader"; }
-    virtual bool canSuspend() const override;
-    virtual void stop() override;
+    // ActiveDOMObject API.
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
+    void stop() override;
 
     // EventTarget
     virtual void refEventTarget() override { ref(); }
index 6bbf1f1..5112cf2 100644 (file)
@@ -4713,6 +4713,11 @@ bool HTMLMediaElement::canSuspend() const
     return true; 
 }
 
+const char* HTMLMediaElement::activeDOMObjectName() const
+{
+    return "HTMLMediaElement";
+}
+
 void HTMLMediaElement::stop()
 {
     LOG(Media, "HTMLMediaElement::stop(%p)", this);
index 16e1da2..2419416 100644 (file)
@@ -521,12 +521,12 @@ private:
     virtual void didBecomeFullscreenElement() override;
     virtual void willStopBeingFullscreenElement() override;
 
-    // ActiveDOMObject functions.
-    virtual const char* activeDOMObjectName() const override { return "HTMLMediaElement"; }
-    virtual bool canSuspend() const override;
-    virtual void suspend(ReasonForSuspension) override;
-    virtual void resume() override;
-    virtual void stop() override;
+    // ActiveDOMObject API.
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    void stop() override;
     
     virtual void mediaVolumeDidChange() override;
 
index 290bbbd..07aa0df 100644 (file)
@@ -86,4 +86,9 @@ bool PublicURLManager::canSuspend() const
     return true;
 }
 
+const char* PublicURLManager::activeDOMObjectName() const
+{
+    return "PublicURLManager";
+}
+
 } // namespace WebCore
index d470718..90da0d8 100644 (file)
@@ -50,12 +50,11 @@ public:
     void registerURL(SecurityOrigin*, const URL&, URLRegistrable*);
     void revoke(const URL&);
 
-    // ActiveDOMObject interface.
-    virtual void stop() override;
-    virtual bool canSuspend() const override;
-
 private:
-    virtual const char* activeDOMObjectName() const override { return "PublicURLManager"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    bool canSuspend() const override;
+    const char* activeDOMObjectName() const override;
     
     typedef HashSet<String> URLSet;
     typedef HashMap<URLRegistry*, URLSet > RegistryURLMap;
index 13189ad..8fc0e02 100644 (file)
@@ -3934,6 +3934,17 @@ void WebGLRenderingContextBase::stop()
     }
 }
 
+const char* WebGLRenderingContextBase::activeDOMObjectName() const
+{
+    return "WebGLRenderingContext";
+}
+
+bool WebGLRenderingContextBase::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 WebGLGetInfo WebGLRenderingContextBase::getBooleanParameter(GC3Denum pname)
 {
     GC3Dboolean value = 0;
index 0680844..0d643fe 100644 (file)
@@ -404,7 +404,8 @@ protected:
     // ActiveDOMObject
     virtual bool hasPendingActivity() const override;
     virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "WebGLRenderingContext"; }
+    virtual const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void addSharedObject(WebGLSharedObject*);
     void addContextObject(WebGLContextObject*);
index 9c3d794..5a47e2c 100644 (file)
@@ -520,4 +520,9 @@ double DOMTimer::alignedFireTime(double fireTime) const
     return fireTime;
 }
 
+const char* DOMTimer::activeDOMObjectName() const
+{
+    return "DOMTimer";
+}
+
 } // namespace WebCore
index d895ea4..691c5b0 100644 (file)
@@ -79,6 +79,9 @@ namespace WebCore {
         virtual void didStop() override;
         virtual double alignedFireTime(double) const override;
 
+        // ActiveDOMObject API.
+        const char* activeDOMObjectName() const override;
+
         enum TimerThrottleState {
             Undetermined,
             ShouldThrottle,
index 71ad82c..a9f467f 100644 (file)
@@ -416,6 +416,17 @@ void EventSource::stop()
     close();
 }
 
+const char* EventSource::activeDOMObjectName() const
+{
+    return "EventSource";
+}
+
+bool EventSource::canSuspend() const
+{
+    // FIXME: We should try and do better here.
+    return false;
+}
+
 PassRefPtr<MessageEvent> EventSource::createMessageEvent()
 {
     RefPtr<MessageEvent> event = MessageEvent::create();
index e08ce42..9e4f557 100644 (file)
@@ -91,8 +91,10 @@ private:
     virtual void didFailAccessControlCheck(const ResourceError&) override;
     virtual void didFailRedirectCheck() override;
 
-    virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "EventSource"; }
+    // ActiveDOMObject API.
+    void stop() override;
+    const char* activeDOMObjectName() const override;
+    bool canSuspend() const override;
 
     void connect();
     void networkRequestEnded();
index 9e29b7f..f4af15f 100644 (file)
@@ -57,13 +57,12 @@ public:
 private:
     virtual void fired() override = 0;
 
-    // ActiveDOMObject
-    virtual bool hasPendingActivity() const final override;
-    virtual void stop() final override;
-    virtual bool canSuspend() const final override;
-    virtual void suspend(ReasonForSuspension) final override;
-    virtual void resume() final override;
-    virtual const char* activeDOMObjectName() const override { return "SuspendableTimer"; }
+    // ActiveDOMObject API.
+    bool hasPendingActivity() const override final;
+    void stop() override final;
+    bool canSuspend() const override final;
+    void suspend(ReasonForSuspension) override final;
+    void resume() override final;
 
     bool m_suspended;
 
index 85b9b54..5eee7eb 100644 (file)
 
 namespace WebCore {
 
-AbstractWorker::AbstractWorker(ScriptExecutionContext& context)
-    : ActiveDOMObject(&context)
-{
-}
-
 AbstractWorker::~AbstractWorker()
 {
 }
index bd79368..be8d1c4 100644 (file)
@@ -43,11 +43,8 @@ namespace WebCore {
 
     class URL;
 
-    class AbstractWorker : public RefCounted<AbstractWorker>, public ActiveDOMObject, public EventTargetWithInlineData {
+    class AbstractWorker : public RefCounted<AbstractWorker>, public EventTargetWithInlineData {
     public:
-        // EventTarget APIs
-        virtual ScriptExecutionContext* scriptExecutionContext() const override final { return ActiveDOMObject::scriptExecutionContext(); }
-
         DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
 
         using RefCounted<AbstractWorker>::ref;
@@ -56,7 +53,7 @@ namespace WebCore {
         virtual ~AbstractWorker();
 
     protected:
-        explicit AbstractWorker(ScriptExecutionContext&);
+        AbstractWorker() = default;
 
         // Helper function that converts a URL to an absolute URL and checks the result for validity.
         URL resolveURL(const String& url, ExceptionCode& ec);
@@ -65,8 +62,6 @@ namespace WebCore {
     private:
         virtual void refEventTarget() override final { ref(); }
         virtual void derefEventTarget() override final { deref(); }
-
-        virtual const char* activeDOMObjectName() const override { return "AbstractWorker"; }
     };
 
 } // namespace WebCore
index 13bd6d6..bcb2c14 100644 (file)
@@ -60,7 +60,7 @@ void networkStateChanged(bool isOnLine)
 }
 
 inline Worker::Worker(ScriptExecutionContext& context)
-    : AbstractWorker(context)
+    : ActiveDOMObject(&context)
     , m_contextProxy(WorkerGlobalScopeProxy::create(this))
 {
     if (!allWorkers) {
@@ -132,6 +132,11 @@ bool Worker::canSuspend() const
     return false;
 }
 
+const char* Worker::activeDOMObjectName() const
+{
+    return "Worker";
+}
+
 void Worker::stop()
 {
     terminate();
index 950e8aa..db1a829 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 
     typedef int ExceptionCode;
 
-    class Worker final : public AbstractWorker, private WorkerScriptLoaderClient {
+    class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient {
     public:
         static PassRefPtr<Worker> create(ScriptExecutionContext&, const String& url, ExceptionCode&);
         virtual ~Worker();
@@ -58,13 +58,15 @@ namespace WebCore {
         void postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*, ExceptionCode&);
 
         void terminate();
-
-        virtual bool canSuspend() const override;
-        virtual void stop() override;
-        virtual bool hasPendingActivity() const override;
     
         DEFINE_ATTRIBUTE_EVENT_LISTENER(message);
 
+        // EventTarget API.
+        virtual ScriptExecutionContext* scriptExecutionContext() const override final { return ActiveDOMObject::scriptExecutionContext(); }
+
+        // ActiveDOMObject API.
+        bool hasPendingActivity() const override;
+
     private:
         explicit Worker(ScriptExecutionContext&);
 
@@ -74,6 +76,11 @@ namespace WebCore {
         virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override;
         virtual void notifyFinished() override;
 
+        // ActiveDOMObject API.
+        bool canSuspend() const override;
+        void stop() override;
+        const char* activeDOMObjectName() const override;
+
         friend void networkStateChanged(bool isOnLine);
 
         RefPtr<WorkerScriptLoader> m_scriptLoader;
index 5560f3c..c096cb1 100644 (file)
@@ -1256,6 +1256,11 @@ bool XMLHttpRequest::canSuspend() const
     return !m_loader;
 }
 
+const char* XMLHttpRequest::activeDOMObjectName() const
+{
+    return "XMLHttpRequest";
+}
+
 void XMLHttpRequest::suspend(ReasonForSuspension)
 {
     m_progressEventThrottle.suspend();
index d4bb121..f5eb77f 100644 (file)
@@ -162,12 +162,12 @@ private:
     explicit XMLHttpRequest(ScriptExecutionContext&);
 
     // ActiveDOMObject
-    virtual void contextDestroyed() override;
-    virtual bool canSuspend() const override;
-    virtual void suspend(ReasonForSuspension) override;
-    virtual void resume() override;
-    virtual void stop() override;
-    virtual const char* activeDOMObjectName() const override { return "XMLHttpRequest"; }
+    void contextDestroyed() override;
+    bool canSuspend() const override;
+    void suspend(ReasonForSuspension) override;
+    void resume() override;
+    void stop() override;
+    const char* activeDOMObjectName() const override;
 
     virtual void refEventTarget() override { ref(); }
     virtual void derefEventTarget() override { deref(); }
index 4442692..333f467 100644 (file)
@@ -1264,14 +1264,19 @@ void WebView::frameRect(RECT* rect)
     ::GetWindowRect(m_viewWindow, rect);
 }
 
-class WindowCloseTimer : public WebCore::SuspendableTimer {
+class WindowCloseTimer final : public WebCore::SuspendableTimer {
 public:
     static WindowCloseTimer* create(WebView*);
 
 private:
     WindowCloseTimer(ScriptExecutionContext&, WebView*);
-    virtual void contextDestroyed();
-    virtual void fired();
+
+    // ActiveDOMObject API.
+    void contextDestroyed() override;
+    const char* activeDOMObjectName() const override { return "WindowCloseTimer"; }
+
+    // SuspendableTimer API.
+    void fired() override;
 
     WebView* m_webView;
 };