Changeset 108954 in webkit


Ignore:
Timestamp:
Feb 26, 2012 9:10:08 PM (12 years ago)
Author:
abarth@webkit.org
Message:

ContextDestructionObserver should live in its own file
https://bugs.webkit.org/show_bug.cgi?id=79619

Reviewed by Hajime Morita.

WebKit prefers to have one class per file. (This patch is paying a
build system hacking debt I incurred earlier.)

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/ActiveDOMObject.cpp:

(WebCore):

  • dom/ActiveDOMObject.h:

(ActiveDOMObject):
(WebCore::ActiveDOMObject::suspendIfNeededCalled):
(WebCore::ActiveDOMObject::setPendingActivity):
(WebCore::ActiveDOMObject::unsetPendingActivity):

  • dom/ContextDestructionObserver.cpp: Added.

(WebCore):
(WebCore::ContextDestructionObserver::ContextDestructionObserver):
(WebCore::ContextDestructionObserver::~ContextDestructionObserver):
(WebCore::ContextDestructionObserver::contextDestroyed):

  • dom/ContextDestructionObserver.h: Added.

(WebCore):
(ContextDestructionObserver):
(WebCore::ContextDestructionObserver::scriptExecutionContext):

  • dom/DOMAllInOne.cpp:
Location:
trunk/Source/WebCore
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r108930 r108954  
    536536    dom/CompositionEvent.cpp
    537537    dom/ContainerNode.cpp
     538    dom/ContextDestructionObserver.cpp
    538539    dom/CustomEvent.cpp
    539540    dom/DatasetDOMStringMap.cpp
  • trunk/Source/WebCore/ChangeLog

    r108952 r108954  
     12012-02-26  Adam Barth  <abarth@webkit.org>
     2
     3        ContextDestructionObserver should live in its own file
     4        https://bugs.webkit.org/show_bug.cgi?id=79619
     5
     6        Reviewed by Hajime Morita.
     7
     8        WebKit prefers to have one class per file.  (This patch is paying a
     9        build system hacking debt I incurred earlier.)
     10
     11        * CMakeLists.txt:
     12        * GNUmakefile.list.am:
     13        * Target.pri:
     14        * WebCore.gypi:
     15        * WebCore.vcproj/WebCore.vcproj:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * dom/ActiveDOMObject.cpp:
     18        (WebCore):
     19        * dom/ActiveDOMObject.h:
     20        (ActiveDOMObject):
     21        (WebCore::ActiveDOMObject::suspendIfNeededCalled):
     22        (WebCore::ActiveDOMObject::setPendingActivity):
     23        (WebCore::ActiveDOMObject::unsetPendingActivity):
     24        * dom/ContextDestructionObserver.cpp: Added.
     25        (WebCore):
     26        (WebCore::ContextDestructionObserver::ContextDestructionObserver):
     27        (WebCore::ContextDestructionObserver::~ContextDestructionObserver):
     28        (WebCore::ContextDestructionObserver::contextDestroyed):
     29        * dom/ContextDestructionObserver.h: Added.
     30        (WebCore):
     31        (ContextDestructionObserver):
     32        (WebCore::ContextDestructionObserver::scriptExecutionContext):
     33        * dom/DOMAllInOne.cpp:
     34
    1352012-02-26  Dirk Schulze  <krit@webkit.org>
    236
  • trunk/Source/WebCore/GNUmakefile.list.am

    r108930 r108954  
    15531553        Source/WebCore/dom/ContainerNode.cpp \
    15541554        Source/WebCore/dom/ContainerNode.h \
     1555        Source/WebCore/dom/ContextDestructionObserver.cpp \
     1556        Source/WebCore/dom/ContextDestructionObserver.h \
    15551557        Source/WebCore/dom/CrossThreadTask.h \
    15561558        Source/WebCore/dom/CustomEvent.cpp \
  • trunk/Source/WebCore/Target.pri

    r108930 r108954  
    489489    dom/CompositionEvent.cpp \
    490490    dom/ContainerNode.cpp \
     491    dom/ContextDestructionObserver.cpp \
    491492    dom/CustomEvent.cpp \
    492493    dom/DecodedDataDocumentParser.cpp \
  • trunk/Source/WebCore/WebCore.gypi

    r108930 r108954  
    579579            'dom/ClipboardAccessPolicy.h',
    580580            'dom/ContainerNode.h',
     581            'dom/ContextDestructionObserver.h',
    581582            'dom/DOMImplementation.h',
    582583            'dom/DOMTimeStamp.h',
     
    50045005            'dom/ContainerNode.cpp',
    50055006            'dom/ContainerNodeAlgorithms.h',
     5007            'dom/ContextDestructionObserver.cpp',
    50065008            'dom/CrossThreadTask.h',
    50075009            'dom/CustomEvent.cpp',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r108930 r108954  
    4697146971                        </File>
    4697246972                        <File
     46973                                RelativePath="..\dom\ContextDestructionObserver.cpp"
     46974                                >
     46975                                <FileConfiguration
     46976                                        Name="Debug|Win32"
     46977                                        ExcludedFromBuild="true"
     46978                                        >
     46979                                        <Tool
     46980                                                Name="VCCLCompilerTool"
     46981                                        />
     46982                                </FileConfiguration>
     46983                                <FileConfiguration
     46984                                        Name="Release|Win32"
     46985                                        ExcludedFromBuild="true"
     46986                                        >
     46987                                        <Tool
     46988                                                Name="VCCLCompilerTool"
     46989                                        />
     46990                                </FileConfiguration>
     46991                                <FileConfiguration
     46992                                        Name="Debug_Cairo_CFLite|Win32"
     46993                                        ExcludedFromBuild="true"
     46994                                        >
     46995                                        <Tool
     46996                                                Name="VCCLCompilerTool"
     46997                                        />
     46998                                </FileConfiguration>
     46999                                <FileConfiguration
     47000                                        Name="Release_Cairo_CFLite|Win32"
     47001                                        ExcludedFromBuild="true"
     47002                                        >
     47003                                        <Tool
     47004                                                Name="VCCLCompilerTool"
     47005                                        />
     47006                                </FileConfiguration>
     47007                                <FileConfiguration
     47008                                        Name="Debug_All|Win32"
     47009                                        ExcludedFromBuild="true"
     47010                                        >
     47011                                        <Tool
     47012                                                Name="VCCLCompilerTool"
     47013                                        />
     47014                                </FileConfiguration>
     47015                                <FileConfiguration
     47016                                        Name="Production|Win32"
     47017                                        ExcludedFromBuild="true"
     47018                                        >
     47019                                        <Tool
     47020                                                Name="VCCLCompilerTool"
     47021                                        />
     47022                                </FileConfiguration>
     47023                        </File>
     47024                        <File
     47025                                RelativePath="..\dom\ContextDestructionObserver.h"
     47026                                >
     47027                        </File>
     47028                        <File
    4697347029                                RelativePath="..\dom\CrossThreadTask.h"
    4697447030                                >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r108930 r108954  
    33513351                975CA2A11303679D00E99AD9 /* JSCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 975CA29F1303679D00E99AD9 /* JSCrypto.cpp */; };
    33523352                975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 975CA2A01303679D00E99AD9 /* JSCrypto.h */; };
     3353                97627B8D14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */; };
     3354                97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    33533355                97665013144FAA4200F6BB51 /* EventFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 97665011144FAA4200F6BB51 /* EventFactory.h */; };
    33543356                9766504F144FBFFE00F6BB51 /* EventFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9766504E144FBFFE00F6BB51 /* EventFactory.cpp */; };
     
    1023410236                975CA29F1303679D00E99AD9 /* JSCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCrypto.cpp; sourceTree = "<group>"; };
    1023510237                975CA2A01303679D00E99AD9 /* JSCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCrypto.h; sourceTree = "<group>"; };
     10238                97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextDestructionObserver.cpp; sourceTree = "<group>"; };
     10239                97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextDestructionObserver.h; sourceTree = "<group>"; };
    1023610240                97665011144FAA4200F6BB51 /* EventFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventFactory.h; sourceTree = "<group>"; };
    1023710241                9766504E144FBFFE00F6BB51 /* EventFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventFactory.cpp; sourceTree = "<group>"; };
     
    2062720631                                A81872110977D3C0005826D9 /* ContainerNode.h */,
    2062820632                                E1A1470711102B1500EEC0F3 /* ContainerNodeAlgorithms.h */,
     20633                                97627B8B14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp */,
     20634                                97627B8C14FB3CEE002CDCA1 /* ContextDestructionObserver.h */,
    2062920635                                2E3FAA0811A36BF100576624 /* CrossThreadTask.h */,
    2063020636                                62CD32561157E57C0063B0A7 /* CustomEvent.cpp */,
     
    2145921465                                41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
    2146021466                                370D6EDB138454550044103E /* ContentTypeParser.h in Headers */,
     21467                                97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */,
    2146121468                                93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */,
    2146221469                                065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */,
     
    2489124898                                41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */,
    2489224899                                370D6EDA138454550044103E /* ContentTypeParser.cpp in Sources */,
     24900                                97627B8D14FB3CEE002CDCA1 /* ContextDestructionObserver.cpp in Sources */,
    2489324901                                065AD4F60B0C2EDA005A2B1D /* ContextMenuController.cpp in Sources */,
    2489424902                                06027CB30B1CC03D00884B2D /* ContextMenuItemMac.mm in Sources */,
  • trunk/Source/WebCore/dom/ActiveDOMObject.cpp

    r107239 r108954  
    3333
    3434namespace WebCore {
    35 
    36 ContextDestructionObserver::ContextDestructionObserver(ScriptExecutionContext* scriptExecutionContext)
    37     : m_scriptExecutionContext(scriptExecutionContext)
    38 {
    39     if (!m_scriptExecutionContext)
    40         return;
    41 
    42     ASSERT(m_scriptExecutionContext->isContextThread());
    43     m_scriptExecutionContext->didCreateDestructionObserver(this);
    44 }
    45 
    46 ContextDestructionObserver::~ContextDestructionObserver()
    47 {
    48     if (!m_scriptExecutionContext)
    49         return;
    50 
    51     ASSERT(m_scriptExecutionContext->isContextThread());
    52     m_scriptExecutionContext->willDestroyDestructionObserver(this);
    53 }
    54 
    55 void ContextDestructionObserver::contextDestroyed()
    56 {
    57     m_scriptExecutionContext = 0;
    58 }
    5935
    6036ActiveDOMObject::ActiveDOMObject(ScriptExecutionContext* scriptExecutionContext, void* upcastPointer)
  • trunk/Source/WebCore/dom/ActiveDOMObject.h

    r107239 r108954  
    2828#define ActiveDOMObject_h
    2929
     30#include "ContextDestructionObserver.h"
    3031#include <wtf/Assertions.h>
    3132
    3233namespace WebCore {
    3334
    34     class ScriptExecutionContext;
     35class ActiveDOMObject : public ContextDestructionObserver {
     36public:
     37    ActiveDOMObject(ScriptExecutionContext*, void* upcastPointer);
    3538
    36     // FIXME: Move this class to it's own file.
    37     class ContextDestructionObserver {
    38     public:
    39         explicit ContextDestructionObserver(ScriptExecutionContext*);
    40         virtual void contextDestroyed();
    41 
    42         ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
    43 
    44     protected:
    45         virtual ~ContextDestructionObserver();
    46 
    47         ScriptExecutionContext* m_scriptExecutionContext;
    48     };
    49 
    50     class ActiveDOMObject : public ContextDestructionObserver {
    51     public:
    52         ActiveDOMObject(ScriptExecutionContext*, void* upcastPointer);
    53 
    54         // suspendIfNeeded() should be called exactly once after object construction to synchronize
    55         // the suspend state with that in ScriptExecutionContext.
    56         void suspendIfNeeded();
     39    // suspendIfNeeded() should be called exactly once after object construction to synchronize
     40    // the suspend state with that in ScriptExecutionContext.
     41    void suspendIfNeeded();
    5742#if !ASSERT_DISABLED
    58         bool suspendIfNeededCalled() const { return m_suspendIfNeededCalled; }
     43    bool suspendIfNeededCalled() const { return m_suspendIfNeededCalled; }
    5944#endif
    6045
    61         virtual bool hasPendingActivity() const;
     46    virtual bool hasPendingActivity() const;
    6247
    63         // canSuspend() is used by the caller if there is a choice between suspending and stopping.
    64         // For example, a page won't be suspended and placed in the back/forward cache if it has
    65         // the objects that can not be suspended.
    66         // However, 'suspend' can be called even if canSuspend() would return 'false'. That
    67         // happens in step-by-step JS debugging for example - in this case it would be incorrect
    68         // to stop the object. Exact semantics of suspend is up to the object then.
    69         enum ReasonForSuspension {
    70             JavaScriptDebuggerPaused,
    71             WillShowDialog,
    72             DocumentWillBecomeInactive
    73         };
    74         virtual bool canSuspend() const;
    75         virtual void suspend(ReasonForSuspension);
    76         virtual void resume();
    77         virtual void stop();
     48    // canSuspend() is used by the caller if there is a choice between suspending and stopping.
     49    // For example, a page won't be suspended and placed in the back/forward cache if it has
     50    // the objects that can not be suspended.
     51    // However, 'suspend' can be called even if canSuspend() would return 'false'. That
     52    // happens in step-by-step JS debugging for example - in this case it would be incorrect
     53    // to stop the object. Exact semantics of suspend is up to the object then.
     54    enum ReasonForSuspension {
     55        JavaScriptDebuggerPaused,
     56        WillShowDialog,
     57        DocumentWillBecomeInactive
     58    };
     59    virtual bool canSuspend() const;
     60    virtual void suspend(ReasonForSuspension);
     61    virtual void resume();
     62    virtual void stop();
    7863
    79         template<class T> void setPendingActivity(T* thisObject)
    80         {
    81             ASSERT(thisObject == this);
    82             thisObject->ref();
    83             m_pendingActivityCount++;
    84         }
     64    template<class T> void setPendingActivity(T* thisObject)
     65    {
     66        ASSERT(thisObject == this);
     67        thisObject->ref();
     68        m_pendingActivityCount++;
     69    }
    8570
    86         template<class T> void unsetPendingActivity(T* thisObject)
    87         {
    88             ASSERT(m_pendingActivityCount > 0);
    89             --m_pendingActivityCount;
    90             thisObject->deref();
    91         }
     71    template<class T> void unsetPendingActivity(T* thisObject)
     72    {
     73        ASSERT(m_pendingActivityCount > 0);
     74        --m_pendingActivityCount;
     75        thisObject->deref();
     76    }
    9277
    93     protected:
    94         virtual ~ActiveDOMObject();
     78protected:
     79    virtual ~ActiveDOMObject();
    9580
    96     private:
    97         unsigned m_pendingActivityCount;
     81private:
     82    unsigned m_pendingActivityCount;
    9883#if !ASSERT_DISABLED
    99         bool m_suspendIfNeededCalled;
     84    bool m_suspendIfNeededCalled;
    10085#endif
    101     };
     86};
    10287
    10388} // namespace WebCore
  • trunk/Source/WebCore/dom/DOMAllInOne.cpp

    r108034 r108954  
    4444#include "CompositionEvent.cpp"
    4545#include "ContainerNode.cpp"
     46#include "ContextDestructionObserver.cpp"
    4647#include "CustomEvent.cpp"
    4748#include "DOMCoreException.cpp"
Note: See TracChangeset for help on using the changeset viewer.