This source file includes following definitions.
- supplementName
- from
- workerStart
- getWorkerStart
#include "config.h"
#include "modules/performance/SharedWorkerPerformance.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 {
SharedWorkerPerformance::SharedWorkerPerformance()
: m_timeOrigin(monotonicallyIncreasingTime())
{
}
const char* SharedWorkerPerformance::supplementName()
{
return "SharedWorkerPerformance";
}
SharedWorkerPerformance& SharedWorkerPerformance::from(SharedWorker& sharedWorker)
{
SharedWorkerPerformance* supplement = static_cast<SharedWorkerPerformance*>(WillBeHeapSupplement<SharedWorker>::from(sharedWorker, supplementName()));
if (!supplement) {
supplement = new SharedWorkerPerformance();
provideTo(sharedWorker, supplementName(), adoptPtrWillBeNoop(supplement));
}
return *supplement;
}
double SharedWorkerPerformance::workerStart(ExecutionContext* context, SharedWorker& sharedWorker)
{
return SharedWorkerPerformance::from(sharedWorker).getWorkerStart(context, sharedWorker);
}
double SharedWorkerPerformance::getWorkerStart(ExecutionContext* context, SharedWorker&) const
{
ASSERT(context);
ASSERT(context->isDocument());
Document* document = toDocument(context);
if (!document->loader())
return 0;
double navigationStart = document->loader()->timing()->navigationStart();
return m_timeOrigin - navigationStart;
}
}