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 |
+ |