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

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: UseCounterTask and explicit 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
Index: Source/core/workers/DedicatedWorkerGlobalScope.cpp
diff --git a/Source/core/workers/DedicatedWorkerGlobalScope.cpp b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
index 357ca79f4e1cafceb28918280d18aed9bac204e2..c8c0bb038663e2c57620bb37e95557e6764e3075 100644
--- a/Source/core/workers/DedicatedWorkerGlobalScope.cpp
+++ b/Source/core/workers/DedicatedWorkerGlobalScope.cpp
@@ -78,11 +78,30 @@ 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> create(UseCounter::Feature feature) { return adoptPtr(new UseCounterTask(feature)); }
+
+private:
+ explicit UseCounterTask(UseCounter::Feature feature) : m_feature(feature) { }
+ virtual void performTask(ExecutionContext* context) OVERRIDE
+ {
+ UseCounter::count(*toDocument(context), m_feature);
+ }
+
+ UseCounter::Feature m_feature;
+};
+
+void DedicatedWorkerGlobalScope::countFeature(UseCounter::Feature feature) const
+{
+ thread()->workerObjectProxy().postTaskToMainExecutionContext(UseCounterTask::create(feature));
+}
+
void DedicatedWorkerGlobalScope::trace(Visitor* visitor)
{
WorkerGlobalScope::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698