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 <v8.h> | 42 #include <v8.h> |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class CachedMetadataHandler; | 46 class CachedMetadataHandler; |
47 class ErrorEvent; | 47 class ErrorEvent; |
48 class ExceptionState; | 48 class ExceptionState; |
49 class ScriptSourceCode; | 49 class ScriptSourceCode; |
50 class WorkerGlobalScope; | 50 class WorkerGlobalScope; |
51 | 51 |
52 class CORE_EXPORT WorkerScriptController { | 52 class CORE_EXPORT WorkerScriptController : public NoBaseWillBeGarbageCollectedFi
nalized<WorkerScriptController> { |
53 public: | 53 public: |
54 WorkerScriptController(WorkerGlobalScope&, v8::Isolate*); | 54 static PassOwnPtrWillBeRawPtr<WorkerScriptController> create(WorkerGlobalSco
pe*, v8::Isolate*); |
55 ~WorkerScriptController(); | 55 virtual ~WorkerScriptController(); |
| 56 void dispose(); |
56 | 57 |
57 bool isExecutionForbidden() const; | 58 bool isExecutionForbidden() const; |
58 bool isExecutionTerminating() const; | 59 bool isExecutionTerminating() const; |
59 | 60 |
60 // Returns true if the evaluation completed with no uncaught exception. | 61 // Returns true if the evaluation completed with no uncaught exception. |
61 bool evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = nul
lptr, CachedMetadataHandler* = nullptr, V8CacheOptions = V8CacheOptionsDefault); | 62 bool evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = nul
lptr, CachedMetadataHandler* = nullptr, V8CacheOptions = V8CacheOptionsDefault); |
62 | 63 |
63 // Prevents future JavaScript execution. See | 64 // Prevents future JavaScript execution. See |
64 // willScheduleExecutionTermination, isExecutionForbidden. | 65 // willScheduleExecutionTermination, isExecutionForbidden. |
65 void forbidExecution(); | 66 void forbidExecution(); |
(...skipping 13 matching lines...) Expand all Loading... |
79 void disableEval(const String&); | 80 void disableEval(const String&); |
80 | 81 |
81 // Used by Inspector agents: | 82 // Used by Inspector agents: |
82 ScriptState* scriptState() { return m_scriptState.get(); } | 83 ScriptState* scriptState() { return m_scriptState.get(); } |
83 | 84 |
84 // Used by V8 bindings: | 85 // Used by V8 bindings: |
85 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState->con
text() : v8::Local<v8::Context>(); } | 86 v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState->con
text() : v8::Local<v8::Context>(); } |
86 | 87 |
87 RejectedPromises* rejectedPromises() const { return m_rejectedPromises.get()
; } | 88 RejectedPromises* rejectedPromises() const { return m_rejectedPromises.get()
; } |
88 | 89 |
| 90 DECLARE_TRACE(); |
| 91 |
89 private: | 92 private: |
| 93 WorkerScriptController(WorkerGlobalScope*, v8::Isolate*); |
90 class WorkerGlobalScopeExecutionState; | 94 class WorkerGlobalScopeExecutionState; |
91 | 95 |
92 bool isContextInitialized() { return m_scriptState && !!m_scriptState->perCo
ntextData(); } | 96 bool isContextInitialized() { return m_scriptState && !!m_scriptState->perCo
ntextData(); } |
93 v8::Isolate* isolate() const; | 97 v8::Isolate* isolate() const; |
94 | 98 |
95 // Evaluate a script file in the current execution environment. | 99 // Evaluate a script file in the current execution environment. |
96 ScriptValue evaluate(const String& script, const String& fileName, const Tex
tPosition& scriptStartPosition, CachedMetadataHandler*, V8CacheOptions); | 100 ScriptValue evaluate(const String& script, const String& fileName, const Tex
tPosition& scriptStartPosition, CachedMetadataHandler*, V8CacheOptions); |
97 | 101 |
98 WorkerGlobalScope& m_workerGlobalScope; | 102 RawPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope; |
99 RefPtr<ScriptState> m_scriptState; | 103 RefPtr<ScriptState> m_scriptState; |
100 RefPtr<DOMWrapperWorld> m_world; | 104 RefPtr<DOMWrapperWorld> m_world; |
101 String m_disableEvalPending; | 105 String m_disableEvalPending; |
102 bool m_executionForbidden; | 106 bool m_executionForbidden; |
103 bool m_executionScheduledToTerminate; | 107 bool m_executionScheduledToTerminate; |
104 mutable Mutex m_scheduledTerminationMutex; | 108 mutable Mutex m_scheduledTerminationMutex; |
105 | 109 |
106 OwnPtrWillBePersistent<RejectedPromises> m_rejectedPromises; | 110 OwnPtrWillBeMember<RejectedPromises> m_rejectedPromises; |
107 | 111 |
108 // |m_globalScopeExecutionState| refers to a stack object | 112 // |m_globalScopeExecutionState| refers to a stack object |
109 // that evaluate() allocates; evaluate() ensuring that the | 113 // that evaluate() allocates; evaluate() ensuring that the |
110 // pointer reference to it is removed upon returning. Hence | 114 // pointer reference to it is removed upon returning. Hence |
111 // kept as a bare pointer here, and not a Persistent with | 115 // kept as a bare pointer here, and not a Persistent with |
112 // Oilpan enabled; stack scanning will visit the object and | 116 // Oilpan enabled; stack scanning will visit the object and |
113 // trace its on-heap fields. | 117 // trace its on-heap fields. |
114 GC_PLUGIN_IGNORE("394615") | 118 GC_PLUGIN_IGNORE("394615") |
115 WorkerGlobalScopeExecutionState* m_globalScopeExecutionState; | 119 WorkerGlobalScopeExecutionState* m_globalScopeExecutionState; |
116 }; | 120 }; |
117 | 121 |
118 } // namespace blink | 122 } // namespace blink |
119 | 123 |
120 #endif // WorkerScriptController_h | 124 #endif // WorkerScriptController_h |
OLD | NEW |