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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 ScriptValue exception; | 61 ScriptValue exception; |
62 }; | 62 }; |
63 | 63 |
64 class WorkerScriptController { | 64 class WorkerScriptController { |
65 public: | 65 public: |
66 explicit WorkerScriptController(WorkerGlobalScope&); | 66 explicit WorkerScriptController(WorkerGlobalScope&); |
67 ~WorkerScriptController(); | 67 ~WorkerScriptController(); |
68 | 68 |
69 WorkerGlobalScope& workerGlobalScope() { return m_workerGlobalScope; } | 69 WorkerGlobalScope& workerGlobalScope() { return m_workerGlobalScope; } |
70 | 70 |
| 71 bool initializeContextIfNeeded(); |
| 72 |
71 void evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* =
0); | 73 void evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* =
0); |
72 | 74 |
73 void rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEven
t>); | 75 void rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEven
t>); |
74 | 76 |
75 // Async request to terminate a future JS execution. Eventually causes t
ermination | 77 // Async request to terminate a future JS execution. Eventually causes t
ermination |
76 // exception raised during JS execution, if the worker thread happens to
run JS. | 78 // exception raised during JS execution, if the worker thread happens to
run JS. |
77 // After JS execution was terminated in this way, the Worker thread has
to use | 79 // After JS execution was terminated in this way, the Worker thread has
to use |
78 // forbidExecution()/isExecutionForbidden() to guard against reentry int
o JS. | 80 // forbidExecution()/isExecutionForbidden() to guard against reentry int
o JS. |
79 // Can be called from any thread. | 81 // Can be called from any thread. |
80 void scheduleExecutionTermination(); | 82 void scheduleExecutionTermination(); |
(...skipping 13 matching lines...) Expand all Loading... |
94 DOMWrapperWorld& world() const { return *m_world; } | 96 DOMWrapperWorld& world() const { return *m_world; } |
95 ScriptState* scriptState() { return m_scriptState.get(); } | 97 ScriptState* scriptState() { return m_scriptState.get(); } |
96 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState-
>context() : v8::Local<v8::Context>(); } | 98 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState-
>context() : v8::Local<v8::Context>(); } |
97 bool isContextInitialized() { return m_scriptState && !!m_scriptState->p
erContextData(); } | 99 bool isContextInitialized() { return m_scriptState && !!m_scriptState->p
erContextData(); } |
98 | 100 |
99 // Send a notification about current thread is going to be idle. | 101 // Send a notification about current thread is going to be idle. |
100 // Returns true if the embedder should stop calling idleNotification | 102 // Returns true if the embedder should stop calling idleNotification |
101 // until real work has been done. | 103 // until real work has been done. |
102 bool idleNotification() { return v8::V8::IdleNotification(); } | 104 bool idleNotification() { return v8::V8::IdleNotification(); } |
103 | 105 |
| 106 |
104 private: | 107 private: |
105 bool initializeContextIfNeeded(); | |
106 | |
107 v8::Isolate* m_isolate; | 108 v8::Isolate* m_isolate; |
108 WorkerGlobalScope& m_workerGlobalScope; | 109 WorkerGlobalScope& m_workerGlobalScope; |
109 RefPtr<ScriptState> m_scriptState; | 110 RefPtr<ScriptState> m_scriptState; |
110 RefPtr<DOMWrapperWorld> m_world; | 111 RefPtr<DOMWrapperWorld> m_world; |
111 String m_disableEvalPending; | 112 String m_disableEvalPending; |
112 bool m_executionForbidden; | 113 bool m_executionForbidden; |
113 bool m_executionScheduledToTerminate; | 114 bool m_executionScheduledToTerminate; |
114 mutable Mutex m_scheduledTerminationMutex; | 115 mutable Mutex m_scheduledTerminationMutex; |
115 RefPtrWillBePersistent<ErrorEvent> m_errorEventFromImportedScript; | 116 RefPtrWillBePersistent<ErrorEvent> m_errorEventFromImportedScript; |
116 OwnPtr<V8IsolateInterruptor> m_interruptor; | 117 OwnPtr<V8IsolateInterruptor> m_interruptor; |
117 }; | 118 }; |
118 | 119 |
119 } // namespace WebCore | 120 } // namespace WebCore |
120 | 121 |
121 #endif // WorkerScriptController_h | 122 #endif // WorkerScriptController_h |
OLD | NEW |