Chromium Code Reviews| Index: third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp |
| diff --git a/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp b/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4eb7011b174666c81d507d85fde10bd655fa9458 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/workers/WorkerOrWorkletGlobalScope.h" |
| + |
| +#include "core/frame/Deprecation.h" |
| +#include "core/inspector/ConsoleMessage.h" |
| +#include "core/workers/WorkerReportingProxy.h" |
| +#include "core/workers/WorkerThread.h" |
| + |
| +namespace blink { |
| + |
| +WorkerOrWorkletGlobalScope::WorkerOrWorkletGlobalScope() |
| + : m_deprecationWarningBits(UseCounter::NumberOfFeatures) {} |
| + |
| +WorkerOrWorkletGlobalScope::~WorkerOrWorkletGlobalScope() {} |
| + |
| +void WorkerOrWorkletGlobalScope::countFeature( |
| + UseCounter::Feature feature) const { |
| + // Do nothing. |
|
falken
2016/12/02 08:54:49
Why is this different from countDeprecation? Can y
nhiroki
2016/12/05 04:49:01
countDeprecation() needs to show a warning message
|
| +} |
| + |
| +void WorkerOrWorkletGlobalScope::countDeprecation( |
| + UseCounter::Feature feature) const { |
| + DCHECK_NE(UseCounter::OBSOLETE_PageDestruction, feature); |
| + DCHECK_GT(UseCounter::NumberOfFeatures, feature); |
| + |
| + // For each deprecated feature, send console message at most once |
| + // per worker lifecycle. |
| + if (!m_deprecationWarningBits.quickGet(feature)) { |
| + // TODO(nhiroki): Stop using const_cast. |
| + WorkerOrWorkletGlobalScope* globalScope = |
| + const_cast<WorkerOrWorkletGlobalScope*>(this); |
| + globalScope->m_deprecationWarningBits.quickSet(feature); |
| + DCHECK(!Deprecation::deprecationMessage(feature).isEmpty()); |
| + globalScope->addConsoleMessage( |
| + ConsoleMessage::create(DeprecationMessageSource, WarningMessageLevel, |
| + Deprecation::deprecationMessage(feature))); |
| + } |
| +} |
| + |
| +} // namespace blink |