Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: third_party/WebKit/Source/web/SuspendableScriptExecutor.h

Issue 2633253002: Split content script injections into multiple tasks (Closed)
Patch Set: comments addressed Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 11 #include "v8/include/v8.h"
12 #include "wtf/Vector.h" 12 #include "wtf/Vector.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class LocalFrame; 16 class LocalFrame;
17 class ScriptSourceCode; 17 class ScriptSourceCode;
18 class ScriptState; 18 class ScriptState;
19 class WebScriptExecutionCallback; 19 class WebScriptExecutionCallback;
20 20
21 class SuspendableScriptExecutor final 21 class SuspendableScriptExecutor final
22 : public GarbageCollectedFinalized<SuspendableScriptExecutor>, 22 : public GarbageCollectedFinalized<SuspendableScriptExecutor>,
23 public SuspendableTimer { 23 public SuspendableTimer {
24 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor); 24 USING_GARBAGE_COLLECTED_MIXIN(SuspendableScriptExecutor);
25 25
26 public: 26 public:
27 static void createAndRun(LocalFrame*, 27 enum BlockingOption { NonBlocking, OnloadBlocking };
28 int worldID, 28
29 const HeapVector<ScriptSourceCode>& sources, 29 static SuspendableScriptExecutor* create(
30 bool userGesture, 30 LocalFrame*,
31 WebScriptExecutionCallback*); 31 int worldID,
32 const HeapVector<ScriptSourceCode>& sources,
33 bool userGesture,
34 WebScriptExecutionCallback*);
32 static void createAndRun(LocalFrame*, 35 static void createAndRun(LocalFrame*,
33 v8::Isolate*, 36 v8::Isolate*,
34 v8::Local<v8::Context>, 37 v8::Local<v8::Context>,
35 v8::Local<v8::Function>, 38 v8::Local<v8::Function>,
36 v8::Local<v8::Value> receiver, 39 v8::Local<v8::Value> receiver,
37 int argc, 40 int argc,
38 v8::Local<v8::Value> argv[], 41 v8::Local<v8::Value> argv[],
39 WebScriptExecutionCallback*); 42 WebScriptExecutionCallback*);
40 ~SuspendableScriptExecutor() override; 43 ~SuspendableScriptExecutor() override;
41 44
45 void run();
46 void runAsync(BlockingOption);
42 void contextDestroyed(ExecutionContext*) override; 47 void contextDestroyed(ExecutionContext*) override;
43 48
44 DECLARE_VIRTUAL_TRACE(); 49 DECLARE_VIRTUAL_TRACE();
45 50
46 class Executor : public GarbageCollectedFinalized<Executor> { 51 class Executor : public GarbageCollectedFinalized<Executor> {
47 public: 52 public:
48 virtual ~Executor() {} 53 virtual ~Executor() {}
49 54
50 virtual Vector<v8::Local<v8::Value>> execute(LocalFrame*) = 0; 55 virtual Vector<v8::Local<v8::Value>> execute(LocalFrame*) = 0;
51 56
52 DEFINE_INLINE_VIRTUAL_TRACE(){}; 57 DEFINE_INLINE_VIRTUAL_TRACE(){};
53 }; 58 };
54 59
55 private: 60 private:
56 SuspendableScriptExecutor(LocalFrame*, 61 SuspendableScriptExecutor(LocalFrame*,
57 ScriptState*, 62 ScriptState*,
58 WebScriptExecutionCallback*, 63 WebScriptExecutionCallback*,
59 Executor*); 64 Executor*);
60 65
61 void fired() override; 66 void fired() override;
62 67
63 void run();
64 void executeAndDestroySelf(); 68 void executeAndDestroySelf();
65 void dispose(); 69 void dispose();
66 70
67 RefPtr<ScriptState> m_scriptState; 71 RefPtr<ScriptState> m_scriptState;
68 WebScriptExecutionCallback* m_callback; 72 WebScriptExecutionCallback* m_callback;
73 BlockingOption m_blockingOption;
69 74
70 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive; 75 SelfKeepAlive<SuspendableScriptExecutor> m_keepAlive;
71 76
72 Member<Executor> m_executor; 77 Member<Executor> m_executor;
73 }; 78 };
74 79
75 } // namespace blink 80 } // namespace blink
76 81
77 #endif // SuspendableScriptExecutor_h 82 #endif // SuspendableScriptExecutor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/LocalFrameClientImpl.cpp ('k') | third_party/WebKit/Source/web/SuspendableScriptExecutor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698