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

Unified Diff: Source/modules/performance/WorkerContextPerformance.cpp

Issue 16434011: Support performance.now() in workers. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix WorkerPerformance IDL Created 7 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/modules/performance/WorkerContextPerformance.cpp
diff --git a/Source/modules/donottrack/NavigatorDoNotTrack.cpp b/Source/modules/performance/WorkerContextPerformance.cpp
similarity index 57%
copy from Source/modules/donottrack/NavigatorDoNotTrack.cpp
copy to Source/modules/performance/WorkerContextPerformance.cpp
index 5fee3b5536ae29b0637a6b4b389cf8727490f158..6f517376daea87a14302d50ace3aa71f05da3562 100644
--- a/Source/modules/donottrack/NavigatorDoNotTrack.cpp
+++ b/Source/modules/performance/WorkerContextPerformance.cpp
@@ -29,48 +29,52 @@
*/
#include "config.h"
-#include "modules/donottrack/NavigatorDoNotTrack.h"
-#include "core/loader/FrameLoader.h"
-#include "core/loader/FrameLoaderClient.h"
-#include "core/page/Frame.h"
-#include "core/page/Navigator.h"
-#include "wtf/PassOwnPtr.h"
+#include "modules/performance/WorkerContextPerformance.h"
+
+#include "core/dom/ScriptExecutionContext.h"
+#include "core/workers/WorkerContext.h"
+#include "modules/performance/WorkerPerformance.h"
namespace WebCore {
-NavigatorDoNotTrack::NavigatorDoNotTrack(Frame* frame)
- : DOMWindowProperty(frame)
+WorkerContextPerformance::WorkerContextPerformance(ScriptExecutionContext* context)
+ : m_context(context)
abarth-chromium 2013/06/12 23:11:41 Why do you need to hold m_context?
James Simonsen 2013/06/13 00:01:36 Done.
{
}
-NavigatorDoNotTrack::~NavigatorDoNotTrack()
+WorkerContextPerformance::~WorkerContextPerformance()
{
}
-const char* NavigatorDoNotTrack::supplementName()
+const char* WorkerContextPerformance::supplementName()
{
- return "NavigatorDoNotTrack";
+ return "WorkerContextPerformance";
}
-NavigatorDoNotTrack* NavigatorDoNotTrack::from(Navigator* navigator)
+WorkerContextPerformance* WorkerContextPerformance::from(ScriptExecutionContext* context)
{
- NavigatorDoNotTrack* supplement = static_cast<NavigatorDoNotTrack*>(Supplement<Navigator>::from(navigator, supplementName()));
+ WorkerContextPerformance* supplement = static_cast<WorkerContextPerformance*>(Supplement<ScriptExecutionContext>::from(context, supplementName()));
if (!supplement) {
- supplement = new NavigatorDoNotTrack(navigator->frame());
- provideTo(navigator, supplementName(), adoptPtr(supplement));
+ supplement = new WorkerContextPerformance(context);
+ provideTo(context, supplementName(), adoptPtr(supplement));
}
return supplement;
}
-String NavigatorDoNotTrack::doNotTrack(Navigator* navigator)
+WorkerPerformance* WorkerContextPerformance::performance(ScriptExecutionContext* context)
{
- return NavigatorDoNotTrack::from(navigator)->doNotTrack();
+ return from(context)->performance();
abarth-chromium 2013/06/12 23:11:41 You can just pass context in here.
James Simonsen 2013/06/13 00:01:36 Yep. Thanks.
}
-String NavigatorDoNotTrack::doNotTrack()
+WorkerPerformance* WorkerContextPerformance::performance()
{
- return frame() ? frame()->loader()->client()->doNotTrackValue() : String();
+ if (!m_performance) {
+ ASSERT_WITH_SECURITY_IMPLICATION(m_context->isWorkerContext());
+ WorkerContext* workerContext = static_cast<WorkerContext*>(m_context);
+ m_performance = WorkerPerformance::create(workerContext);
+ }
+ return m_performance.get();
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698