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

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: 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::DOMManipulation: 19 case TaskType::DOMManipulation:
20 case TaskType::UserInteraction: 20 case TaskType::UserInteraction:
21 case TaskType::HistoryTraversal: 21 case TaskType::HistoryTraversal:
22 case TaskType::Embed: 22 case TaskType::Embed:
23 case TaskType::MediaElementEvent: 23 case TaskType::MediaElementEvent:
24 case TaskType::CanvasBlobSerialization: 24 case TaskType::CanvasBlobSerialization:
25 case TaskType::RemoteEvent: 25 case TaskType::RemoteEvent:
26 case TaskType::WebSocket: 26 case TaskType::WebSocket:
27 case TaskType::Microtask: 27 case TaskType::Microtask:
28 case TaskType::PostedMessage:
29 case TaskType::UnshippedPortMessage: 28 case TaskType::UnshippedPortMessage:
30 case TaskType::FileReading: 29 case TaskType::FileReading:
31 case TaskType::DatabaseAccess: 30 case TaskType::DatabaseAccess:
32 case TaskType::Presentation: 31 case TaskType::Presentation:
33 case TaskType::Sensor: 32 case TaskType::Sensor:
34 case TaskType::PerformanceTimeline: 33 case TaskType::PerformanceTimeline:
35 case TaskType::Timer: 34 case TaskType::Timer:
36 case TaskType::UnspecedTimer: 35 case TaskType::UnspecedTimer:
37 case TaskType::MiscPlatformAPI: 36 case TaskType::MiscPlatformAPI:
38 return frame ? frame->frameScheduler()->timerTaskRunner() 37 return frame ? frame->frameScheduler()->timerTaskRunner()
39 : Platform::current()->currentThread()->getWebTaskRunner(); 38 : Platform::current()->currentThread()->getWebTaskRunner();
40 case TaskType::UnspecedLoading: 39 case TaskType::UnspecedLoading:
41 case TaskType::Networking: 40 case TaskType::Networking:
42 return frame ? frame->frameScheduler()->loadingTaskRunner() 41 return frame ? frame->frameScheduler()->loadingTaskRunner()
43 : Platform::current()->currentThread()->getWebTaskRunner(); 42 : Platform::current()->currentThread()->getWebTaskRunner();
43 // We found throttling PostedMessage tasks may break existing web pages, so
44 // tentatively make it unthrottled.
45 // TODO(nhiroki): Consider to throttle this again maybe after making a
46 // mechanism that web pages can opt-out the throttling if throttling is not
47 // desirable.
48 case TaskType::PostedMessage:
nhiroki 2017/02/02 05:46:38 As my comment on the issue[1], I'm still not sure
altimin 2017/02/02 18:41:25 +1, I'm particularly interested in unthrottling We
Sami 2017/02/02 23:37:10 Yeah, this seems like a reasonable step for now. I
nhiroki 2017/02/03 15:07:34 Acknowledged.
nhiroki 2017/02/03 15:07:34 Acknowledged.
44 case TaskType::Unthrottled: 49 case TaskType::Unthrottled:
45 return frame ? frame->frameScheduler()->unthrottledTaskRunner() 50 return frame ? frame->frameScheduler()->unthrottledTaskRunner()
46 : Platform::current()->currentThread()->getWebTaskRunner(); 51 : Platform::current()->currentThread()->getWebTaskRunner();
47 } 52 }
48 NOTREACHED(); 53 NOTREACHED();
49 return nullptr; 54 return nullptr;
50 } 55 }
51 56
52 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) { 57 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) {
53 return get(type, document ? document->frame() : nullptr); 58 return get(type, document ? document->frame() : nullptr);
54 } 59 }
55 60
56 RefPtr<WebTaskRunner> TaskRunnerHelper::get( 61 RefPtr<WebTaskRunner> TaskRunnerHelper::get(
57 TaskType type, 62 TaskType type,
58 ExecutionContext* executionContext) { 63 ExecutionContext* executionContext) {
59 return get(type, executionContext && executionContext->isDocument() 64 return get(type, executionContext && executionContext->isDocument()
60 ? static_cast<Document*>(executionContext) 65 ? static_cast<Document*>(executionContext)
61 : nullptr); 66 : nullptr);
62 } 67 }
63 68
64 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, 69 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type,
65 ScriptState* scriptState) { 70 ScriptState* scriptState) {
66 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); 71 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr);
67 } 72 }
68 73
69 } // namespace blink 74 } // 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