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

Side by Side Diff: third_party/WebKit/Source/core/dom/TaskRunnerHelper.cpp

Issue 2808273003: [scheduler] Move some task types to suspendable task runner. (Closed)
Patch Set: Created 3 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/TaskRunnerHelper.h" 5 #include "core/dom/TaskRunnerHelper.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "platform/WebFrameScheduler.h" 9 #include "platform/WebFrameScheduler.h"
10 #include "platform/WebTaskRunner.h" 10 #include "platform/WebTaskRunner.h"
11 #include "public/platform/Platform.h" 11 #include "public/platform/Platform.h"
12 #include "public/platform/WebThread.h" 12 #include "public/platform/WebThread.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) { 16 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, LocalFrame* frame) {
17 // TODO(haraken): Optimize the mapping from TaskTypes to task runners. 17 // TODO(haraken): Optimize the mapping from TaskTypes to task runners.
18 switch (type) { 18 switch (type) {
19 case TaskType::kTimer: 19 case TaskType::kTimer:
20 return frame ? frame->FrameScheduler()->TimerTaskRunner() 20 return frame ? frame->FrameScheduler()->TimerTaskRunner()
21 : Platform::Current()->CurrentThread()->GetWebTaskRunner(); 21 : Platform::Current()->CurrentThread()->GetWebTaskRunner();
22 case TaskType::kUnspecedLoading: 22 case TaskType::kUnspecedLoading:
23 case TaskType::kNetworking: 23 case TaskType::kNetworking:
24 return frame ? frame->FrameScheduler()->LoadingTaskRunner() 24 return frame ? frame->FrameScheduler()->LoadingTaskRunner()
25 : Platform::Current()->CurrentThread()->GetWebTaskRunner(); 25 : Platform::Current()->CurrentThread()->GetWebTaskRunner();
26 // Throttling following tasks may break existing web pages, so tentatively 26 // Throttling following tasks may break existing web pages, so tentatively
27 // these are unthrottled. 27 // these are unthrottled.
28 // TODO(nhiroki): Throttle them again after we're convinced that it's safe 28 // TODO(nhiroki): Throttle them again after we're convinced that it's safe
Sami 2017/04/12 15:24:50 Does this comment need updating by the way?
29 // or provide a mechanism that web pages can opt-out it if throttling is not 29 // or provide a mechanism that web pages can opt-out it if throttling is not
30 // desirable. 30 // desirable.
31 case TaskType::kDOMManipulation:
31 case TaskType::kDatabaseAccess: 32 case TaskType::kDatabaseAccess:
33 case TaskType::kFileReading:
34 case TaskType::kHistoryTraversal:
35 case TaskType::kPerformanceTimeline:
36 case TaskType::kPostedMessage:
37 case TaskType::kRemoteEvent:
38 case TaskType::kSensor:
39 case TaskType::kUnshippedPortMessage:
40 case TaskType::kWebSocket:
32 return frame ? frame->FrameScheduler()->SuspendableTaskRunner() 41 return frame ? frame->FrameScheduler()->SuspendableTaskRunner()
33 : Platform::Current()->CurrentThread()->GetWebTaskRunner(); 42 : Platform::Current()->CurrentThread()->GetWebTaskRunner();
34 case TaskType::kDOMManipulation:
35 case TaskType::kUserInteraction: 43 case TaskType::kUserInteraction:
36 case TaskType::kHistoryTraversal:
37 case TaskType::kEmbed: 44 case TaskType::kEmbed:
38 case TaskType::kMediaElementEvent: 45 case TaskType::kMediaElementEvent:
39 case TaskType::kCanvasBlobSerialization: 46 case TaskType::kCanvasBlobSerialization:
40 case TaskType::kRemoteEvent:
41 case TaskType::kWebSocket:
42 case TaskType::kMicrotask: 47 case TaskType::kMicrotask:
43 case TaskType::kPostedMessage:
44 case TaskType::kUnshippedPortMessage:
45 case TaskType::kFileReading:
46 case TaskType::kPresentation: 48 case TaskType::kPresentation:
47 case TaskType::kSensor:
48 case TaskType::kPerformanceTimeline:
49 case TaskType::kWebGL: 49 case TaskType::kWebGL:
50 case TaskType::kUnspecedTimer: 50 case TaskType::kUnspecedTimer:
51 case TaskType::kMiscPlatformAPI: 51 case TaskType::kMiscPlatformAPI:
52 case TaskType::kUnthrottled: 52 case TaskType::kUnthrottled:
53 return frame ? frame->FrameScheduler()->UnthrottledTaskRunner() 53 return frame ? frame->FrameScheduler()->UnthrottledTaskRunner()
54 : Platform::Current()->CurrentThread()->GetWebTaskRunner(); 54 : Platform::Current()->CurrentThread()->GetWebTaskRunner();
55 } 55 }
56 NOTREACHED(); 56 NOTREACHED();
57 return nullptr; 57 return nullptr;
58 } 58 }
(...skipping 10 matching lines...) Expand all
69 : nullptr); 69 : nullptr);
70 } 70 }
71 71
72 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type, 72 RefPtr<WebTaskRunner> TaskRunnerHelper::Get(TaskType type,
73 ScriptState* script_state) { 73 ScriptState* script_state) {
74 return Get(type, 74 return Get(type,
75 script_state ? script_state->GetExecutionContext() : nullptr); 75 script_state ? script_state->GetExecutionContext() : nullptr);
76 } 76 }
77 77
78 } // namespace blink 78 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698