Changeset 56580 in webkit


Ignore:
Timestamp:
Mar 25, 2010 5:06:31 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-25 Drew Wilson <atwilson@chromium.org>

Reviewed by Nate Chapin.

[v8] Error in getScriptExecutionContext() when worker context is terminating.
https://bugs.webkit.org/show_bug.cgi?id=36565

Removed WorkerScriptExecutionProxy::retrieve() and added WorkerScriptController::controllerForContext(). This allows
callers to differentiate between "the current context is shutting down" vs "the current context is not a worker context".

Test: Existing worker tests suffice.

  • bindings/v8/V8DOMWrapper.cpp: (WebCore::V8DOMWrapper::getConstructor): Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
  • bindings/v8/V8Utilities.cpp: (WebCore::getScriptExecutionContext): Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
  • bindings/v8/WorkerContextExecutionProxy.cpp: Removed WorkerScriptExecutionProxy::retrieve().
  • bindings/v8/WorkerContextExecutionProxy.h: Removed WorkerScriptExecutionProxy::retrieve().
  • bindings/v8/WorkerScriptController.cpp: (WebCore::WorkerScriptController::controllerForContext): Added helper function to get the WorkerScriptController for the current context.
  • bindings/v8/WorkerScriptController.h: Added declaration for controllerForContext().

2010-03-25 Drew Wilson <atwilson@chromium.org>

Reviewed by Nate Chapin.

[v8] Error in getScriptExecutionContext() when worker context is terminating
https://bugs.webkit.org/show_bug.cgi?id=36565

Test: Existing worker tests suffice.

  • src/WebWorkerClientImpl.cpp: (WebKit::WebWorkerClientImpl::createWorkerContextProxy): Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56576 r56580  
     12010-03-25  Drew Wilson  <atwilson@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        [v8] Error in getScriptExecutionContext() when worker context is terminating.
     6        https://bugs.webkit.org/show_bug.cgi?id=36565
     7
     8        Removed WorkerScriptExecutionProxy::retrieve() and added WorkerScriptController::controllerForContext(). This allows
     9        callers to differentiate between "the current context is shutting down" vs "the current context is not a worker context".
     10
     11        Test: Existing worker tests suffice.
     12
     13        * bindings/v8/V8DOMWrapper.cpp:
     14        (WebCore::V8DOMWrapper::getConstructor):
     15        Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
     16        * bindings/v8/V8Utilities.cpp:
     17        (WebCore::getScriptExecutionContext):
     18        Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
     19        * bindings/v8/WorkerContextExecutionProxy.cpp:
     20        Removed WorkerScriptExecutionProxy::retrieve().
     21        * bindings/v8/WorkerContextExecutionProxy.h:
     22        Removed WorkerScriptExecutionProxy::retrieve().
     23        * bindings/v8/WorkerScriptController.cpp:
     24        (WebCore::WorkerScriptController::controllerForContext):
     25        Added helper function to get the WorkerScriptController for the current context.
     26        * bindings/v8/WorkerScriptController.h:
     27        Added declaration for controllerForContext().
     28
    1292010-03-25  Simon Hausmann  <simon.hausmann@nokia.com>
    230
  • trunk/WebCore/bindings/v8/V8DOMWrapper.cpp

    r56527 r56580  
    163163v8::Local<v8::Function> V8DOMWrapper::getConstructor(WrapperTypeInfo* type, WorkerContext*)
    164164{
    165     WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
     165    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
     166    WorkerContextExecutionProxy* proxy = controller ? controller->proxy() : 0;
    166167    if (!proxy)
    167168        return v8::Local<v8::Function>();
  • trunk/WebCore/bindings/v8/V8Utilities.cpp

    r56329 r56580  
    129129{
    130130#if ENABLE(WORKERS)
    131     WorkerContextExecutionProxy* proxy = WorkerContextExecutionProxy::retrieve();
    132     if (proxy)
    133         return proxy->workerContext()->scriptExecutionContext();
     131    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
     132    if (controller) {
     133        WorkerContextExecutionProxy* proxy = controller->proxy();
     134        return proxy ? proxy->workerContext()->scriptExecutionContext() : 0;
     135    }
    134136#endif
    135137
  • trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

    r56452 r56580  
    4646#include "V8Proxy.h"
    4747#include "V8SharedWorkerContext.h"
    48 #include "V8WorkerContext.h"
    4948#include "Worker.h"
    5049#include "WorkerContext.h"
     
    107106        m_context.Clear();
    108107    }
    109 }
    110 
    111 WorkerContextExecutionProxy* WorkerContextExecutionProxy::retrieve()
    112 {
    113     // Happens on frame destruction, check otherwise GetCurrent() will crash.
    114     if (!v8::Context::InContext())
    115         return 0;
    116     v8::Handle<v8::Context> context = v8::Context::GetCurrent();
    117     v8::Handle<v8::Object> global = context->Global();
    118     global = V8DOMWrapper::lookupDOMWrapper(V8WorkerContext::GetTemplate(), global);
    119     // Return 0 if the current executing context is not the worker context.
    120     if (global.IsEmpty())
    121         return 0;
    122     WorkerContext* workerContext = V8WorkerContext::toNative(global);
    123     return workerContext->script()->proxy();
    124108}
    125109
  • trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.h

    r56375 r56580  
    7575        WorkerContext* workerContext() { return m_workerContext; }
    7676
    77         // Returns WorkerContextExecutionProxy object of the currently executing context. 0 will be returned if the current executing context is not the worker context.
    78         static WorkerContextExecutionProxy* retrieve();
    79 
    8077    private:
    8178        void initV8IfNeeded();
  • trunk/WebCore/bindings/v8/WorkerScriptController.cpp

    r55180 r56580  
    4242#include "V8DOMMap.h"
    4343#include "V8Proxy.h"
     44#include "V8WorkerContext.h"
    4445#include "WorkerContext.h"
    4546#include "WorkerContextExecutionProxy.h"
     
    99100}
    100101
     102WorkerScriptController* WorkerScriptController::controllerForContext()
     103{
     104    // Happens on frame destruction, check otherwise GetCurrent() will crash.
     105    if (!v8::Context::InContext())
     106        return 0;
     107    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
     108    v8::Handle<v8::Object> global = context->Global();
     109    global = V8DOMWrapper::lookupDOMWrapper(V8WorkerContext::GetTemplate(), global);
     110    // Return 0 if the current executing context is not the worker context.
     111    if (global.IsEmpty())
     112        return 0;
     113    WorkerContext* workerContext = V8WorkerContext::toNative(global);
     114    return workerContext->script();
     115}
     116
    101117} // namespace WebCore
    102118
  • trunk/WebCore/bindings/v8/WorkerScriptController.h

    r56131 r56580  
    5757
    5858        void forbidExecution();
     59        // Returns WorkerScriptController for the currently executing context. 0 will be returned if the current executing context is not the worker context.
     60        static WorkerScriptController* controllerForContext();
    5961
    6062    private:
  • trunk/WebKit/chromium/ChangeLog

    r56579 r56580  
     12010-03-25  Drew Wilson  <atwilson@chromium.org>
     2
     3        Reviewed by Nate Chapin.
     4
     5        [v8] Error in getScriptExecutionContext() when worker context is terminating
     6        https://bugs.webkit.org/show_bug.cgi?id=36565
     7
     8        Test: Existing worker tests suffice.
     9
     10        * src/WebWorkerClientImpl.cpp:
     11        (WebKit::WebWorkerClientImpl::createWorkerContextProxy):
     12        Changed to use WorkerScriptController::controllerForContext() instead of WorkerScriptExecutionProxy::retrieve().
     13
    1142010-03-25  Jeremy Orlow  <jorlow@chromium.org>
    215
  • trunk/WebKit/chromium/src/WebWorkerClientImpl.cpp

    r53586 r56580  
    4646#include "WorkerContext.h"
    4747#include "WorkerContextExecutionProxy.h"
     48#include "WorkerScriptController.h"
    4849#include "WorkerMessagingProxy.h"
    4950#include <wtf/Threading.h>
     
    9596        webWorker = webFrame->client()->createWorker(webFrame, proxy);
    9697    } else {
    97         WorkerContextExecutionProxy* currentContext =
    98         WorkerContextExecutionProxy::retrieve();
     98        WorkerScriptController* controller = WorkerScriptController::controllerForContext();
     99        WorkerContextExecutionProxy* currentContext = controller ? controller->proxy() : 0;
    99100        if (!currentContext) {
    100101            ASSERT_NOT_REACHED();
Note: See TracChangeset for help on using the changeset viewer.