| 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 24 matching lines...) Expand all Loading... |
| 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 final : public NoBaseWillBeGarbageCollect
edFinalized<MainThreadTaskRunner> { | 45 class CORE_EXPORT MainThreadTaskRunner final : public GarbageCollectedFinalized<
MainThreadTaskRunner> { |
| 46 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); | 46 WTF_MAKE_NONCOPYABLE(MainThreadTaskRunner); |
| 47 USING_FAST_MALLOC_WILL_BE_REMOVED(MainThreadTaskRunner); | |
| 48 | |
| 49 public: | 47 public: |
| 50 static PassOwnPtrWillBeRawPtr<MainThreadTaskRunner> create(ExecutionContext*
); | 48 static RawPtr<MainThreadTaskRunner> create(ExecutionContext*); |
| 51 | 49 |
| 52 ~MainThreadTaskRunner(); | 50 ~MainThreadTaskRunner(); |
| 53 | 51 |
| 54 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
| 55 | 53 |
| 56 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); //
Executes the task on context's thread asynchronously. | 54 void postTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextTask>); //
Executes the task on context's thread asynchronously. |
| 57 void postInspectorTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextT
ask>); | 55 void postInspectorTask(const WebTraceLocation&, PassOwnPtr<ExecutionContextT
ask>); |
| 58 void perform(PassOwnPtr<ExecutionContextTask>, bool); | 56 void perform(PassOwnPtr<ExecutionContextTask>, bool); |
| 59 | 57 |
| 60 void suspend(); | 58 void suspend(); |
| 61 void resume(); | 59 void resume(); |
| 62 | 60 |
| 63 private: | 61 private: |
| 64 explicit MainThreadTaskRunner(ExecutionContext*); | 62 explicit MainThreadTaskRunner(ExecutionContext*); |
| 65 | 63 |
| 66 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); | 64 void pendingTasksTimerFired(Timer<MainThreadTaskRunner>*); |
| 67 | 65 |
| 68 void postTaskInternal(const WebTraceLocation&, PassOwnPtr<ExecutionContextTa
sk>, bool isInspectorTask); | 66 void postTaskInternal(const WebTraceLocation&, PassOwnPtr<ExecutionContextTa
sk>, bool isInspectorTask); |
| 69 | 67 |
| 70 RawPtrWillBeMember<ExecutionContext> m_context; | 68 Member<ExecutionContext> m_context; |
| 71 #if !ENABLE(OILPAN) | 69 #if !ENABLE(OILPAN) |
| 72 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; | 70 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; |
| 73 #endif | 71 #endif |
| 74 Timer<MainThreadTaskRunner> m_pendingTasksTimer; | 72 Timer<MainThreadTaskRunner> m_pendingTasksTimer; |
| 75 Vector<OwnPtr<ExecutionContextTask>> m_pendingTasks; | 73 Vector<OwnPtr<ExecutionContextTask>> m_pendingTasks; |
| 76 bool m_suspended; | 74 bool m_suspended; |
| 77 }; | 75 }; |
| 78 | 76 |
| 79 inline PassOwnPtrWillBeRawPtr<MainThreadTaskRunner> MainThreadTaskRunner::create
(ExecutionContext* context) | 77 inline RawPtr<MainThreadTaskRunner> MainThreadTaskRunner::create(ExecutionContex
t* context) |
| 80 { | 78 { |
| 81 return adoptPtrWillBeNoop(new MainThreadTaskRunner(context)); | 79 return new MainThreadTaskRunner(context); |
| 82 } | 80 } |
| 83 | 81 |
| 84 } // namespace blink | 82 } // namespace blink |
| 85 | 83 |
| 86 #endif | 84 #endif |
| OLD | NEW |