| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WorkerOrWorkletScriptController_h | 31 #ifndef WorkerOrWorkletScriptController_h |
| 32 #define WorkerOrWorkletScriptController_h | 32 #define WorkerOrWorkletScriptController_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/RejectedPromises.h" | 34 #include "bindings/core/v8/RejectedPromises.h" |
| 35 #include "bindings/core/v8/ScriptValue.h" | 35 #include "bindings/core/v8/ScriptValue.h" |
| 36 #include "bindings/core/v8/V8Binding.h" | 36 #include "bindings/core/v8/V8Binding.h" |
| 37 #include "bindings/core/v8/V8CacheOptions.h" | 37 #include "bindings/core/v8/V8CacheOptions.h" |
| 38 #include "core/CoreExport.h" | 38 #include "core/CoreExport.h" |
| 39 #include "platform/text/CompressibleString.h" |
| 39 #include "wtf/Allocator.h" | 40 #include "wtf/Allocator.h" |
| 40 #include "wtf/OwnPtr.h" | 41 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/ThreadingPrimitives.h" | 42 #include "wtf/ThreadingPrimitives.h" |
| 42 #include "wtf/text/TextPosition.h" | 43 #include "wtf/text/TextPosition.h" |
| 43 #include <v8.h> | 44 #include <v8.h> |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 class CachedMetadataHandler; | 48 class CachedMetadataHandler; |
| 48 class ErrorEvent; | 49 class ErrorEvent; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 DECLARE_TRACE(); | 93 DECLARE_TRACE(); |
| 93 | 94 |
| 94 bool isContextInitialized() const { return m_scriptState && !!m_scriptState-
>perContextData(); } | 95 bool isContextInitialized() const { return m_scriptState && !!m_scriptState-
>perContextData(); } |
| 95 | 96 |
| 96 private: | 97 private: |
| 97 WorkerOrWorkletScriptController(WorkerOrWorkletGlobalScope*, v8::Isolate*); | 98 WorkerOrWorkletScriptController(WorkerOrWorkletGlobalScope*, v8::Isolate*); |
| 98 class ExecutionState; | 99 class ExecutionState; |
| 99 | 100 |
| 100 // Evaluate a script file in the current execution environment. | 101 // Evaluate a script file in the current execution environment. |
| 101 ScriptValue evaluate(const String& script, const String& fileName, const Tex
tPosition& scriptStartPosition, CachedMetadataHandler*, V8CacheOptions); | 102 ScriptValue evaluate(const CompressibleString& script, const String& fileNam
e, const TextPosition& scriptStartPosition, CachedMetadataHandler*, V8CacheOptio
ns); |
| 102 | 103 |
| 103 RawPtrWillBeMember<WorkerOrWorkletGlobalScope> m_globalScope; | 104 RawPtrWillBeMember<WorkerOrWorkletGlobalScope> m_globalScope; |
| 104 | 105 |
| 105 // The v8 isolate associated to the (worker or worklet) global scope. For | 106 // The v8 isolate associated to the (worker or worklet) global scope. For |
| 106 // workers this should be the worker thread's isolate, while for worklets | 107 // workers this should be the worker thread's isolate, while for worklets |
| 107 // usually the main thread's isolate is used. | 108 // usually the main thread's isolate is used. |
| 108 v8::Isolate* m_isolate; | 109 v8::Isolate* m_isolate; |
| 109 | 110 |
| 110 RefPtr<ScriptState> m_scriptState; | 111 RefPtr<ScriptState> m_scriptState; |
| 111 RefPtr<DOMWrapperWorld> m_world; | 112 RefPtr<DOMWrapperWorld> m_world; |
| 112 String m_disableEvalPending; | 113 String m_disableEvalPending; |
| 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; |
| 116 | 117 |
| 117 RefPtr<RejectedPromises> m_rejectedPromises; | 118 RefPtr<RejectedPromises> m_rejectedPromises; |
| 118 | 119 |
| 119 // |m_executionState| refers to a stack object that evaluate() allocates; | 120 // |m_executionState| refers to a stack object that evaluate() allocates; |
| 120 // evaluate() ensuring that the pointer reference to it is removed upon | 121 // evaluate() ensuring that the pointer reference to it is removed upon |
| 121 // returning. Hence kept as a bare pointer here, and not a Persistent with | 122 // returning. Hence kept as a bare pointer here, and not a Persistent with |
| 122 // Oilpan enabled; stack scanning will visit the object and | 123 // Oilpan enabled; stack scanning will visit the object and |
| 123 // trace its on-heap fields. | 124 // trace its on-heap fields. |
| 124 GC_PLUGIN_IGNORE("394615") | 125 GC_PLUGIN_IGNORE("394615") |
| 125 ExecutionState* m_executionState; | 126 ExecutionState* m_executionState; |
| 126 }; | 127 }; |
| 127 | 128 |
| 128 } // namespace blink | 129 } // namespace blink |
| 129 | 130 |
| 130 #endif // WorkerOrWorkletScriptController_h | 131 #endif // WorkerOrWorkletScriptController_h |
| OLD | NEW |