| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SuspendableScriptExecutor_h | 5 #ifndef SuspendableScriptExecutor_h |
| 6 #define SuspendableScriptExecutor_h | 6 #define SuspendableScriptExecutor_h |
| 7 | 7 |
| 8 #include "core/frame/SuspendableTimer.h" | 8 #include "core/frame/SuspendableTimer.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "platform/heap/SelfKeepAlive.h" | 10 #include "platform/heap/SelfKeepAlive.h" |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 12 #include <v8.h> |
| 12 | 13 |
| 13 namespace blink { | 14 namespace blink { |
| 14 | 15 |
| 15 class LocalFrame; | 16 class LocalFrame; |
| 16 class ScriptSourceCode; | 17 class ScriptSourceCode; |
| 17 class WebScriptExecutionCallback; | 18 class WebScriptExecutionCallback; |
| 18 | 19 |
| 19 class SuspendableScriptExecutor final | 20 class SuspendableScriptExecutor final |
| 20 : public GarbageCollectedFinalized<SuspendableScriptExecutor>, | 21 : public GarbageCollectedFinalized<SuspendableScriptExecutor>, |
| 21 public SuspendableTimer { | 22 public SuspendableTimer { |
| 22 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor); | 23 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor); |
| 23 | 24 |
| 24 public: | 25 public: |
| 25 static void createAndRun(LocalFrame*, | 26 static void createAndRun(LocalFrame*, |
| 26 int worldID, | 27 int worldID, |
| 27 const HeapVector<ScriptSourceCode>& sources, | 28 const HeapVector<ScriptSourceCode>& sources, |
| 28 int extensionGroup, | 29 int extensionGroup, |
| 29 bool userGesture, | 30 bool userGesture, |
| 30 WebScriptExecutionCallback*); | 31 WebScriptExecutionCallback*); |
| 32 static void createAndRun(LocalFrame*, |
| 33 v8::Isolate*, |
| 34 v8::Local<v8::Function>, |
| 35 v8::Local<v8::Value> receiver, |
| 36 int argc, |
| 37 v8::Local<v8::Value> argv[], |
| 38 WebScriptExecutionCallback*); |
| 31 ~SuspendableScriptExecutor() override; | 39 ~SuspendableScriptExecutor() override; |
| 32 | 40 |
| 33 void contextDestroyed() override; | 41 void contextDestroyed() override; |
| 34 | 42 |
| 35 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
| 36 | 44 |
| 45 class Executor : public GarbageCollectedFinalized<Executor> { |
| 46 public: |
| 47 virtual ~Executor() {} |
| 48 |
| 49 virtual Vector<v8::Local<v8::Value>> execute(LocalFrame*) = 0; |
| 50 |
| 51 DEFINE_INLINE_VIRTUAL_TRACE(){}; |
| 52 }; |
| 53 |
| 37 private: | 54 private: |
| 38 SuspendableScriptExecutor(LocalFrame*, | 55 SuspendableScriptExecutor(LocalFrame*, |
| 39 int worldID, | 56 WebScriptExecutionCallback*, |
| 40 const HeapVector<ScriptSourceCode>& sources, | 57 Executor*); |
| 41 int extensionGroup, | |
| 42 bool userGesture, | |
| 43 WebScriptExecutionCallback*); | |
| 44 | 58 |
| 45 void fired() override; | 59 void fired() override; |
| 46 | 60 |
| 47 void run(); | 61 void run(); |
| 48 void executeAndDestroySelf(); | 62 void executeAndDestroySelf(); |
| 49 void dispose(); | 63 void dispose(); |
| 50 | 64 |
| 51 Member<LocalFrame> m_frame; | 65 Member<LocalFrame> m_frame; |
| 52 HeapVector<ScriptSourceCode> m_sources; | |
| 53 WebScriptExecutionCallback* m_callback; | 66 WebScriptExecutionCallback* m_callback; |
| 54 | 67 |
| 55 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive; | 68 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive; |
| 56 | 69 |
| 57 int m_worldID; | 70 Member<Executor> m_executor; |
| 58 int m_extensionGroup; | |
| 59 | |
| 60 bool m_userGesture; | |
| 61 }; | 71 }; |
| 62 | 72 |
| 63 } // namespace blink | 73 } // namespace blink |
| 64 | 74 |
| 65 #endif // SuspendableScriptExecutor_h | 75 #endif // SuspendableScriptExecutor_h |
| OLD | NEW |