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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #endif | 54 #endif |
55 | 55 |
56 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; | 56 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; |
57 void queueScriptForExecution(ScriptLoader*, ExecutionType); | 57 void queueScriptForExecution(ScriptLoader*, ExecutionType); |
58 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } | 58 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } |
59 void suspend(); | 59 void suspend(); |
60 void resume(); | 60 void resume(); |
61 void notifyScriptReady(ScriptLoader*, ExecutionType); | 61 void notifyScriptReady(ScriptLoader*, ExecutionType); |
62 void notifyScriptLoadError(ScriptLoader*, ExecutionType); | 62 void notifyScriptLoadError(ScriptLoader*, ExecutionType); |
63 | 63 |
64 static void movePendingAsyncScript(Document&, Document&, ScriptLoader*); | 64 static void movePendingScript(Document&, Document&, ScriptLoader*); |
65 | 65 |
66 DECLARE_TRACE(); | 66 DECLARE_TRACE(); |
67 | 67 |
68 private: | 68 private: |
69 class Task; | 69 class Task; |
70 | 70 |
71 explicit ScriptRunner(Document*); | 71 explicit ScriptRunner(Document*); |
72 | 72 |
73 void addPendingAsyncScript(ScriptLoader*); | 73 void movePendingScript(ScriptRunner*, ScriptLoader*); |
74 | 74 bool removePendingInOrderScript(ScriptLoader*); |
75 void movePendingAsyncScript(ScriptRunner*, ScriptLoader*); | |
76 | 75 |
77 void postTask(const WebTraceLocation&); | 76 void postTask(const WebTraceLocation&); |
78 | 77 |
79 bool executeTaskFromQueue(WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>>*
); | 78 bool executeTaskFromQueue(WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>>*
); |
80 | 79 |
81 void executeTask(); | 80 void executeTask(); |
82 | 81 |
83 RawPtrWillBeMember<Document> m_document; | 82 RawPtrWillBeMember<Document> m_document; |
84 | 83 |
85 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_pendingInOrderScripts; | 84 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_pendingInOrderScripts; |
86 WillBeHeapHashSet<RawPtrWillBeMember<ScriptLoader>> m_pendingAsyncScripts; | 85 WillBeHeapHashSet<RawPtrWillBeMember<ScriptLoader>> m_pendingAsyncScripts; |
87 | 86 |
88 // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-wi
ll-execute-as-soon-as-possible | 87 // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-wi
ll-execute-as-soon-as-possible |
89 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_asyncScriptsToExecuteSoo
n; | 88 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_asyncScriptsToExecuteSoo
n; |
90 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_inOrderScriptsToExecuteS
oon; | 89 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_inOrderScriptsToExecuteS
oon; |
91 | 90 |
92 WebTaskRunner* m_taskRunner; | 91 WebTaskRunner* m_taskRunner; |
93 | 92 |
94 int m_numberOfInOrderScriptsWithPendingNotification; | 93 int m_numberOfInOrderScriptsWithPendingNotification; |
95 | 94 |
96 bool m_isSuspended; | 95 bool m_isSuspended; |
97 #ifndef NDEBUG | 96 #ifndef NDEBUG |
98 bool m_hasEverBeenSuspended; | 97 bool m_hasEverBeenSuspended; |
99 #endif | 98 #endif |
100 | 99 |
101 #if !ENABLE(OILPAN) | 100 #if !ENABLE(OILPAN) |
102 bool m_isDisposed; | |
103 WeakPtrFactory<ScriptRunner> m_weakPointerFactoryForTasks; | 101 WeakPtrFactory<ScriptRunner> m_weakPointerFactoryForTasks; |
104 #endif | 102 #endif |
105 }; | 103 }; |
106 | 104 |
107 } // namespace blink | 105 } // namespace blink |
108 | 106 |
109 #endif // ScriptRunner_h | 107 #endif // ScriptRunner_h |
OLD | NEW |