⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 98787 in webkit


Ignore:
Timestamp:
Oct 28, 2011, 5:30:00 PM (15 years ago)
Author:
abarth@webkit.org
Message:

Make DOMURL a ContextDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=71162

Reviewed by Eric Seidel.

This removes a bunch of hand-rolled ifdefed code.

  • dom/ActiveDOMObject.h:
    • One-argument constructors should be explicit.
  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::~ScriptExecutionContext):

  • dom/ScriptExecutionContext.h:
  • html/DOMURL.cpp:

(WebCore::DOMURL::DOMURL):
(WebCore::DOMURL::~DOMURL):

  • html/DOMURL.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98784 r98787  
     12011-10-28  Adam Barth  <abarth@webkit.org>
     2
     3        Make DOMURL a ContextDestructionObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=71162
     5
     6        Reviewed by Eric Seidel.
     7
     8        This removes a bunch of hand-rolled ifdefed code.
     9
     10        * dom/ActiveDOMObject.h:
     11            - One-argument constructors should be explicit.
     12        * dom/ScriptExecutionContext.cpp:
     13        (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
     14        * dom/ScriptExecutionContext.h:
     15        * html/DOMURL.cpp:
     16        (WebCore::DOMURL::DOMURL):
     17        (WebCore::DOMURL::~DOMURL):
     18        * html/DOMURL.h:
     19
    1202011-10-28  Adam Barth  <abarth@webkit.org>
    221
  • trunk/Source/WebCore/dom/ActiveDOMObject.h

    r98784 r98787  
    3737    class ContextDestructionObserver {
    3838    public:
    39         ContextDestructionObserver(ScriptExecutionContext*);
     39        explicit ContextDestructionObserver(ScriptExecutionContext*);
    4040        virtual void contextDestroyed();
    4141
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r98784 r98787  
    135135    for (HashSet<String>::iterator iter = m_publicBlobURLs.begin(); iter != publicBlobURLsEnd; ++iter)
    136136        ThreadableBlobRegistry::unregisterBlobURL(KURL(ParsedURLString, *iter));
    137 
    138     HashSet<DOMURL*>::iterator domUrlsEnd = m_domUrls.end();
    139     for (HashSet<DOMURL*>::iterator iter = m_domUrls.begin(); iter != domUrlsEnd; ++iter) {
    140         ASSERT((*iter)->scriptExecutionContext() == this);
    141         (*iter)->contextDestroyed();
    142     }
    143137#endif
    144138
     
    220214    m_messagePorts.remove(port);
    221215}
    222 
    223 #if ENABLE(BLOB)
    224 void ScriptExecutionContext::createdDomUrl(DOMURL* url)
    225 {
    226     ASSERT(url);
    227     m_domUrls.add(url);
    228 }
    229 
    230 void ScriptExecutionContext::destroyedDomUrl(DOMURL* url)
    231 {
    232     ASSERT(url);
    233     m_domUrls.remove(url);
    234 }
    235 #endif
    236216
    237217bool ScriptExecutionContext::canSuspendActiveDOMObjects()
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r98784 r98787  
    134134    const HashSet<MessagePort*>& messagePorts() const { return m_messagePorts; }
    135135
    136 #if ENABLE(BLOB)
    137     void createdDomUrl(DOMURL*);
    138     void destroyedDomUrl(DOMURL*);
    139     const HashSet<DOMURL*>& domUrls() const { return m_domUrls; }
    140 #endif
    141136    void ref() { refScriptExecutionContext(); }
    142137    void deref() { derefScriptExecutionContext(); }
     
    215210    HashSet<String> m_publicBlobURLs;
    216211    HashSet<String> m_publicStreamURLs;
    217     HashSet<DOMURL*> m_domUrls;
    218212#endif
    219213
  • trunk/Source/WebCore/html/DOMURL.cpp

    r95901 r98787  
    3636
    3737DOMURL::DOMURL(ScriptExecutionContext* scriptExecutionContext)
    38     : m_scriptExecutionContext(scriptExecutionContext)
     38    : ContextDestructionObserver(scriptExecutionContext)
    3939{
    40     if (m_scriptExecutionContext)
    41         m_scriptExecutionContext->createdDomUrl(this);
    4240}
    4341
    4442DOMURL::~DOMURL()
    4543{
    46     if (m_scriptExecutionContext)
    47         m_scriptExecutionContext->destroyedDomUrl(this);
    48 }
    49 
    50 void DOMURL::contextDestroyed()
    51 {
    52     ASSERT(m_scriptExecutionContext);
    53     m_scriptExecutionContext = 0;
    5444}
    5545
  • trunk/Source/WebCore/html/DOMURL.h

    r95901 r98787  
    2929#if ENABLE(BLOB)
    3030
     31#include "ActiveDOMObject.h"
    3132#include "PlatformString.h"
    3233#include <wtf/PassRefPtr.h>
     
    3940class ScriptExecutionContext;
    4041
    41 class DOMURL : public RefCounted<DOMURL> {
     42class DOMURL : public RefCounted<DOMURL>, public ContextDestructionObserver {
    4243public:
    4344    static PassRefPtr<DOMURL> create(ScriptExecutionContext* scriptExecutionContext) { return adoptRef(new DOMURL(scriptExecutionContext)); }
     
    5051    void revokeObjectURL(const String&);
    5152
    52     void contextDestroyed();
    53     ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
    54 
    5553private:
    5654    explicit DOMURL(ScriptExecutionContext*);
    57 
    58     ScriptExecutionContext* m_scriptExecutionContext;
    5955};
    6056
Note: See TracChangeset for help on using the changeset viewer.