Changeset 99328 in webkit


Ignore:
Timestamp:
Nov 4, 2011, 3:24:17 PM (14 years ago)
Author:
commit-queue@webkit.org
Message:

Allow ScriptExecutionContext::addMessage to be called from background threads.
https://bugs.webkit.org/show_bug.cgi?id=71575

Patch by Michael Nordman <michaeln@google.coom> on 2011-11-04
Reviewed by Nate Chapin.

No new tests.

  • dom/Document.cpp:

(WebCore::Document::addMessage):

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

(WebCore::ScriptExecutionContext::AddConsoleMessageTask::create):
(WebCore::ScriptExecutionContext::AddConsoleMessageTask::performTask):
(WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):

  • workers/WorkerContext.cpp:

(WebCore::WorkerContext::addMessage):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r99327 r99328  
     12011-11-04  Michael Nordman  <michaeln@google.coom>
     2
     3        Allow ScriptExecutionContext::addMessage to be called from background threads.
     4        https://bugs.webkit.org/show_bug.cgi?id=71575
     5
     6        Reviewed by Nate Chapin.
     7
     8        No new tests.
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::addMessage):
     12        * dom/ScriptExecutionContext.cpp:
     13        * dom/ScriptExecutionContext.h:
     14        (WebCore::ScriptExecutionContext::AddConsoleMessageTask::create):
     15        (WebCore::ScriptExecutionContext::AddConsoleMessageTask::performTask):
     16        (WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):
     17        * workers/WorkerContext.cpp:
     18        (WebCore::WorkerContext::addMessage):
     19
    1202011-11-04  Shawn Singh  <shawnsingh@chromium.org>
    221
  • trunk/Source/WebCore/dom/Document.cpp

    r99173 r99328  
    46044604void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
    46054605{
     4606    if (!isContextThread()) {
     4607        postTask(AddConsoleMessageTask::create(source, type, level, message));
     4608        return;
     4609    }
     4610
    46064611    if (DOMWindow* window = domWindow())
    46074612        window->console()->addMessage(source, type, level, message, lineNumber, sourceURL, callStack);
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r98802 r99328  
    8484};
    8585
     86void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionContext *context)
     87{
     88    context->addMessage(m_source, m_type, m_level, m_message, 0, String(), 0);
     89}
     90
    8691ScriptExecutionContext::ScriptExecutionContext()
    8792    : m_iteratingActiveDOMObjects(false)
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r98802 r99328  
    164164
    165165protected:
     166    class AddConsoleMessageTask : public Task {
     167    public:
     168        static PassOwnPtr<AddConsoleMessageTask> create(MessageSource source, MessageType type, MessageLevel level, const String& message)
     169        {
     170            return adoptPtr(new AddConsoleMessageTask(source, type, level, message));
     171        }
     172        virtual void performTask(ScriptExecutionContext*);
     173    private:
     174        AddConsoleMessageTask(MessageSource source, MessageType type, MessageLevel level, const String& message)
     175            : m_source(source)
     176            , m_type(type)
     177            , m_level(level)
     178            , m_message(message.isolatedCopy())
     179        {
     180        }
     181        MessageSource m_source;
     182        MessageType m_type;
     183        MessageLevel m_level;
     184        String m_message;
     185    };
     186
    166187    // Explicitly override the security origin for this script context.
    167188    // Note: It is dangerous to change the security origin of a script context
  • trunk/Source/WebCore/workers/WorkerContext.cpp

    r98656 r99328  
    300300void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
    301301{
     302    if (!isContextThread()) {
     303        postTask(AddConsoleMessageTask::create(source, type, level, message));
     304        return;
     305    }
    302306    thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, type, level, message, lineNumber, sourceURL);
    303307}
Note: See TracChangeset for help on using the changeset viewer.