Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: third_party/WebKit/Source/core/dom/MainThreadTaskRunner.h

Issue 2527143002: Suspend frame schedulers on a page suspension (Closed)
Patch Set: mod a comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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"
32 #include "platform/heap/Handle.h" 31 #include "platform/heap/Handle.h"
32 #include "public/platform/WebTraceLocation.h"
33 #include "wtf/Allocator.h" 33 #include "wtf/Allocator.h"
34 #include "wtf/Noncopyable.h" 34 #include "wtf/Noncopyable.h"
35 #include "wtf/PtrUtil.h" 35 #include "wtf/PtrUtil.h"
36 #include "wtf/Vector.h"
37 #include "wtf/WeakPtr.h" 36 #include "wtf/WeakPtr.h"
38 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
39 #include <memory> 38 #include <memory>
40 39
41 namespace blink { 40 namespace blink {
42 41
43 class ExecutionContext; 42 class ExecutionContext;
44 class ExecutionContextTask; 43 class ExecutionContextTask;
45 44
46 class CORE_EXPORT MainThreadTaskRunner final { 45 class CORE_EXPORT MainThreadTaskRunner final {
(...skipping 11 matching lines...) Expand all
58 void postTask(const WebTraceLocation&, 57 void postTask(const WebTraceLocation&,
59 std::unique_ptr<ExecutionContextTask>, 58 std::unique_ptr<ExecutionContextTask>,
60 const String& taskNameForInstrumentation = emptyString()); 59 const String& taskNameForInstrumentation = emptyString());
61 60
62 void postInspectorTask(const WebTraceLocation&, 61 void postInspectorTask(const WebTraceLocation&,
63 std::unique_ptr<ExecutionContextTask>); 62 std::unique_ptr<ExecutionContextTask>);
64 void perform(std::unique_ptr<ExecutionContextTask>, 63 void perform(std::unique_ptr<ExecutionContextTask>,
65 bool isInspectorTask, 64 bool isInspectorTask,
66 bool instrumenting); 65 bool instrumenting);
67 66
68 void suspend();
69 void resume();
70
71 private: 67 private:
72 explicit MainThreadTaskRunner(ExecutionContext*); 68 explicit MainThreadTaskRunner(ExecutionContext*);
73 69
74 void pendingTasksTimerFired(TimerBase*);
75
76 void postTaskInternal(const WebTraceLocation&, 70 void postTaskInternal(const WebTraceLocation&,
77 std::unique_ptr<ExecutionContextTask>, 71 std::unique_ptr<ExecutionContextTask>,
78 bool isInspectorTask, 72 bool isInspectorTask,
79 bool instrumenting); 73 bool instrumenting);
80 74
81 // Untraced back reference to the owner Document; 75 // Untraced back reference to the owner Document;
82 // this object has identical lifetime to it. 76 // this object has identical lifetime to it.
83 UntracedMember<ExecutionContext> m_context; 77 UntracedMember<ExecutionContext> m_context;
84 Timer<MainThreadTaskRunner> m_pendingTasksTimer;
85 Vector<std::pair<std::unique_ptr<ExecutionContextTask>,
86 bool /* instrumenting */>>
87 m_pendingTasks;
88 bool m_suspended;
89 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory; 78 WeakPtrFactory<MainThreadTaskRunner> m_weakFactory;
90 WeakPtr<MainThreadTaskRunner> m_weakPtr; 79 WeakPtr<MainThreadTaskRunner> m_weakPtr;
91 }; 80 };
92 81
93 inline std::unique_ptr<MainThreadTaskRunner> MainThreadTaskRunner::create( 82 inline std::unique_ptr<MainThreadTaskRunner> MainThreadTaskRunner::create(
94 ExecutionContext* context) { 83 ExecutionContext* context) {
95 return wrapUnique(new MainThreadTaskRunner(context)); 84 return wrapUnique(new MainThreadTaskRunner(context));
96 } 85 }
97 86
98 } // namespace blink 87 } // namespace blink
99 88
100 #endif 89 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ExecutionContext.h ('k') | third_party/WebKit/Source/core/dom/MainThreadTaskRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698