| 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 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
| 34 #include "wtf/PassOwnPtr.h" | 34 #include "wtf/PassOwnPtr.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 class CancellableTaskFactory; | 38 class CancellableTaskFactory; |
| 39 class Document; | 39 class Document; |
| 40 class ScriptLoader; | 40 class ScriptLoader; |
| 41 class WebTaskRunner; | 41 class WebTaskRunner; |
| 42 | 42 |
| 43 class CORE_EXPORT ScriptRunner final : public NoBaseWillBeGarbageCollectedFinali
zed<ScriptRunner> { | 43 class CORE_EXPORT ScriptRunner final : public GarbageCollectedFinalized<ScriptRu
nner> { |
| 44 WTF_MAKE_NONCOPYABLE(ScriptRunner); USING_FAST_MALLOC_WILL_BE_REMOVED(Script
Runner); | 44 WTF_MAKE_NONCOPYABLE(ScriptRunner); |
| 45 public: | 45 public: |
| 46 static PassOwnPtrWillBeRawPtr<ScriptRunner> create(Document* document) | 46 static RawPtr<ScriptRunner> create(Document* document) |
| 47 { | 47 { |
| 48 return adoptPtrWillBeNoop(new ScriptRunner(document)); | 48 return new ScriptRunner(document); |
| 49 } | 49 } |
| 50 ~ScriptRunner(); | 50 ~ScriptRunner(); |
| 51 #if !ENABLE(OILPAN) | 51 #if !ENABLE(OILPAN) |
| 52 void dispose(); | 52 void dispose(); |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; | 55 enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION }; |
| 56 void queueScriptForExecution(ScriptLoader*, ExecutionType); | 56 void queueScriptForExecution(ScriptLoader*, ExecutionType); |
| 57 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } | 57 bool hasPendingScripts() const { return !m_pendingInOrderScripts.isEmpty() |
| !m_pendingAsyncScripts.isEmpty(); } |
| 58 void suspend(); | 58 void suspend(); |
| 59 void resume(); | 59 void resume(); |
| 60 void notifyScriptReady(ScriptLoader*, ExecutionType); | 60 void notifyScriptReady(ScriptLoader*, ExecutionType); |
| 61 void notifyScriptLoadError(ScriptLoader*, ExecutionType); | 61 void notifyScriptLoadError(ScriptLoader*, ExecutionType); |
| 62 | 62 |
| 63 static void movePendingScript(Document&, Document&, ScriptLoader*); | 63 static void movePendingScript(Document&, Document&, ScriptLoader*); |
| 64 | 64 |
| 65 DECLARE_TRACE(); | 65 DECLARE_TRACE(); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 class Task; | 68 class Task; |
| 69 | 69 |
| 70 explicit ScriptRunner(Document*); | 70 explicit ScriptRunner(Document*); |
| 71 | 71 |
| 72 void movePendingScript(ScriptRunner*, ScriptLoader*); | 72 void movePendingScript(ScriptRunner*, ScriptLoader*); |
| 73 bool removePendingInOrderScript(ScriptLoader*); | 73 bool removePendingInOrderScript(ScriptLoader*); |
| 74 void scheduleReadyInOrderScripts(); | 74 void scheduleReadyInOrderScripts(); |
| 75 | 75 |
| 76 void postTask(const WebTraceLocation&); | 76 void postTask(const WebTraceLocation&); |
| 77 | 77 |
| 78 bool executeTaskFromQueue(WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>>*
); | 78 bool executeTaskFromQueue(HeapDeque<Member<ScriptLoader>>*); |
| 79 | 79 |
| 80 void executeTask(); | 80 void executeTask(); |
| 81 | 81 |
| 82 RawPtrWillBeMember<Document> m_document; | 82 Member<Document> m_document; |
| 83 | 83 |
| 84 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_pendingInOrderScripts; | 84 HeapDeque<Member<ScriptLoader>> m_pendingInOrderScripts; |
| 85 WillBeHeapHashSet<RawPtrWillBeMember<ScriptLoader>> m_pendingAsyncScripts; | 85 HeapHashSet<Member<ScriptLoader>> m_pendingAsyncScripts; |
| 86 | 86 |
| 87 // 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 |
| 88 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_asyncScriptsToExecuteSoo
n; | 88 HeapDeque<Member<ScriptLoader>> m_asyncScriptsToExecuteSoon; |
| 89 WillBeHeapDeque<RawPtrWillBeMember<ScriptLoader>> m_inOrderScriptsToExecuteS
oon; | 89 HeapDeque<Member<ScriptLoader>> m_inOrderScriptsToExecuteSoon; |
| 90 | 90 |
| 91 WebTaskRunner* m_taskRunner; | 91 WebTaskRunner* m_taskRunner; |
| 92 | 92 |
| 93 int m_numberOfInOrderScriptsWithPendingNotification; | 93 int m_numberOfInOrderScriptsWithPendingNotification; |
| 94 | 94 |
| 95 bool m_isSuspended; | 95 bool m_isSuspended; |
| 96 #ifndef NDEBUG | 96 #ifndef NDEBUG |
| 97 bool m_hasEverBeenSuspended; | 97 bool m_hasEverBeenSuspended; |
| 98 #endif | 98 #endif |
| 99 | 99 |
| 100 #if !ENABLE(OILPAN) | 100 #if !ENABLE(OILPAN) |
| 101 bool m_isDisposed; | 101 bool m_isDisposed; |
| 102 WeakPtrFactory<ScriptRunner> m_weakPointerFactoryForTasks; | 102 WeakPtrFactory<ScriptRunner> m_weakPointerFactoryForTasks; |
| 103 #endif | 103 #endif |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace blink | 106 } // namespace blink |
| 107 | 107 |
| 108 #endif // ScriptRunner_h | 108 #endif // ScriptRunner_h |
| OLD | NEW |