| OLD | NEW |
| 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 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: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 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 WebTaskRunner* TaskRunnerHelper::get(TaskType type, Document* document) { | 51 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, Document* document) { |
| 52 return get(type, document ? document->frame() : nullptr); | 52 return get(type, document ? document->frame() : nullptr); |
| 53 } | 53 } |
| 54 | 54 |
| 55 WebTaskRunner* TaskRunnerHelper::get(TaskType type, | 55 RefPtr<WebTaskRunner> TaskRunnerHelper::get( |
| 56 ExecutionContext* executionContext) { | 56 TaskType type, |
| 57 ExecutionContext* executionContext) { |
| 57 return get(type, executionContext && executionContext->isDocument() | 58 return get(type, executionContext && executionContext->isDocument() |
| 58 ? static_cast<Document*>(executionContext) | 59 ? static_cast<Document*>(executionContext) |
| 59 : nullptr); | 60 : nullptr); |
| 60 } | 61 } |
| 61 | 62 |
| 62 WebTaskRunner* TaskRunnerHelper::get(TaskType type, ScriptState* scriptState) { | 63 RefPtr<WebTaskRunner> TaskRunnerHelper::get(TaskType type, |
| 64 ScriptState* scriptState) { |
| 63 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); | 65 return get(type, scriptState ? scriptState->getExecutionContext() : nullptr); |
| 64 } | 66 } |
| 65 | 67 |
| 66 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |