Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // WorkerThread::workerThread(). | 106 // WorkerThread::workerThread(). |
| 107 // See http://webkit.org/b/83104#c14 for why this is here. | 107 // See http://webkit.org/b/83104#c14 for why this is here. |
| 108 blink::Platform::current()->didStopWorkerRunLoop(blink::WebWorkerRunLoop(&m_ workerGlobalScope.thread()->runLoop())); | 108 blink::Platform::current()->didStopWorkerRunLoop(blink::WebWorkerRunLoop(&m_ workerGlobalScope.thread()->runLoop())); |
| 109 | 109 |
| 110 if (isContextInitialized()) | 110 if (isContextInitialized()) |
| 111 m_scriptState->disposePerContextData(); | 111 m_scriptState->disposePerContextData(); |
| 112 | 112 |
| 113 ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate) ); | 113 ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate) ); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool WorkerScriptController::initializeContextIfNeeded() | 116 bool WorkerScriptController::initializeContext() |
| 117 { | 117 { |
| 118 v8::HandleScope handleScope(m_isolate); | 118 v8::HandleScope handleScope(m_isolate); |
| 119 | 119 |
| 120 if (isContextInitialized()) | 120 if (isContextInitialized()) |
| 121 return true; | 121 return true; |
| 122 | 122 |
| 123 v8::Handle<v8::Context> context = v8::Context::New(m_isolate); | 123 v8::Handle<v8::Context> context = v8::Context::New(m_isolate); |
| 124 if (context.IsEmpty()) | 124 if (context.IsEmpty()) |
| 125 return false; | 125 return false; |
| 126 | 126 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 148 | 148 |
| 149 // Insert the object instance as the prototype of the shadow object. | 149 // Insert the object instance as the prototype of the shadow object. |
| 150 v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_scriptS tate->context()->Global()->GetPrototype()); | 150 v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_scriptS tate->context()->Global()->GetPrototype()); |
| 151 globalObject->SetPrototype(jsWorkerGlobalScope); | 151 globalObject->SetPrototype(jsWorkerGlobalScope); |
| 152 | 152 |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionSt ate* state) | 156 ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionSt ate* state) |
| 157 { | 157 { |
| 158 if (!initializeContextIfNeeded()) | 158 ASSERT(isContextInitialized()); |
|
haraken
2014/05/09 10:03:22
I think it's OK to call initializeContext from Wor
horo
2014/05/09 10:22:00
That sounds reasonable.
Done.
| |
| 159 return ScriptValue(); | |
| 160 | 159 |
| 161 ScriptState::Scope scope(m_scriptState.get()); | 160 ScriptState::Scope scope(m_scriptState.get()); |
| 162 | 161 |
| 163 if (!m_disableEvalPending.isEmpty()) { | 162 if (!m_disableEvalPending.isEmpty()) { |
| 164 m_scriptState->context()->AllowCodeGenerationFromStrings(false); | 163 m_scriptState->context()->AllowCodeGenerationFromStrings(false); |
| 165 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(m_isolate, m_disableEvalPending)); | 164 m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8 String(m_isolate, m_disableEvalPending)); |
| 166 m_disableEvalPending = String(); | 165 m_disableEvalPending = String(); |
| 167 } | 166 } |
| 168 | 167 |
| 169 v8::TryCatch block; | 168 v8::TryCatch block; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 m_disableEvalPending = errorMessage; | 256 m_disableEvalPending = errorMessage; |
| 258 } | 257 } |
| 259 | 258 |
| 260 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent) | 259 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe RawPtr<ErrorEvent> errorEvent) |
| 261 { | 260 { |
| 262 m_errorEventFromImportedScript = errorEvent; | 261 m_errorEventFromImportedScript = errorEvent; |
| 263 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate), m_isolate); | 262 throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImp ortedScript->message(), m_isolate), m_isolate); |
| 264 } | 263 } |
| 265 | 264 |
| 266 } // namespace WebCore | 265 } // namespace WebCore |
| OLD | NEW |