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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return; 71 return;
72 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease()); 72 thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.re lease());
73 } 73 }
74 74
75 void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, Excep tionState& exceptionState) 75 void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, Excep tionState& exceptionState)
76 { 76 {
77 Base::importScripts(urls, exceptionState); 77 Base::importScripts(urls, exceptionState);
78 thread()->workerObjectProxy().reportPendingActivity(hasPendingActivity()); 78 thread()->workerObjectProxy().reportPendingActivity(hasPendingActivity());
79 } 79 }
80 80
81 DedicatedWorkerThread* DedicatedWorkerGlobalScope::thread() 81 DedicatedWorkerThread* DedicatedWorkerGlobalScope::thread() const
82 { 82 {
83 return static_cast<DedicatedWorkerThread*>(Base::thread()); 83 return static_cast<DedicatedWorkerThread*>(Base::thread());
84 } 84 }
85 85
86 class UseCounterTask : public ExecutionContextTask {
87 public:
88 static PassOwnPtr<UseCounterTask> createCount(UseCounter::Feature feature) { return adoptPtr(new UseCounterTask(feature, false)); }
89 static PassOwnPtr<UseCounterTask> createDeprecation(UseCounter::Feature feat ure) { return adoptPtr(new UseCounterTask(feature, true)); }
90
91 private:
92 UseCounterTask(UseCounter::Feature feature, bool isDeprecation)
93 : m_feature(feature)
94 , m_isDeprecation(isDeprecation)
95 {
96 }
97
98 virtual void performTask(ExecutionContext* context) OVERRIDE
99 {
100 if (m_isDeprecation)
101 UseCounter::countDeprecation(*toDocument(context), m_feature);
102 else
103 UseCounter::count(*toDocument(context), m_feature);
104 }
105
106 UseCounter::Feature m_feature;
107 bool m_isDeprecation;
108 };
109
110 void DedicatedWorkerGlobalScope::countFeature(UseCounter::Feature feature) const
111 {
112 thread()->workerObjectProxy().postTaskToMainExecutionContext(UseCounterTask: :createCount(feature));
113 }
114
115 void DedicatedWorkerGlobalScope::countDeprecation(UseCounter::Feature feature) c onst
116 {
117 thread()->workerObjectProxy().postTaskToMainExecutionContext(UseCounterTask: :createDeprecation(feature));
118 }
119
86 void DedicatedWorkerGlobalScope::trace(Visitor* visitor) 120 void DedicatedWorkerGlobalScope::trace(Visitor* visitor)
87 { 121 {
88 WorkerGlobalScope::trace(visitor); 122 WorkerGlobalScope::trace(visitor);
89 } 123 }
90 124
91 } // namespace WebCore 125 } // namespace WebCore
OLDNEW
« 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