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

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

Issue 2645813002: Add TaskRunnerHelper::get for Frame that casts to LocalFrame if possible or uses nullptr. (Closed)
Patch Set: Created 3 years, 11 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 | « third_party/WebKit/Source/core/dom/TaskRunnerHelper.h ('k') | 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"
(...skipping 30 matching lines...) Expand all
41 return frame ? frame->frameScheduler()->loadingTaskRunner() 41 return frame ? frame->frameScheduler()->loadingTaskRunner()
42 : Platform::current()->currentThread()->getWebTaskRunner(); 42 : Platform::current()->currentThread()->getWebTaskRunner();
43 case TaskType::Unthrottled: 43 case TaskType::Unthrottled:
44 return frame ? frame->frameScheduler()->unthrottledTaskRunner() 44 return frame ? frame->frameScheduler()->unthrottledTaskRunner()
45 : Platform::current()->currentThread()->getWebTaskRunner(); 45 : Platform::current()->currentThread()->getWebTaskRunner();
46 } 46 }
47 NOTREACHED(); 47 NOTREACHED();
48 return nullptr; 48 return nullptr;
49 } 49 }
50 50
51 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Frame* frame) {
52 return get(type, frame->isLocalFrame() ? toLocalFrame(frame) : nullptr);
53 }
54
51 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) { 55 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) {
52 return get(type, document ? document->frame() : nullptr); 56 return get(type, document ? document->frame() : nullptr);
53 } 57 }
54 58
55 RefPtr<WebTaskRunner> TaskRunnerHelper::get( 59 RefPtr<WebTaskRunner> TaskRunnerHelper::get(
56 TaskType type, 60 TaskType type,
57 ExecutionContext* executionContext) { 61 ExecutionContext* executionContext) {
58 return get(type, executionContext && executionContext->isDocument() 62 return get(type, executionContext && executionContext->isDocument()
59 ? static_cast<Document*>(executionContext) 63 ? static_cast<Document*>(executionContext)
60 : nullptr); 64 : nullptr);
61 } 65 }
62 66
63 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, 67 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type,
64 ScriptState* scriptState) { 68 ScriptState* scriptState) {
65 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); 69 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr);
66 } 70 }
67 71
68 } // namespace blink 72 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/TaskRunnerHelper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698