| 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 15 matching lines...) Expand all Loading... |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WorkerScriptController_h | 31 #ifndef WorkerScriptController_h |
| 32 #define WorkerScriptController_h | 32 #define WorkerScriptController_h |
| 33 | 33 |
| 34 #include "bindings/v8/ScriptValue.h" | 34 #include "bindings/v8/ScriptValue.h" |
| 35 #include "bindings/v8/V8Binding.h" | 35 #include "bindings/v8/V8Binding.h" |
| 36 #include <v8.h> | 36 #include "core/dom/ErrorEvent.h" |
| 37 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
| 38 #include "wtf/Threading.h" | 38 #include "wtf/Threading.h" |
| 39 #include "wtf/text/TextPosition.h" | 39 #include "wtf/text/TextPosition.h" |
| 40 #include <v8.h> |
| 40 | 41 |
| 41 namespace WebCore { | 42 namespace WebCore { |
| 42 | 43 |
| 43 class ScriptSourceCode; | 44 class ScriptSourceCode; |
| 44 class ScriptValue; | 45 class ScriptValue; |
| 45 class WorkerGlobalScope; | 46 class WorkerGlobalScope; |
| 46 | 47 |
| 47 struct WorkerGlobalScopeExecutionState { | 48 struct WorkerGlobalScopeExecutionState { |
| 48 WorkerGlobalScopeExecutionState() | 49 WorkerGlobalScopeExecutionState() |
| 49 : hadException(false) | 50 : hadException(false) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 String sourceURL; | 61 String sourceURL; |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 class WorkerScriptController { | 64 class WorkerScriptController { |
| 64 public: | 65 public: |
| 65 WorkerScriptController(WorkerGlobalScope*); | 66 WorkerScriptController(WorkerGlobalScope*); |
| 66 ~WorkerScriptController(); | 67 ~WorkerScriptController(); |
| 67 | 68 |
| 68 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope; } | 69 WorkerGlobalScope* workerGlobalScope() { return m_workerGlobalScope; } |
| 69 | 70 |
| 70 void evaluate(const ScriptSourceCode&, ScriptValue* = 0); | 71 void evaluate(const ScriptSourceCode&, RefPtr<ErrorEvent>* = 0); |
| 71 | 72 |
| 72 void setException(const ScriptValue&); | 73 void rethrowExceptionFromImportedScript(PassRefPtr<ErrorEvent>); |
| 73 | 74 |
| 74 // Async request to terminate a future JS execution. Eventually causes t
ermination | 75 // Async request to terminate a future JS execution. Eventually causes t
ermination |
| 75 // exception raised during JS execution, if the worker thread happens to
run JS. | 76 // exception raised during JS execution, if the worker thread happens to
run JS. |
| 76 // After JS execution was terminated in this way, the Worker thread has
to use | 77 // After JS execution was terminated in this way, the Worker thread has
to use |
| 77 // forbidExecution()/isExecutionForbidden() to guard against reentry int
o JS. | 78 // forbidExecution()/isExecutionForbidden() to guard against reentry int
o JS. |
| 78 // Can be called from any thread. | 79 // Can be called from any thread. |
| 79 void scheduleExecutionTermination(); | 80 void scheduleExecutionTermination(); |
| 80 bool isExecutionTerminating() const; | 81 bool isExecutionTerminating() const; |
| 81 | 82 |
| 82 // Called on Worker thread when JS exits with termination exception caus
ed by forbidExecution() request, | 83 // Called on Worker thread when JS exits with termination exception caus
ed by forbidExecution() request, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 106 | 107 |
| 107 WorkerGlobalScope* m_workerGlobalScope; | 108 WorkerGlobalScope* m_workerGlobalScope; |
| 108 v8::Isolate* m_isolate; | 109 v8::Isolate* m_isolate; |
| 109 ScopedPersistent<v8::Context> m_context; | 110 ScopedPersistent<v8::Context> m_context; |
| 110 OwnPtr<V8PerContextData> m_perContextData; | 111 OwnPtr<V8PerContextData> m_perContextData; |
| 111 String m_disableEvalPending; | 112 String m_disableEvalPending; |
| 112 OwnPtr<DOMDataStore> m_domDataStore; | 113 OwnPtr<DOMDataStore> m_domDataStore; |
| 113 bool m_executionForbidden; | 114 bool m_executionForbidden; |
| 114 bool m_executionScheduledToTerminate; | 115 bool m_executionScheduledToTerminate; |
| 115 mutable Mutex m_scheduledTerminationMutex; | 116 mutable Mutex m_scheduledTerminationMutex; |
| 117 RefPtr<ErrorEvent> m_errorEventFromImportedScript; |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 } // namespace WebCore | 120 } // namespace WebCore |
| 119 | 121 |
| 120 #endif // WorkerScriptController_h | 122 #endif // WorkerScriptController_h |
| OLD | NEW |