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

Changeset 98795 in webkit


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

MessagePort should be a ContextDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=71167

Reviewed by Eric Seidel.

I couldn't quite get rid of all the uses of the
ScriptExecutionContext::m_messagePorts in this patch. I hope to get
rid of them in the future as the "extra data" design for
ScriptExecutionContext emerges.

  • dom/ActiveDOMObject.cpp:

(WebCore::ContextDestructionObserver::contextDestroyed):

  • dom/MessagePort.cpp:

(WebCore::MessagePort::MessagePort):
(WebCore::MessagePort::contextDestroyed):

  • dom/MessagePort.h:
  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
(WebCore::ScriptExecutionContext::closeMessagePorts):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r98794 r98795  
     12011-10-28  Adam Barth  <abarth@webkit.org>
     2
     3        MessagePort should be a ContextDestructionObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=71167
     5
     6        Reviewed by Eric Seidel.
     7
     8        I couldn't quite get rid of all the uses of the
     9        ScriptExecutionContext::m_messagePorts in this patch.  I hope to get
     10        rid of them in the future as the "extra data" design for
     11        ScriptExecutionContext emerges.
     12
     13        * dom/ActiveDOMObject.cpp:
     14        (WebCore::ContextDestructionObserver::contextDestroyed):
     15        * dom/MessagePort.cpp:
     16        (WebCore::MessagePort::MessagePort):
     17        (WebCore::MessagePort::contextDestroyed):
     18        * dom/MessagePort.h:
     19        * dom/ScriptExecutionContext.cpp:
     20        (WebCore::ScriptExecutionContext::~ScriptExecutionContext):
     21        (WebCore::ScriptExecutionContext::closeMessagePorts):
     22
    1232011-10-28  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/Source/WebCore/dom/ActiveDOMObject.cpp

    r98784 r98795  
    5555void ContextDestructionObserver::contextDestroyed()
    5656{
     57    ASSERT(m_scriptExecutionContext);
    5758    m_scriptExecutionContext = 0;
    5859}
  • trunk/Source/WebCore/dom/MessagePort.cpp

    r98388 r98795  
    4242
    4343MessagePort::MessagePort(ScriptExecutionContext& scriptExecutionContext)
    44     : m_started(false)
     44    : ContextDestructionObserver(&scriptExecutionContext)
     45    , m_started(false)
    4546    , m_closed(false)
    46     , m_scriptExecutionContext(&scriptExecutionContext)
    4747{
    4848    m_scriptExecutionContext->createdMessagePort(this);
     
    153153void MessagePort::contextDestroyed()
    154154{
    155     ASSERT(m_scriptExecutionContext);
    156155    // Must be closed before blowing away the cached context, to ensure that we get no more calls to messageAvailable().
    157156    // ScriptExecutionContext::closeMessagePorts() takes care of that.
    158157    ASSERT(m_closed);
    159     m_scriptExecutionContext = 0;
     158    ContextDestructionObserver::contextDestroyed();
    160159}
    161160
  • trunk/Source/WebCore/dom/MessagePort.h

    r98388 r98795  
    2828#define MessagePort_h
    2929
     30#include "ActiveDOMObject.h"
    3031#include "EventListener.h"
    3132#include "EventTarget.h"
     
    5354    // ActiveDOMObject's features and relying on JavaScript garbage collection
    5455    // to get its lifetime right.
    55     class MessagePort : public RefCounted<MessagePort>, public EventTarget {
     56    class MessagePort : public RefCounted<MessagePort>, public EventTarget, public ContextDestructionObserver {
    5657    public:
    5758        static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(new MessagePort(scriptExecutionContext)); }
     
    122123        bool m_closed;
    123124
    124         ScriptExecutionContext* m_scriptExecutionContext;
    125125        EventTargetData m_eventTargetData;
    126126    };
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r98787 r98795  
    113113    }
    114114
    115     HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
    116     for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
    117         ASSERT((*iter)->scriptExecutionContext() == this);
    118         (*iter)->contextDestroyed();
    119     }
    120115#if ENABLE(SQL_DATABASE)
    121116    if (m_databaseThread) {
     
    301296}
    302297
    303 void ScriptExecutionContext::closeMessagePorts() {
     298void ScriptExecutionContext::closeMessagePorts()
     299{
    304300    HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
    305301    for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
Note: See TracChangeset for help on using the changeset viewer.