Title: [135703] trunk/Source/WebCore
Revision
135703
Author
hara...@chromium.org
Date
2012-11-26 03:20:49 -0800 (Mon, 26 Nov 2012)

Log Message

[V8] Remove WorkerContextExecutionProxy
https://bugs.webkit.org/show_bug.cgi?id=103210

Reviewed by Adam Barth.

This patch moves all methods in WorkerContextExecutionProxy
to WorkerScriptController.

Due to the dependency between WorkerContextExecutionProxy's methods,
it is a bit difficult to split this patch into pieces.
This patch simply moves methods without changing their logic.
Also this patch doesn't remove empty WorkerContextExecutionProxy.{h,cpp}
to keep the diff sane. I will address these issues in a follow-up patch.

Tests: fast/worker/*

* bindings/v8/ScriptState.cpp:
(WebCore::scriptStateFromWorkerContext):
* bindings/v8/V8Binding.cpp:
(WebCore::toV8Context):
* bindings/v8/V8WorkerContextEventListener.cpp:
(WebCore::V8WorkerContextEventListener::handleEvent):
* bindings/v8/WorkerContextExecutionProxy.cpp:
* bindings/v8/WorkerContextExecutionProxy.h:
* bindings/v8/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::WorkerScriptController):
(WebCore::WorkerScriptController::~WorkerScriptController):
(WebCore::WorkerScriptController::dispose):
(WebCore):
(WebCore::WorkerScriptController::initializeIfNeeded):
(WebCore::WorkerScriptController::evaluate):
(WebCore::WorkerScriptController::setEvalAllowed):
(WebCore::WorkerScriptController::disableEval):
* bindings/v8/WorkerScriptController.h:
(WebCore):
(WebCore::WorkerContextExecutionState::WorkerContextExecutionState):
(WorkerContextExecutionState):
(WorkerScriptController):
(WebCore::WorkerScriptController::context):
* bindings/v8/WorkerScriptDebugServer.cpp:
(WebCore::WorkerScriptDebugServer::addListener):
* bindings/v8/custom/V8WorkerContextCustom.cpp:
(WebCore::SetTimeoutOrInterval):
(WebCore::toV8):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135702 => 135703)


--- trunk/Source/WebCore/ChangeLog	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/ChangeLog	2012-11-26 11:20:49 UTC (rev 135703)
@@ -1,3 +1,50 @@
+2012-11-26  Kentaro Hara  <hara...@chromium.org>
+
+        [V8] Remove WorkerContextExecutionProxy
+        https://bugs.webkit.org/show_bug.cgi?id=103210
+
+        Reviewed by Adam Barth.
+
+        This patch moves all methods in WorkerContextExecutionProxy
+        to WorkerScriptController.
+
+        Due to the dependency between WorkerContextExecutionProxy's methods,
+        it is a bit difficult to split this patch into pieces.
+        This patch simply moves methods without changing their logic.
+        Also this patch doesn't remove empty WorkerContextExecutionProxy.{h,cpp}
+        to keep the diff sane. I will address these issues in a follow-up patch.
+
+        Tests: fast/worker/*
+
+        * bindings/v8/ScriptState.cpp:
+        (WebCore::scriptStateFromWorkerContext):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::toV8Context):
+        * bindings/v8/V8WorkerContextEventListener.cpp:
+        (WebCore::V8WorkerContextEventListener::handleEvent):
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        * bindings/v8/WorkerContextExecutionProxy.h:
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::WorkerScriptController):
+        (WebCore::WorkerScriptController::~WorkerScriptController):
+        (WebCore::WorkerScriptController::dispose):
+        (WebCore):
+        (WebCore::WorkerScriptController::initializeIfNeeded):
+        (WebCore::WorkerScriptController::evaluate):
+        (WebCore::WorkerScriptController::setEvalAllowed):
+        (WebCore::WorkerScriptController::disableEval):
+        * bindings/v8/WorkerScriptController.h:
+        (WebCore):
+        (WebCore::WorkerContextExecutionState::WorkerContextExecutionState):
+        (WorkerContextExecutionState):
+        (WorkerScriptController):
+        (WebCore::WorkerScriptController::context):
+        * bindings/v8/WorkerScriptDebugServer.cpp:
+        (WebCore::WorkerScriptDebugServer::addListener):
+        * bindings/v8/custom/V8WorkerContextCustom.cpp:
+        (WebCore::SetTimeoutOrInterval):
+        (WebCore::toV8):
+
 2012-11-26  Hajime Morrita  <morr...@google.com>
 
         [Refactoring] Some Node::isDescendant calls can be replaced with Node::contains()

Modified: trunk/Source/WebCore/bindings/v8/ScriptState.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/ScriptState.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/ScriptState.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -39,7 +39,6 @@
 #include "V8HiddenPropertyName.h"
 #include "V8WorkerContext.h"
 #include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
 #include "WorkerScriptController.h"
 #include <v8.h>
 #include <wtf/Assertions.h>
@@ -142,13 +141,12 @@
 #if ENABLE(WORKERS)
 ScriptState* scriptStateFromWorkerContext(WorkerContext* workerContext)
 {
-    WorkerContextExecutionProxy* proxy = workerContext->script()->proxy();
-    if (!proxy)
+    WorkerScriptController* script = workerContext->script();
+    if (!script)
         return 0;
 
     v8::HandleScope handleScope;
-    v8::Local<v8::Context> context = proxy->context();
-    return ScriptState::forContext(context);
+    return ScriptState::forContext(script->context());
 }
 #endif
 

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -47,7 +47,7 @@
 #include "V8XPathNSResolver.h"
 #include "WebCoreMemoryInstrumentation.h"
 #include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
+#include "WorkerScriptController.h"
 #include "WorldContextHandle.h"
 #include "XPathNSResolver.h"
 #include <wtf/MathExtras.h>
@@ -311,8 +311,8 @@
             return worldContext.adjustedContext(frame->script());
 #if ENABLE(WORKERS)
     } else if (context->isWorkerContext()) {
-        if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(context)->script()->proxy())
-            return proxy->context();
+        if (WorkerScriptController* script = static_cast<WorkerContext*>(context)->script())
+            return script->context();
 #endif
     }
     return v8::Local<v8::Context>();

Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextEventListener.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -41,17 +41,10 @@
 #include "V8GCController.h"
 #include "V8RecursionScope.h"
 #include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
+#include "WorkerScriptController.h"
 
 namespace WebCore {
 
-static WorkerContextExecutionProxy* workerProxy(ScriptExecutionContext* context)
-{
-    ASSERT(context->isWorkerContext());
-    WorkerContext* workerContext = static_cast<WorkerContext*>(context);
-    return workerContext->script()->proxy();
-}
-
 V8WorkerContextEventListener::V8WorkerContextEventListener(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
     : V8EventListener(listener, isInline, worldContext)
 {
@@ -68,11 +61,12 @@
 
     v8::HandleScope handleScope;
 
-    WorkerContextExecutionProxy* proxy = workerProxy(context);
-    if (!proxy)
+    ASSERT(context->isWorkerContext());
+    WorkerScriptController* script = static_cast<WorkerContext*>(context)->script();
+    if (!script)
         return;
 
-    v8::Handle<v8::Context> v8Context = proxy->context();
+    v8::Handle<v8::Context> v8Context = script->context();
     if (v8Context.IsEmpty())
         return;
 

Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -28,6 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// FIXME: This file is going to be removed in a follow-up patch.
 
 #include "config.h"
 
@@ -59,128 +60,6 @@
 
 namespace WebCore {
 
-WorkerContextExecutionProxy::WorkerContextExecutionProxy(WorkerContext* workerContext)
-    : m_workerContext(workerContext)
-    , m_disableEvalPending(String())
-{
-    V8Initializer::initializeWorker();
-}
-
-WorkerContextExecutionProxy::~WorkerContextExecutionProxy()
-{
-    dispose();
-}
-
-void WorkerContextExecutionProxy::dispose()
-{
-    m_perContextData.clear();
-    m_context.clear();
-}
-
-bool WorkerContextExecutionProxy::initializeIfNeeded()
-{
-    // Bail out if the context has already been initialized.
-    if (!m_context.isEmpty())
-        return true;
-
-    // Create a new environment
-    v8::Persistent<v8::ObjectTemplate> globalTemplate;
-    m_context.adopt(v8::Context::New(0, globalTemplate));
-    if (m_context.isEmpty())
-        return false;
-
-    // Starting from now, use local context only.
-    v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
-
-    v8::Context::Scope scope(context);
-
-    m_perContextData = V8PerContextData::create(m_context.get());
-    if (!m_perContextData->init()) {
-        dispose();
-        return false;
-    }
-
-    // Set DebugId for the new context.
-    context->SetEmbedderData(0, v8::String::New("worker"));
-
-    // Create a new JS object and use it as the prototype for the shadow global object.
-    WrapperTypeInfo* contextType = &V8DedicatedWorkerContext::info;
-#if ENABLE(SHARED_WORKERS)
-    if (!m_workerContext->isDedicatedWorkerContext())
-        contextType = &V8SharedWorkerContext::info;
-#endif
-    v8::Handle<v8::Function> workerContextConstructor = m_perContextData->constructorForType(contextType);
-    v8::Local<v8::Object> jsWorkerContext = V8ObjectConstructor::newInstance(workerContextConstructor);
-    // Bail out if allocation failed.
-    if (jsWorkerContext.IsEmpty()) {
-        dispose();
-        return false;
-    }
-
-    // Wrap the object.
-    V8DOMWrapper::createDOMWrapper(PassRefPtr<WorkerContext>(m_workerContext), contextType, jsWorkerContext);
-
-    // Insert the object instance as the prototype of the shadow object.
-    v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype());
-    globalObject->SetPrototype(jsWorkerContext);
-
-    return true;
-}
-
-ScriptValue WorkerContextExecutionProxy::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState* state)
-{
-    V8GCController::checkMemoryUsage();
-
-    v8::HandleScope hs;
-
-    if (!initializeIfNeeded())
-        return ScriptValue();
-
-    if (!m_disableEvalPending.isEmpty()) {
-        m_context->AllowCodeGenerationFromStrings(false);
-        m_context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_disableEvalPending));
-        m_disableEvalPending = String();
-    }
-
-    v8::Context::Scope scope(m_context.get());
-
-    v8::TryCatch exceptionCatcher;
-
-    v8::Local<v8::String> scriptString = v8ExternalString(script);
-    v8::Handle<v8::Script> compiledScript = ScriptSourceCode::compileScript(scriptString, fileName, scriptStartPosition);
-    v8::Local<v8::Value> result = ScriptRunner::runCompiledScript(compiledScript, m_workerContext);
-
-    if (!exceptionCatcher.CanContinue()) {
-        m_workerContext->script()->forbidExecution();
-        return ScriptValue();
-    }
-
-    if (exceptionCatcher.HasCaught()) {
-        v8::Local<v8::Message> message = exceptionCatcher.Message();
-        state->hadException = true;
-        state->errorMessage = toWebCoreString(message->Get());
-        state->lineNumber = message->GetLineNumber();
-        state->sourceURL = toWebCoreString(message->GetScriptResourceName());
-        if (m_workerContext->sanitizeScriptError(state->errorMessage, state->lineNumber, state->sourceURL))
-            state->exception = throwError(v8GeneralError, state->errorMessage.utf8().data());
-        else
-            state->exception = ScriptValue(exceptionCatcher.Exception());
-
-        exceptionCatcher.Reset();
-    } else
-        state->hadException = false;
-
-    if (result.IsEmpty() || result->IsUndefined())
-        return ScriptValue();
-
-    return ScriptValue(result);
-}
-
-void WorkerContextExecutionProxy::setEvalAllowed(bool enable, const String& errorMessage)
-{
-    m_disableEvalPending = enable ? String() : errorMessage;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(WORKERS)

Modified: trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.h	2012-11-26 11:20:49 UTC (rev 135703)
@@ -28,6 +28,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// FIXME: This file is going to be removed in a follow-up patch.
 
 #ifndef WorkerContextExecutionProxy_h
 #define WorkerContextExecutionProxy_h
@@ -42,51 +43,6 @@
 
 namespace WebCore {
 
-    class Event;
-    class EventTarget;
-    class V8PerContextData;
-    class WorkerContext;
-    struct WrapperTypeInfo;
-
-    struct WorkerContextExecutionState {
-        WorkerContextExecutionState()
-            : hadException(false)
-            , lineNumber(0)
-        {
-        }
-
-        bool hadException;
-        ScriptValue exception;
-        String errorMessage;
-        int lineNumber;
-        String sourceURL;
-    };
-
-    class WorkerContextExecutionProxy {
-    public:
-        explicit WorkerContextExecutionProxy(WorkerContext*);
-        ~WorkerContextExecutionProxy();
-
-        // Alow use of eval() and is equivalents in scripts.
-        void setEvalAllowed(bool enable, const String& errorMessage);
-
-        // Evaluate a script file in the current execution environment.
-        ScriptValue evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState*);
-
-        // Returns a local handle of the context.
-        v8::Local<v8::Context> context() { return v8::Local<v8::Context>::New(m_context.get()); }
-
-    private:
-        void initIsolate();
-        bool initializeIfNeeded();
-        void dispose();
-
-        WorkerContext* m_workerContext;
-        ScopedPersistent<v8::Context> m_context;
-        OwnPtr<V8PerContextData> m_perContextData;
-        String m_disableEvalPending;
-    };
-
 } // namespace WebCore
 
 #endif // ENABLE(WORKERS)

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -36,8 +36,12 @@
 
 #include "DOMTimer.h"
 #include "ScriptCallStack.h"
+#include "ScriptRunner.h"
 #include "ScriptSourceCode.h"
 #include "ScriptValue.h"
+#include "V8DedicatedWorkerContext.h"
+#include "V8Initializer.h"
+#include "V8SharedWorkerContext.h"
 #include "V8WorkerContext.h"
 #include "WorkerContext.h"
 #include "WorkerContextExecutionProxy.h"
@@ -62,7 +66,8 @@
     m_isolate->Enter();
     m_domDataStore = adoptPtr(new DOMDataStore(DOMDataStore::Worker));
     data->setDOMDataStore(m_domDataStore.get());
-    m_proxy = adoptPtr(new WorkerContextExecutionProxy(workerContext));
+
+    V8Initializer::initializeWorker();
 }
 
 WorkerScriptController::~WorkerScriptController()
@@ -74,12 +79,118 @@
     // See http://webkit.org/b/83104#c14 for why this is here.
     WebKit::Platform::current()->didStopWorkerRunLoop(WebKit::WebWorkerRunLoop(&m_workerContext->thread()->runLoop()));
 #endif
-    m_proxy.clear();
+    dispose();
     V8PerIsolateData::dispose(m_isolate);
     m_isolate->Exit();
     m_isolate->Dispose();
 }
 
+void WorkerScriptController::dispose()
+{
+    m_perContextData.clear();
+    m_context.clear();
+}
+
+bool WorkerScriptController::initializeIfNeeded()
+{
+    if (!m_context.isEmpty())
+        return true;
+
+    v8::Persistent<v8::ObjectTemplate> globalTemplate;
+    m_context.adopt(v8::Context::New(0, globalTemplate));
+    if (m_context.isEmpty())
+        return false;
+
+    // Starting from now, use local context only.
+    v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_context.get());
+
+    v8::Context::Scope scope(context);
+
+    m_perContextData = V8PerContextData::create(m_context.get());
+    if (!m_perContextData->init()) {
+        dispose();
+        return false;
+    }
+
+    // Set DebugId for the new context.
+    context->SetEmbedderData(0, v8::String::New("worker"));
+
+    // Create a new JS object and use it as the prototype for the shadow global object.
+    WrapperTypeInfo* contextType = &V8DedicatedWorkerContext::info;
+#if ENABLE(SHARED_WORKERS)
+    if (!m_workerContext->isDedicatedWorkerContext())
+        contextType = &V8SharedWorkerContext::info;
+#endif
+    v8::Handle<v8::Function> workerContextConstructor = m_perContextData->constructorForType(contextType);
+    v8::Local<v8::Object> jsWorkerContext = V8ObjectConstructor::newInstance(workerContextConstructor);
+    if (jsWorkerContext.IsEmpty()) {
+        dispose();
+        return false;
+    }
+
+    V8DOMWrapper::createDOMWrapper(PassRefPtr<WorkerContext>(m_workerContext), contextType, jsWorkerContext);
+
+    // Insert the object instance as the prototype of the shadow object.
+    v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype());
+    globalObject->SetPrototype(jsWorkerContext);
+
+    return true;
+}
+
+ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState* state)
+{
+    V8GCController::checkMemoryUsage();
+
+    v8::HandleScope handleScope;
+
+    if (!initializeIfNeeded())
+        return ScriptValue();
+
+    if (!m_disableEvalPending.isEmpty()) {
+        m_context->AllowCodeGenerationFromStrings(false);
+        m_context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_disableEvalPending));
+        m_disableEvalPending = String();
+    }
+
+    v8::Context::Scope scope(m_context.get());
+
+    v8::TryCatch block;
+
+    v8::Local<v8::String> scriptString = v8ExternalString(script);
+    v8::Handle<v8::Script> compiledScript = ScriptSourceCode::compileScript(scriptString, fileName, scriptStartPosition);
+    v8::Local<v8::Value> result = ScriptRunner::runCompiledScript(compiledScript, m_workerContext);
+
+    if (!block.CanContinue()) {
+        m_workerContext->script()->forbidExecution();
+        return ScriptValue();
+    }
+
+    if (block.HasCaught()) {
+        v8::Local<v8::Message> message = block.Message();
+        state->hadException = true;
+        state->errorMessage = toWebCoreString(message->Get());
+        state->lineNumber = message->GetLineNumber();
+        state->sourceURL = toWebCoreString(message->GetScriptResourceName());
+        if (m_workerContext->sanitizeScriptError(state->errorMessage, state->lineNumber, state->sourceURL))
+            state->exception = throwError(v8GeneralError, state->errorMessage.utf8().data());
+        else
+            state->exception = ScriptValue(block.Exception());
+
+        block.Reset();
+    } else
+        state->hadException = false;
+
+    if (result.IsEmpty() || result->IsUndefined())
+        return ScriptValue();
+
+    return ScriptValue(result);
+}
+
+void WorkerScriptController::setEvalAllowed(bool enable, const String& errorMessage)
+{
+    m_disableEvalPending = enable ? String() : errorMessage;
+}
+
 void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
 {
     evaluate(sourceCode, 0);
@@ -91,7 +202,7 @@
         return;
 
     WorkerContextExecutionState state;
-    m_proxy->evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPosition(), &state);
+    evaluate(sourceCode.source(), sourceCode.url().string(), sourceCode.startPosition(), &state);
     if (state.hadException) {
         if (exception)
             *exception = state.exception;
@@ -133,7 +244,7 @@
 
 void WorkerScriptController::disableEval(const String& errorMessage)
 {
-    m_proxy->setEvalAllowed(false, errorMessage);
+    setEvalAllowed(false, errorMessage);
 }
 
 void WorkerScriptController::setException(const ScriptValue& exception)

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptController.h (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptController.h	2012-11-26 11:20:49 UTC (rev 135703)
@@ -33,25 +33,38 @@
 
 #if ENABLE(WORKERS)
 
+#include "ScriptValue.h"
 #include "V8Binding.h"
-
 #include <v8.h>
 #include <wtf/OwnPtr.h>
 #include <wtf/Threading.h>
+#include <wtf/text/TextPosition.h>
 
 namespace WebCore {
 
     class ScriptSourceCode;
     class ScriptValue;
     class WorkerContext;
-    class WorkerContextExecutionProxy;
 
+    struct WorkerContextExecutionState {
+        WorkerContextExecutionState()
+            : hadException(false)
+            , lineNumber(0)
+        {
+        }
+
+        bool hadException;
+        ScriptValue exception;
+        String errorMessage;
+        int lineNumber;
+        String sourceURL;
+    };
+
     class WorkerScriptController {
     public:
         WorkerScriptController(WorkerContext*);
         ~WorkerScriptController();
 
-        WorkerContextExecutionProxy* proxy() { return m_proxy.get(); }
         WorkerContext* workerContext() { return m_workerContext; }
 
         void evaluate(const ScriptSourceCode&);
@@ -74,13 +87,27 @@
 
         void disableEval(const String&);
 
+        // Alow use of eval() and is equivalents in scripts.
+        void setEvalAllowed(bool enable, const String&);
+
         // Returns WorkerScriptController for the currently executing context. 0 will be returned if the current executing context is not the worker context.
         static WorkerScriptController* controllerForContext();
 
+        // Evaluate a script file in the current execution environment.
+        ScriptValue evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerContextExecutionState*);
+
+        // Returns a local handle of the context.
+        v8::Local<v8::Context> context() { return v8::Local<v8::Context>::New(m_context.get()); }
+
     private:
+        bool initializeIfNeeded();
+        void dispose();
+
         WorkerContext* m_workerContext;
-        OwnPtr<WorkerContextExecutionProxy> m_proxy;
         v8::Isolate* m_isolate;
+        ScopedPersistent<v8::Context> m_context;
+        OwnPtr<V8PerContextData> m_perContextData;
+        String m_disableEvalPending;
         OwnPtr<DOMDataStore> m_domDataStore;
         bool m_executionForbidden;
         bool m_executionScheduledToTerminate;

Modified: trunk/Source/WebCore/bindings/v8/WorkerScriptDebugServer.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/WorkerScriptDebugServer.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/WorkerScriptDebugServer.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -35,7 +35,6 @@
 
 #include "ScriptDebugListener.h"
 #include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
 #include "WorkerDebuggerAgent.h"
 #include "WorkerThread.h"
 #include <v8.h>
@@ -66,11 +65,6 @@
     ASSERT(!m_debuggerScript.get()->IsUndefined());
     v8::Debug::SetDebugEventListener2(&WorkerScriptDebugServer::v8DebugEventCallback, v8::External::New(this));
     
-    // TODO: Should we remove |proxy|? It looks like unused now.
-    WorkerContextExecutionProxy* proxy = m_workerContext->script()->proxy();
-    if (!proxy)
-        return;
-
     v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getWorkerScripts")));
     v8::Handle<v8::Value> argv[] = { v8Undefined() };
     v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 0, argv);

Modified: trunk/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp (135702 => 135703)


--- trunk/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp	2012-11-26 11:16:09 UTC (rev 135702)
+++ trunk/Source/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp	2012-11-26 11:20:49 UTC (rev 135703)
@@ -43,7 +43,7 @@
 #include "V8WorkerContextEventListener.h"
 #include "WebSocket.h"
 #include "WorkerContext.h"
-#include "WorkerContextExecutionProxy.h"
+#include "WorkerScriptController.h"
 
 namespace WebCore {
 
@@ -59,11 +59,11 @@
     int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0;
     int timerId;
 
-    WorkerContextExecutionProxy* proxy = workerContext->script()->proxy();
-    if (!proxy)
+    WorkerScriptController* script = workerContext->script();
+    if (!script)
         return v8::Undefined();
 
-    v8::Handle<v8::Context> v8Context = proxy->context();
+    v8::Handle<v8::Context> v8Context = script->context();
     if (function->IsString()) {
         if (ContentSecurityPolicy* policy = workerContext->contentSecurityPolicy()) {
             if (!policy->allowEval())
@@ -134,11 +134,11 @@
     if (!impl)
         return v8NullWithCheck(isolate);
 
-    WorkerContextExecutionProxy* proxy = impl->script()->proxy();
-    if (!proxy)
+    WorkerScriptController* script = impl->script();
+    if (!script)
         return v8NullWithCheck(isolate);
 
-    v8::Handle<v8::Object> global = proxy->context()->Global();
+    v8::Handle<v8::Object> global = script->context()->Global();
     ASSERT(!global.IsEmpty());
     return global;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to