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

Unified Diff: Source/core/workers/DedicatedWorkerGlobalScope.cpp

Issue 342103003: Support UseCounter in dedicated workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Support countDeprecation Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/workers/DedicatedWorkerGlobalScope.h ('k') | Source/core/workers/WorkerGlobalScope.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/workers/DedicatedWorkerGlobalScope.cpp
diff --git a/Source/core/workers/DedicatedWorkerGlobalScope.cpp b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
index 357ca79f4e1cafceb28918280d18aed9bac204e2..9af51ba2b473383397aeb37112579a1f0cc4248b 100644
--- a/Source/core/workers/DedicatedWorkerGlobalScope.cpp
+++ b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
@@ -78,11 +78,45 @@ void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, Excep
thread()->workerObjectProxy().reportPendingActivity(hasPendingActivity());
}
-DedicatedWorkerThread* DedicatedWorkerGlobalScope::thread()
+DedicatedWorkerThread* DedicatedWorkerGlobalScope::thread() const
{
return static_cast<DedicatedWorkerThread*>(Base::thread());
}
+class UseCounterTask : public ExecutionContextTask {
+public:
+ static PassOwnPtr<UseCounterTask> createCount(UseCounter::Feature feature) { return adoptPtr(new UseCounterTask(feature, false)); }
+ static PassOwnPtr<UseCounterTask> createDeprecation(UseCounter::Feature feature) { return adoptPtr(new UseCounterTask(feature, true)); }
+
+private:
+ UseCounterTask(UseCounter::Feature feature, bool isDeprecation)
+ : m_feature(feature)
+ , m_isDeprecation(isDeprecation)
+ {
+ }
+
+ virtual void performTask(ExecutionContext* context) OVERRIDE
+ {
+ if (m_isDeprecation)
+ UseCounter::countDeprecation(*toDocument(context), m_feature);
+ else
+ UseCounter::count(*toDocument(context), m_feature);
+ }
+
+ UseCounter::Feature m_feature;
+ bool m_isDeprecation;
+};
+
+void DedicatedWorkerGlobalScope::countFeature(UseCounter::Feature feature) const
+{
+ thread()->workerObjectProxy().postTaskToMainExecutionContext(UseCounterTask::createCount(feature));
+}
+
+void DedicatedWorkerGlobalScope::countDeprecation(UseCounter::Feature feature) const
+{
+ thread()->workerObjectProxy().postTaskToMainExecutionContext(UseCounterTask::createDeprecation(feature));
+}
+
void DedicatedWorkerGlobalScope::trace(Visitor* visitor)
{
WorkerGlobalScope::trace(visitor);
« no previous file with comments | « Source/core/workers/DedicatedWorkerGlobalScope.h ('k') | Source/core/workers/WorkerGlobalScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698