OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 30 matching lines...) Expand all Loading... |
41 class WebTaskRunner; | 41 class WebTaskRunner; |
42 | 42 |
43 class CORE_EXPORT ScriptRunner final : public GarbageCollected<ScriptRunner> { | 43 class CORE_EXPORT ScriptRunner final : public GarbageCollected<ScriptRunner> { |
44 WTF_MAKE_NONCOPYABLE(ScriptRunner); | 44 WTF_MAKE_NONCOPYABLE(ScriptRunner); |
45 public: | 45 public: |
46 static ScriptRunner* create(Document* document) | 46 static ScriptRunner* create(Document* document) |
47 { | 47 { |
48 return new ScriptRunner(document); | 48 return new ScriptRunner(document); |
49 } | 49 } |
50 | 50 |
51 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; | 51 // Async scripts may either execute asynchronously (as their load |
52 void queueScriptForExecution(ScriptLoader*, ExecutionType); | 52 // completes), or 'in order'. See |
| 53 // http://www.html5rocks.com/en/tutorials/speed/script-loading/ for more |
| 54 // information. |
| 55 enum AsyncExecutionType { None, Async, InOrder }; |
| 56 void queueScriptForExecution(ScriptLoader*, AsyncExecutionType); |
53 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } | 57 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } |
54 void suspend(); | 58 void suspend(); |
55 void resume(); | 59 void resume(); |
56 void notifyScriptReady(ScriptLoader*, ExecutionType); | 60 void notifyScriptReady(ScriptLoader*, AsyncExecutionType); |
57 void notifyScriptLoadError(ScriptLoader*, ExecutionType); | 61 void notifyScriptLoadError(ScriptLoader*, AsyncExecutionType); |
58 | 62 |
59 static void movePendingScript(Document&, Document&, ScriptLoader*); | 63 static void movePendingScript(Document&, Document&, ScriptLoader*); |
60 | 64 |
61 DECLARE_TRACE(); | 65 DECLARE_TRACE(); |
62 | 66 |
63 private: | 67 private: |
64 class Task; | 68 class Task; |
65 | 69 |
66 explicit ScriptRunner(Document*); | 70 explicit ScriptRunner(Document*); |
67 | 71 |
(...skipping 22 matching lines...) Expand all Loading... |
90 | 94 |
91 bool m_isSuspended; | 95 bool m_isSuspended; |
92 #ifndef NDEBUG | 96 #ifndef NDEBUG |
93 bool m_hasEverBeenSuspended; | 97 bool m_hasEverBeenSuspended; |
94 #endif | 98 #endif |
95 }; | 99 }; |
96 | 100 |
97 } // namespace blink | 101 } // namespace blink |
98 | 102 |
99 #endif // ScriptRunner_h | 103 #endif // ScriptRunner_h |
OLD | NEW |