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

Unified Diff: third_party/WebKit/Source/core/workers/WorkerOrWorkletGlobalScope.cpp

Issue 2535093003: Worker: Connect UseCounter to workers and worklets (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698