Chromium Code Reviews| 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 "v8/include/v8.h" | |
|
dcheng
2016/09/27 08:30:57
Oh, maybe try cheating and putting this in <>, whi
| |
| 11 #include "wtf/Vector.h" | 12 #include "wtf/Vector.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 : public GarbageCollectedFinalized<Suspend ableScriptExecutor>, public SuspendableTimer { | 20 class SuspendableScriptExecutor final : public GarbageCollectedFinalized<Suspend ableScriptExecutor>, public SuspendableTimer { |
| 20 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor); | 21 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor); |
| 21 public: | 22 public: |
| 22 static void createAndRun(LocalFrame*, int worldID, const HeapVector<ScriptSo urceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCall back*); | 23 static void createAndRun(LocalFrame*, int worldID, const HeapVector<ScriptSo urceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCall back*); |
| 24 static void createAndRun(LocalFrame*, v8::Isolate*, v8::Local<v8::Function>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> argv[], WebScript ExecutionCallback*); | |
| 23 ~SuspendableScriptExecutor() override; | 25 ~SuspendableScriptExecutor() override; |
| 24 | 26 |
| 25 void contextDestroyed() override; | 27 void contextDestroyed() override; |
| 26 | 28 |
| 27 DECLARE_VIRTUAL_TRACE(); | 29 DECLARE_VIRTUAL_TRACE(); |
| 28 | 30 |
| 31 class Executor { | |
| 32 public: | |
| 33 virtual Vector<v8::Local<v8::Value>> execute(LocalFrame*) = 0; | |
| 34 | |
| 35 virtual void trace(Visitor*) {}; | |
| 36 }; | |
| 37 | |
| 29 private: | 38 private: |
| 30 SuspendableScriptExecutor(LocalFrame*, int worldID, const HeapVector<ScriptS ourceCode>& sources, int extensionGroup, bool userGesture, WebScriptExecutionCal lback*); | 39 SuspendableScriptExecutor(LocalFrame*, WebScriptExecutionCallback*, std::uni que_ptr<Executor>); |
| 31 | 40 |
| 32 void fired() override; | 41 void fired() override; |
| 33 | 42 |
| 34 void run(); | 43 void run(); |
| 35 void executeAndDestroySelf(); | 44 void executeAndDestroySelf(); |
| 36 void dispose(); | 45 void dispose(); |
| 37 | 46 |
| 38 Member<LocalFrame> m_frame; | 47 Member<LocalFrame> m_frame; |
| 39 HeapVector<ScriptSourceCode> m_sources; | |
| 40 WebScriptExecutionCallback* m_callback; | 48 WebScriptExecutionCallback* m_callback; |
| 41 | 49 |
| 42 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive; | 50 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive; |
| 43 | 51 |
| 44 int m_worldID; | 52 std::unique_ptr<Executor> m_executor; |
| 45 int m_extensionGroup; | |
| 46 | |
| 47 bool m_userGesture; | |
| 48 }; | 53 }; |
| 49 | 54 |
| 50 } // namespace blink | 55 } // namespace blink |
| 51 | 56 |
| 52 #endif // SuspendableScriptExecutor_h | 57 #endif // SuspendableScriptExecutor_h |
| OLD | NEW |