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/workers/WorkerOrWorkletGlobalScope.h" | 5 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
6 | 6 |
7 #include "core/dom/ExecutionContextTask.h" | 7 #include "core/dom/ExecutionContextTask.h" |
8 #include "core/dom/TaskRunnerHelper.h" | 8 #include "core/dom/TaskRunnerHelper.h" |
9 #include "core/frame/Deprecation.h" | 9 #include "core/frame/Deprecation.h" |
10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
11 #include "core/probe/CoreProbes.h" | 11 #include "core/probe/CoreProbes.h" |
12 #include "core/workers/WorkerReportingProxy.h" | 12 #include "core/workers/WorkerReportingProxy.h" |
13 #include "core/workers/WorkerThread.h" | 13 #include "core/workers/WorkerThread.h" |
14 #include "platform/CrossThreadFunctional.h" | 14 #include "platform/CrossThreadFunctional.h" |
15 #include "platform/wtf/Functional.h" | 15 #include "platform/wtf/Functional.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope() | 19 WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope() |
20 : deprecation_warning_bits_(UseCounter::kNumberOfFeatures) {} | 20 : used_features_(UseCounter::kNumberOfFeatures) {} |
21 | 21 |
22 WorkerOrWorkletGlobalScope::~WorkerOrWorkletGlobalScope() = default; | 22 WorkerOrWorkletGlobalScope::~WorkerOrWorkletGlobalScope() = default; |
23 | 23 |
24 void WorkerOrWorkletGlobalScope::AddDeprecationMessage( | 24 void WorkerOrWorkletGlobalScope::CountFeature(UseCounter::Feature feature) { |
25 UseCounter::Feature feature) { | |
26 DCHECK_NE(UseCounter::kOBSOLETE_PageDestruction, feature); | 25 DCHECK_NE(UseCounter::kOBSOLETE_PageDestruction, feature); |
27 DCHECK_GT(UseCounter::kNumberOfFeatures, feature); | 26 DCHECK_GT(UseCounter::kNumberOfFeatures, feature); |
| 27 if (used_features_.QuickGet(feature)) |
| 28 return; |
| 29 used_features_.QuickSet(feature); |
| 30 ReportFeature(feature); |
| 31 } |
28 | 32 |
29 // For each deprecated feature, send console message at most once | 33 void WorkerOrWorkletGlobalScope::CountDeprecation(UseCounter::Feature feature) { |
30 // per worker lifecycle. | 34 DCHECK_NE(UseCounter::kOBSOLETE_PageDestruction, feature); |
31 if (deprecation_warning_bits_.QuickGet(feature)) | 35 DCHECK_GT(UseCounter::kNumberOfFeatures, feature); |
| 36 if (used_features_.QuickGet(feature)) |
32 return; | 37 return; |
33 deprecation_warning_bits_.QuickSet(feature); | 38 used_features_.QuickSet(feature); |
| 39 |
| 40 // Adds a deprecation message to the console. |
34 DCHECK(!Deprecation::DeprecationMessage(feature).IsEmpty()); | 41 DCHECK(!Deprecation::DeprecationMessage(feature).IsEmpty()); |
35 AddConsoleMessage( | 42 AddConsoleMessage( |
36 ConsoleMessage::Create(kDeprecationMessageSource, kWarningMessageLevel, | 43 ConsoleMessage::Create(kDeprecationMessageSource, kWarningMessageLevel, |
37 Deprecation::DeprecationMessage(feature))); | 44 Deprecation::DeprecationMessage(feature))); |
| 45 |
| 46 ReportDeprecation(feature); |
38 } | 47 } |
39 | 48 |
40 void WorkerOrWorkletGlobalScope::PostTask( | 49 void WorkerOrWorkletGlobalScope::PostTask( |
41 TaskType type, | 50 TaskType type, |
42 const WebTraceLocation& location, | 51 const WebTraceLocation& location, |
43 std::unique_ptr<ExecutionContextTask> task, | 52 std::unique_ptr<ExecutionContextTask> task, |
44 const String& task_name_for_instrumentation) { | 53 const String& task_name_for_instrumentation) { |
45 if (!GetThread()) | 54 if (!GetThread()) |
46 return; | 55 return; |
47 | 56 |
(...skipping 11 matching lines...) Expand all Loading... |
59 | 68 |
60 void WorkerOrWorkletGlobalScope::RunTask( | 69 void WorkerOrWorkletGlobalScope::RunTask( |
61 std::unique_ptr<ExecutionContextTask> task, | 70 std::unique_ptr<ExecutionContextTask> task, |
62 bool is_instrumented) { | 71 bool is_instrumented) { |
63 DCHECK(GetThread()->IsCurrentThread()); | 72 DCHECK(GetThread()->IsCurrentThread()); |
64 probe::AsyncTask async_task(this, task.get(), nullptr, is_instrumented); | 73 probe::AsyncTask async_task(this, task.get(), nullptr, is_instrumented); |
65 task->PerformTask(this); | 74 task->PerformTask(this); |
66 } | 75 } |
67 | 76 |
68 } // namespace blink | 77 } // namespace blink |
OLD | NEW |