OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
(...skipping 11 matching lines...) Expand all Loading... |
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef MainThreadTaskRunner_h | 27 #ifndef MainThreadTaskRunner_h |
28 #define MainThreadTaskRunner_h | 28 #define MainThreadTaskRunner_h |
29 | 29 |
30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
31 #include "platform/Timer.h" | 31 #include "platform/Timer.h" |
32 | 32 #include "platform/heap/Handle.h" |
33 #include "wtf/FastAllocBase.h" | 33 #include "wtf/FastAllocBase.h" |
34 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
35 #include "wtf/OwnPtr.h" | 35 #include "wtf/OwnPtr.h" |
36 #include "wtf/PassOwnPtr.h" | 36 #include "wtf/PassOwnPtr.h" |
37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
38 #include "wtf/WeakPtr.h" | 38 #include "wtf/WeakPtr.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class ExecutionContext; | 42 class ExecutionContext; |
43 class ExecutionContextTask; | 43 class ExecutionContextTask; |
44 | 44 |
45 class CORE_EXPORT MainThreadTaskRunner { | 45 class CORE_EXPORT MainThreadTaskRunner final : public NoBaseWillBeGarbageCollect
edFinalized<MainThreadTaskRunner> { |
46 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); | 46 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); |
47 WTF_MAKE_FAST_ALLOCATED(MainThreadTaskRunner); | 47 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(MainThreadTaskRunner); |
48 | 48 |
49 public: | 49 public: |
50 static PassOwnPtr<MainThreadTaskRunner> create(ExecutionContext*); | 50 static PassOwnPtrWillBeRawPtr<MainThreadTaskRunner> create(ExecutionContext*
); |
51 | 51 |
52 ~MainThreadTaskRunner(); | 52 ~MainThreadTaskRunner(); |
53 | 53 |
| 54 DECLARE_TRACE(); |
| 55 |
54 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); //
Executes the task on context's thread asynchronously. | 56 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); //
Executes the task on context's thread asynchronously. |
55 void postInspectorTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextT
ask>); | 57 void postInspectorTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextT
ask>); |
56 void perform(PassOwnPtr<ExecutionContextTask>, bool); | 58 void perform(PassOwnPtr<ExecutionContextTask>, bool); |
57 | 59 |
58 void suspend(); | 60 void suspend(); |
59 void resume(); | 61 void resume(); |
60 | 62 |
61 private: | 63 private: |
62 explicit MainThreadTaskRunner(ExecutionContext*); | 64 explicit MainThreadTaskRunner(ExecutionContext*); |
63 | 65 |
64 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); | 66 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); |
65 | 67 |
66 ExecutionContext* m_context; | 68 WeakPtrWillBeRawPtr<MainThreadTaskRunner> createWeakPointerToSelf(); |
| 69 |
| 70 RawPtrWillBeMember<ExecutionContext> m_context; |
| 71 #if !ENABLE(OILPAN) |
67 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; | 72 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; |
| 73 #endif |
68 Timer<MainThreadTaskRunner> m_pendingTasksTimer; | 74 Timer<MainThreadTaskRunner> m_pendingTasksTimer; |
69 Vector<OwnPtr<ExecutionContextTask>> m_pendingTasks; | 75 Vector<OwnPtr<ExecutionContextTask>> m_pendingTasks; |
70 bool m_suspended; | 76 bool m_suspended; |
71 }; | 77 }; |
72 | 78 |
73 inline PassOwnPtr<MainThreadTaskRunner> MainThreadTaskRunner::create(ExecutionCo
ntext* context) | 79 inline PassOwnPtrWillBeRawPtr<MainThreadTaskRunner> MainThreadTaskRunner::create
(ExecutionContext* context) |
74 { | 80 { |
75 return adoptPtr(new MainThreadTaskRunner(context)); | 81 return adoptPtrWillBeNoop(new MainThreadTaskRunner(context)); |
76 } | 82 } |
77 | 83 |
78 } // namespace | 84 } // namespace |
79 | 85 |
80 #endif | 86 #endif |
OLD | NEW |