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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" | 42 #include "bindings/core/v8/V8SharedWorkerGlobalScope.h" |
43 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 43 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
44 #include "bindings/core/v8/WorkerScriptDebugServer.h" | 44 #include "bindings/core/v8/WorkerScriptDebugServer.h" |
45 #include "bindings/core/v8/WrapperTypeInfo.h" | 45 #include "bindings/core/v8/WrapperTypeInfo.h" |
46 #include "core/events/ErrorEvent.h" | 46 #include "core/events/ErrorEvent.h" |
47 #include "core/frame/DOMTimer.h" | 47 #include "core/frame/DOMTimer.h" |
48 #include "core/inspector/ScriptCallStack.h" | 48 #include "core/inspector/ScriptCallStack.h" |
49 #include "core/workers/SharedWorkerGlobalScope.h" | 49 #include "core/workers/SharedWorkerGlobalScope.h" |
50 #include "core/workers/WorkerGlobalScope.h" | 50 #include "core/workers/WorkerGlobalScope.h" |
51 #include "core/workers/WorkerObjectProxy.h" | 51 #include "core/workers/WorkerObjectProxy.h" |
52 #include "core/workers/WorkerThread.h" | 52 #include "core/workers/WorkerScript.h" |
53 #include "platform/heap/ThreadState.h" | 53 #include "platform/heap/ThreadState.h" |
54 #include "public/platform/Platform.h" | 54 #include "public/platform/Platform.h" |
55 #include <v8.h> | 55 #include <v8.h> |
56 | 56 |
57 namespace blink { | 57 namespace blink { |
58 | 58 |
59 class WorkerScriptController::WorkerGlobalScopeExecutionState final { | 59 class WorkerScriptController::WorkerGlobalScopeExecutionState final { |
60 STACK_ALLOCATED(); | 60 STACK_ALLOCATED(); |
61 public: | 61 public: |
62 explicit WorkerGlobalScopeExecutionState(WorkerScriptController* controller) | 62 explicit WorkerGlobalScopeExecutionState(WorkerScriptController* controller) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); | 113 m_world = DOMWrapperWorld::create(isolate, WorkerWorldId); |
114 } | 114 } |
115 | 115 |
116 WorkerScriptController::~WorkerScriptController() | 116 WorkerScriptController::~WorkerScriptController() |
117 { | 117 { |
118 m_rejectedPromises->dispose(); | 118 m_rejectedPromises->dispose(); |
119 m_rejectedPromises.clear(); | 119 m_rejectedPromises.clear(); |
120 | 120 |
121 m_world->dispose(); | 121 m_world->dispose(); |
122 | 122 |
123 // The corresponding call to didStartRunLoop() is in WorkerThread::initializ
e(). | 123 // The corresponding call to didStartRunLoop() is in WorkerScript::initializ
e(). |
124 // See http://webkit.org/b/83104#c14 for why this is here. | 124 // See http://webkit.org/b/83104#c14 for why this is here. |
125 m_workerGlobalScope.thread()->didStopRunLoop(); | 125 m_workerGlobalScope.script()->didStopRunLoop(); |
126 | 126 |
127 if (isContextInitialized()) | 127 if (isContextInitialized()) |
128 m_scriptState->disposePerContextData(); | 128 m_scriptState->disposePerContextData(); |
129 } | 129 } |
130 | 130 |
131 bool WorkerScriptController::initializeContextIfNeeded() | 131 bool WorkerScriptController::initializeContextIfNeeded() |
132 { | 132 { |
133 v8::HandleScope handleScope(isolate()); | 133 v8::HandleScope handleScope(isolate()); |
134 | 134 |
135 if (isContextInitialized()) | 135 if (isContextInitialized()) |
(...skipping 23 matching lines...) Expand all Loading... |
159 | 159 |
160 V8DOMWrapper::associateObjectWithWrapper(isolate(), &m_workerGlobalScope, wr
apperTypeInfo, jsWorkerGlobalScope); | 160 V8DOMWrapper::associateObjectWithWrapper(isolate(), &m_workerGlobalScope, wr
apperTypeInfo, jsWorkerGlobalScope); |
161 | 161 |
162 // Insert the object instance as the prototype of the shadow object. | 162 // Insert the object instance as the prototype of the shadow object. |
163 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta
te->context()->Global()->GetPrototype()); | 163 v8::Local<v8::Object> globalObject = v8::Local<v8::Object>::Cast(m_scriptSta
te->context()->Global()->GetPrototype()); |
164 return v8CallBoolean(globalObject->SetPrototype(context, jsWorkerGlobalScope
)); | 164 return v8CallBoolean(globalObject->SetPrototype(context, jsWorkerGlobalScope
)); |
165 } | 165 } |
166 | 166 |
167 v8::Isolate* WorkerScriptController::isolate() const | 167 v8::Isolate* WorkerScriptController::isolate() const |
168 { | 168 { |
169 return m_workerGlobalScope.thread()->isolate(); | 169 return m_workerGlobalScope.script()->isolate(); |
170 } | 170 } |
171 | 171 |
172 ScriptValue WorkerScriptController::evaluate(const String& script, const String&
fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cache
Handler, V8CacheOptions v8CacheOptions) | 172 ScriptValue WorkerScriptController::evaluate(const String& script, const String&
fileName, const TextPosition& scriptStartPosition, CachedMetadataHandler* cache
Handler, V8CacheOptions v8CacheOptions) |
173 { | 173 { |
174 if (!initializeContextIfNeeded()) | 174 if (!initializeContextIfNeeded()) |
175 return ScriptValue(); | 175 return ScriptValue(); |
176 | 176 |
177 ScriptState::Scope scope(m_scriptState.get()); | 177 ScriptState::Scope scope(m_scriptState.get()); |
178 | 178 |
179 if (!m_disableEvalPending.isEmpty()) { | 179 if (!m_disableEvalPending.isEmpty()) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) | 292 void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBe
RawPtr<ErrorEvent> errorEvent, ExceptionState& exceptionState) |
293 { | 293 { |
294 const String& errorMessage = errorEvent->message(); | 294 const String& errorMessage = errorEvent->message(); |
295 if (m_globalScopeExecutionState) | 295 if (m_globalScopeExecutionState) |
296 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; | 296 m_globalScopeExecutionState->m_errorEventFromImportedScript = errorEvent
; |
297 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola
te(), errorMessage)); | 297 exceptionState.rethrowV8Exception(V8ThrowException::createGeneralError(isola
te(), errorMessage)); |
298 } | 298 } |
299 | 299 |
300 } // namespace blink | 300 } // namespace blink |
OLD | NEW |