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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerReportingProxyImpl.cpp

Issue 2716853002: (WIP) Worker: Merge ParentFrameTaskRunners into TaskRunnerHelper
Patch Set: WIP Created 3 years, 9 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/web/WebSharedWorkerReportingProxyImpl.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "web/WebSharedWorkerReportingProxyImpl.h" 5 #include "web/WebSharedWorkerReportingProxyImpl.h"
6 6
7 #include "bindings/core/v8/SourceLocation.h" 7 #include "bindings/core/v8/SourceLocation.h"
8 #include "core/dom/TaskRunnerHelper.h"
8 #include "platform/CrossThreadFunctional.h" 9 #include "platform/CrossThreadFunctional.h"
9 #include "public/platform/WebTraceLocation.h" 10 #include "public/platform/WebTraceLocation.h"
10 #include "web/WebSharedWorkerImpl.h" 11 #include "web/WebSharedWorkerImpl.h"
11 #include "wtf/WTF.h" 12 #include "wtf/WTF.h"
12 13
13 namespace blink { 14 namespace blink {
14 15
15 WebSharedWorkerReportingProxyImpl::WebSharedWorkerReportingProxyImpl( 16 WebSharedWorkerReportingProxyImpl::WebSharedWorkerReportingProxyImpl(
16 WebSharedWorkerImpl* worker, 17 WebSharedWorkerImpl* worker)
17 ParentFrameTaskRunners* parentFrameTaskRunners) 18 : m_worker(worker) {
18 : m_worker(worker), m_parentFrameTaskRunners(parentFrameTaskRunners) {
19 DCHECK(isMainThread()); 19 DCHECK(isMainThread());
20 } 20 }
21 21
22 WebSharedWorkerReportingProxyImpl::~WebSharedWorkerReportingProxyImpl() { 22 WebSharedWorkerReportingProxyImpl::~WebSharedWorkerReportingProxyImpl() {
23 DCHECK(isMainThread()); 23 DCHECK(isMainThread());
24 } 24 }
25 25
26 void WebSharedWorkerReportingProxyImpl::countFeature( 26 void WebSharedWorkerReportingProxyImpl::countFeature(
27 UseCounter::Feature feature) { 27 UseCounter::Feature feature) {
28 DCHECK(!isMainThread()); 28 DCHECK(m_globalScope->isContextThread());
29 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer) 29 FrameTaskRunnerHelper::get(TaskType::UnspecedTimer, m_globalScope.get())
30 ->postTask(BLINK_FROM_HERE, 30 ->postTask(BLINK_FROM_HERE,
31 crossThreadBind(&WebSharedWorkerImpl::countFeature, 31 crossThreadBind(&WebSharedWorkerImpl::countFeature,
32 crossThreadUnretained(m_worker), feature)); 32 crossThreadUnretained(m_worker), feature));
33 } 33 }
34 34
35 void WebSharedWorkerReportingProxyImpl::countDeprecation( 35 void WebSharedWorkerReportingProxyImpl::countDeprecation(
36 UseCounter::Feature feature) { 36 UseCounter::Feature feature) {
37 DCHECK(!isMainThread()); 37 DCHECK(m_globalScope->isContextThread());
38 // Go through the same code path with countFeature() because a deprecation 38 // Go through the same code path with countFeature() because a deprecation
39 // message is already shown on the worker console and a remaining work is just 39 // message is already shown on the worker console and a remaining work is just
40 // to record an API use. 40 // to record an API use.
41 countFeature(feature); 41 countFeature(feature);
42 } 42 }
43 43
44 void WebSharedWorkerReportingProxyImpl::reportException( 44 void WebSharedWorkerReportingProxyImpl::reportException(
45 const String& errorMessage, 45 const String& errorMessage,
46 std::unique_ptr<SourceLocation>, 46 std::unique_ptr<SourceLocation>,
47 int exceptionId) { 47 int exceptionId) {
48 DCHECK(!isMainThread()); 48 DCHECK(m_globalScope->isContextThread());
49 // Not suppported in SharedWorker. 49 // Not suppported in SharedWorker.
50 } 50 }
51 51
52 void WebSharedWorkerReportingProxyImpl::reportConsoleMessage( 52 void WebSharedWorkerReportingProxyImpl::reportConsoleMessage(
53 MessageSource, 53 MessageSource,
54 MessageLevel, 54 MessageLevel,
55 const String& message, 55 const String& message,
56 SourceLocation*) { 56 SourceLocation*) {
57 DCHECK(!isMainThread()); 57 DCHECK(m_globalScope->isContextThread());
58 // Not supported in SharedWorker. 58 // Not supported in SharedWorker.
59 } 59 }
60 60
61 void WebSharedWorkerReportingProxyImpl::postMessageToPageInspector( 61 void WebSharedWorkerReportingProxyImpl::postMessageToPageInspector(
62 const String& message) { 62 const String& message) {
63 DCHECK(!isMainThread()); 63 DCHECK(m_globalScope->isContextThread());
64 // The TaskType of Inspector tasks need to be Unthrottled because they need to 64 // The TaskType of Inspector tasks need to be Unthrottled because they need to
65 // run even on a suspended page. 65 // run even on a suspended page.
66 m_parentFrameTaskRunners->get(TaskType::Unthrottled) 66 FrameTaskRunnerHelper::get(TaskType::Unthrottled, m_globalScope.get())
67 ->postTask( 67 ->postTask(
68 BLINK_FROM_HERE, 68 BLINK_FROM_HERE,
69 crossThreadBind(&WebSharedWorkerImpl::postMessageToPageInspector, 69 crossThreadBind(&WebSharedWorkerImpl::postMessageToPageInspector,
70 crossThreadUnretained(m_worker), message)); 70 crossThreadUnretained(m_worker), message));
71 } 71 }
72 72
73 void WebSharedWorkerReportingProxyImpl::didCreateWorkerGlobalScope(
74 WorkerOrWorkletGlobalScope* globalScope) {
75 DCHECK(globalScope->isContextThread());
76 m_globalScope = globalScope;
77 }
78
73 void WebSharedWorkerReportingProxyImpl::didCloseWorkerGlobalScope() { 79 void WebSharedWorkerReportingProxyImpl::didCloseWorkerGlobalScope() {
74 DCHECK(!isMainThread()); 80 DCHECK(m_globalScope->isContextThread());
75 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer) 81 FrameTaskRunnerHelper::get(TaskType::UnspecedTimer, m_globalScope.get())
76 ->postTask( 82 ->postTask(
77 BLINK_FROM_HERE, 83 BLINK_FROM_HERE,
78 crossThreadBind(&WebSharedWorkerImpl::didCloseWorkerGlobalScope, 84 crossThreadBind(&WebSharedWorkerImpl::didCloseWorkerGlobalScope,
79 crossThreadUnretained(m_worker))); 85 crossThreadUnretained(m_worker)));
80 } 86 }
81 87
82 void WebSharedWorkerReportingProxyImpl::didTerminateWorkerThread() { 88 void WebSharedWorkerReportingProxyImpl::didTerminateWorkerThread() {
83 DCHECK(!isMainThread()); 89 DCHECK(m_globalScope->isContextThread());
84 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer) 90 FrameTaskRunnerHelper::get(TaskType::UnspecedTimer, m_globalScope.get())
85 ->postTask(BLINK_FROM_HERE, 91 ->postTask(BLINK_FROM_HERE,
86 crossThreadBind(&WebSharedWorkerImpl::didTerminateWorkerThread, 92 crossThreadBind(&WebSharedWorkerImpl::didTerminateWorkerThread,
87 crossThreadUnretained(m_worker))); 93 crossThreadUnretained(m_worker)));
88 } 94 }
89 95
90 DEFINE_TRACE(WebSharedWorkerReportingProxyImpl) { 96 DEFINE_TRACE(WebSharedWorkerReportingProxyImpl) {
91 visitor->trace(m_parentFrameTaskRunners);
92 } 97 }
93 98
94 } // namespace blink 99 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerReportingProxyImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698