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

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

Issue 2669883003: Scheduler: Enqueue non-JS-timer tasks into the unthrottled task runner (Closed)
Patch Set: rebase Created 3 years, 10 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 | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | 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::Timer:
20 case TaskType::UnspecedTimer:
haraken 2017/02/03 16:33:47 I would move UnspecedTimer to the unthrottled task
nhiroki 2017/02/03 21:39:17 Done.
21 return frame ? frame->frameScheduler()->timerTaskRunner()
22 : Platform::current()->currentThread()->getWebTaskRunner();
23 case TaskType::UnspecedLoading:
24 case TaskType::Networking:
25 return frame ? frame->frameScheduler()->loadingTaskRunner()
26 : Platform::current()->currentThread()->getWebTaskRunner();
27 // Throttling following tasks may break existing web pages, so tentatively
28 // these are unthrottled.
29 // TODO(nhiroki): Throttle them again after we're convinced that it's safe
30 // or provide a mechanism that web pages can opt-out it if throttling is not
31 // desirable.
19 case TaskType::DOMManipulation: 32 case TaskType::DOMManipulation:
20 case TaskType::UserInteraction: 33 case TaskType::UserInteraction:
21 case TaskType::HistoryTraversal: 34 case TaskType::HistoryTraversal:
22 case TaskType::Embed: 35 case TaskType::Embed:
23 case TaskType::MediaElementEvent: 36 case TaskType::MediaElementEvent:
24 case TaskType::CanvasBlobSerialization: 37 case TaskType::CanvasBlobSerialization:
25 case TaskType::RemoteEvent: 38 case TaskType::RemoteEvent:
26 case TaskType::WebSocket: 39 case TaskType::WebSocket:
27 case TaskType::Microtask: 40 case TaskType::Microtask:
28 case TaskType::PostedMessage: 41 case TaskType::PostedMessage:
29 case TaskType::UnshippedPortMessage: 42 case TaskType::UnshippedPortMessage:
30 case TaskType::FileReading: 43 case TaskType::FileReading:
31 case TaskType::DatabaseAccess: 44 case TaskType::DatabaseAccess:
32 case TaskType::Presentation: 45 case TaskType::Presentation:
33 case TaskType::Sensor: 46 case TaskType::Sensor:
34 case TaskType::PerformanceTimeline: 47 case TaskType::PerformanceTimeline:
35 case TaskType::WebGL: 48 case TaskType::WebGL:
36 case TaskType::Timer:
37 case TaskType::UnspecedTimer:
38 case TaskType::MiscPlatformAPI: 49 case TaskType::MiscPlatformAPI:
39 return frame ? frame->frameScheduler()->timerTaskRunner()
40 : Platform::current()->currentThread()->getWebTaskRunner();
41 case TaskType::UnspecedLoading:
42 case TaskType::Networking:
43 return frame ? frame->frameScheduler()->loadingTaskRunner()
44 : Platform::current()->currentThread()->getWebTaskRunner();
45 case TaskType::Unthrottled: 50 case TaskType::Unthrottled:
46 return frame ? frame->frameScheduler()->unthrottledTaskRunner() 51 return frame ? frame->frameScheduler()->unthrottledTaskRunner()
47 : Platform::current()->currentThread()->getWebTaskRunner(); 52 : Platform::current()->currentThread()->getWebTaskRunner();
48 } 53 }
49 NOTREACHED(); 54 NOTREACHED();
50 return nullptr; 55 return nullptr;
51 } 56 }
52 57
53 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) { 58 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) {
54 return get(type, document ? document->frame() : nullptr); 59 return get(type, document ? document->frame() : nullptr);
55 } 60 }
56 61
57 RefPtr<WebTaskRunner> TaskRunnerHelper::get( 62 RefPtr<WebTaskRunner> TaskRunnerHelper::get(
58 TaskType type, 63 TaskType type,
59 ExecutionContext* executionContext) { 64 ExecutionContext* executionContext) {
60 return get(type, executionContext && executionContext->isDocument() 65 return get(type, executionContext && executionContext->isDocument()
61 ? static_cast<Document*>(executionContext) 66 ? static_cast<Document*>(executionContext)
62 : nullptr); 67 : nullptr);
63 } 68 }
64 69
65 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, 70 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type,
66 ScriptState* scriptState) { 71 ScriptState* scriptState) {
67 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); 72 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr);
68 } 73 }
69 74
70 } // namespace blink 75 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/LocalDOMWindow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698