2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-08-29 23:50:06 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2016-06-09 17:04:42 +00:00
|
|
|
#include "PerformanceWorker.h"
|
2018-01-08 13:05:04 +00:00
|
|
|
#include "mozilla/dom/DOMPrefs.h"
|
2018-01-31 07:24:08 +00:00
|
|
|
#include "mozilla/dom/WorkerPrivate.h"
|
2014-08-29 23:50:06 +00:00
|
|
|
|
2016-06-09 17:04:42 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
PerformanceWorker::PerformanceWorker(WorkerPrivate* aWorkerPrivate)
|
2014-08-29 23:50:06 +00:00
|
|
|
: mWorkerPrivate(aWorkerPrivate)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2016-06-09 17:04:42 +00:00
|
|
|
PerformanceWorker::~PerformanceWorker()
|
2014-08-29 23:50:06 +00:00
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
2015-07-28 16:33:37 +00:00
|
|
|
void
|
2016-06-09 17:04:42 +00:00
|
|
|
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
|
2015-07-28 16:33:37 +00:00
|
|
|
{
|
2018-01-08 13:05:04 +00:00
|
|
|
if (DOMPrefs::PerformanceLoggingEnabled()) {
|
2015-08-20 21:34:22 +00:00
|
|
|
nsAutoCString uri;
|
|
|
|
nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
|
|
|
|
if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {
|
|
|
|
// If we have no URI, just put in "none".
|
|
|
|
uri.AssignLiteral("none");
|
|
|
|
}
|
2016-06-09 17:04:42 +00:00
|
|
|
Performance::LogEntry(aEntry, uri);
|
2015-07-28 16:33:37 +00:00
|
|
|
}
|
2016-06-09 17:04:42 +00:00
|
|
|
Performance::InsertUserEntry(aEntry);
|
2015-07-28 16:33:37 +00:00
|
|
|
}
|
|
|
|
|
2015-11-19 14:04:47 +00:00
|
|
|
TimeStamp
|
2016-06-09 17:04:42 +00:00
|
|
|
PerformanceWorker::CreationTimeStamp() const
|
2015-05-25 16:53:07 +00:00
|
|
|
{
|
2016-12-16 08:07:39 +00:00
|
|
|
return mWorkerPrivate->CreationTimeStamp();
|
2015-11-19 14:04:47 +00:00
|
|
|
}
|
2015-05-25 16:53:07 +00:00
|
|
|
|
2015-11-19 14:04:47 +00:00
|
|
|
DOMHighResTimeStamp
|
2016-06-09 17:04:42 +00:00
|
|
|
PerformanceWorker::CreationTime() const
|
2015-11-19 14:04:47 +00:00
|
|
|
{
|
2016-12-16 08:07:39 +00:00
|
|
|
return mWorkerPrivate->CreationTime();
|
2015-05-25 16:53:07 +00:00
|
|
|
}
|
|
|
|
|
2016-06-09 17:04:42 +00:00
|
|
|
} // dom namespace
|
|
|
|
} // mozilla namespace
|