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

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

Issue 111743007: Add the SharedWorker.workerStart property for high resolution timers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code style compliance Created 6 years, 11 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/SharedWorkerPerformance.cpp
diff --git a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp b/Source/modules/performance/SharedWorkerPerformance.cpp
similarity index 50%
copy from Source/bindings/v8/custom/V8TextTrackCueCustom.cpp
copy to Source/modules/performance/SharedWorkerPerformance.cpp
index 3adef38297e74537479463be5932b8992fdd7ed2..559481f479b00b14c195b607ee8624a31b80e653 100644
--- a/Source/bindings/v8/custom/V8TextTrackCueCustom.cpp
+++ b/Source/modules/performance/SharedWorkerPerformance.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Opera Software ASA. All rights reserved.
+ * Copyright (c) 2014, Opera Software ASA. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,42 +28,56 @@
*/
#include "config.h"
-#include "V8TextTrackCue.h"
+#include "modules/performance/SharedWorkerPerformance.h"
-#include "V8VTTCue.h"
-
-#include "bindings/v8/ExceptionMessages.h"
-#include "bindings/v8/ExceptionState.h"
-#include "core/frame/UseCounter.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
+#include "core/loader/DocumentLoadTiming.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/workers/SharedWorker.h"
namespace WebCore {
-v8::Handle<v8::Value> toV8(TextTrackCue* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+SharedWorkerPerformance::SharedWorkerPerformance()
+ : m_timeOrigin(monotonicallyIncreasingTime())
+{
+}
+
+SharedWorkerPerformance::~SharedWorkerPerformance()
+{
+}
+
+const char* SharedWorkerPerformance::supplementName()
{
- return toV8(toVTTCue(impl), creationContext, isolate);
+ return "SharedWorkerPerformance";
}
-// Custom constructor to make new TextTrackCue(...) return a VTTCue. This is legacy
-// compat, not per spec, and should be removed at the earliest opportunity.
-void V8TextTrackCue::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
+SharedWorkerPerformance* SharedWorkerPerformance::from(SharedWorker* sharedWorker)
{
- ExceptionState exceptionState(ExceptionState::ConstructionContext, "TextTrackCue", info.Holder(), info.GetIsolate());
- if (UNLIKELY(info.Length() < 3)) {
- exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(3, info.Length()));
- exceptionState.throwIfNeeded();
- return;
+ SharedWorkerPerformance* supplement = static_cast<SharedWorkerPerformance*>(Supplement<SharedWorker>::from(sharedWorker, supplementName()));
+ if (!supplement) {
+ supplement = new SharedWorkerPerformance();
+ provideTo(sharedWorker, supplementName(), adoptPtr(supplement));
}
- V8TRYCATCH_VOID(double, startTime, static_cast<double>(info[0]->NumberValue()));
- V8TRYCATCH_VOID(double, endTime, static_cast<double>(info[1]->NumberValue()));
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, text, info[2]);
+ return supplement;
+}
- Document& document = *toDocument(getExecutionContext());
- UseCounter::count(document, UseCounter::TextTrackCueConstructor);
+double SharedWorkerPerformance::workerStart(ExecutionContext* context, SharedWorker* sharedWorker)
+{
+ return SharedWorkerPerformance::from(sharedWorker)->getWorkerStart(context, sharedWorker);
+}
- RefPtr<VTTCue> impl = VTTCue::create(document, startTime, endTime, text);
- v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate());
+double SharedWorkerPerformance::getWorkerStart(ExecutionContext* context, SharedWorker* sharedWorker) const
+{
+ ASSERT(context);
+ ASSERT(context->isDocument());
+ Document* document = toDocument(context);
+ if (!document->loader())
+ return 0;
- v8SetReturnValue(info, wrapper);
+ double navigationStart = document->loader()->timing()->navigationStart();
+ return m_timeOrigin - navigationStart;
}
} // namespace WebCore
+
« no previous file with comments | « Source/modules/performance/SharedWorkerPerformance.h ('k') | Source/modules/performance/SharedWorkerPerformance.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698