2015-05-03 22:32:37 +03: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-30 03:50:06 +04: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/. */
|
|
|
|
|
|
|
|
#include "Performance.h"
|
|
|
|
#include "mozilla/dom/PerformanceBinding.h"
|
|
|
|
|
|
|
|
#include "WorkerPrivate.h"
|
|
|
|
|
|
|
|
BEGIN_WORKERS_NAMESPACE
|
|
|
|
|
|
|
|
Performance::Performance(WorkerPrivate* aWorkerPrivate)
|
|
|
|
: mWorkerPrivate(aWorkerPrivate)
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
Performance::~Performance()
|
|
|
|
{
|
|
|
|
mWorkerPrivate->AssertIsOnWorkerThread();
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
Performance::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2014-08-30 03:50:06 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return PerformanceBinding_workers::Wrap(aCx, this, aGivenProto);
|
2014-08-30 03:50:06 +04:00
|
|
|
}
|
|
|
|
|
2015-05-25 19:53:07 +03:00
|
|
|
DOMHighResTimeStamp
|
2014-08-30 03:50:06 +04:00
|
|
|
Performance::Now() const
|
|
|
|
{
|
|
|
|
TimeDuration duration =
|
2015-11-19 23:32:49 +03:00
|
|
|
TimeStamp::Now() - mWorkerPrivate->CreationTimeStamp();
|
|
|
|
return RoundTime(duration.ToMilliseconds());
|
2014-08-30 03:50:06 +04:00
|
|
|
}
|
|
|
|
|
2015-05-25 19:53:07 +03:00
|
|
|
// To be removed once bug 1124165 lands
|
|
|
|
bool
|
|
|
|
Performance::IsPerformanceTimingAttribute(const nsAString& aName)
|
|
|
|
{
|
|
|
|
// In workers we just support navigationStart.
|
|
|
|
return aName.EqualsASCII("navigationStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMHighResTimeStamp
|
|
|
|
Performance::GetPerformanceTimingFromString(const nsAString& aProperty)
|
|
|
|
{
|
|
|
|
if (!IsPerformanceTimingAttribute(aProperty)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aProperty.EqualsLiteral("navigationStart")) {
|
2015-11-19 23:32:49 +03:00
|
|
|
return mWorkerPrivate->CreationTime();
|
2015-05-25 19:53:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_CRASH("IsPerformanceTimingAttribute and GetPerformanceTimingFromString are out of sync");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-07-28 19:33:37 +03:00
|
|
|
void
|
|
|
|
Performance::InsertUserEntry(PerformanceEntry* aEntry)
|
|
|
|
{
|
|
|
|
if (mWorkerPrivate->PerformanceLoggingEnabled()) {
|
2015-08-21 00:34:22 +03: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");
|
|
|
|
}
|
|
|
|
PerformanceBase::LogEntry(aEntry, uri);
|
2015-07-28 19:33:37 +03:00
|
|
|
}
|
|
|
|
PerformanceBase::InsertUserEntry(aEntry);
|
|
|
|
}
|
|
|
|
|
2015-11-19 17:04:47 +03:00
|
|
|
TimeStamp
|
|
|
|
Performance::CreationTimeStamp() const
|
2015-05-25 19:53:07 +03:00
|
|
|
{
|
2015-11-19 23:32:49 +03:00
|
|
|
return mWorkerPrivate->CreationTimeStamp();
|
2015-11-19 17:04:47 +03:00
|
|
|
}
|
2015-05-25 19:53:07 +03:00
|
|
|
|
2015-11-19 17:04:47 +03:00
|
|
|
DOMHighResTimeStamp
|
|
|
|
Performance::CreationTime() const
|
|
|
|
{
|
2015-11-19 23:32:49 +03:00
|
|
|
return mWorkerPrivate->CreationTime();
|
2015-05-25 19:53:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Performance::DispatchBufferFullEvent()
|
|
|
|
{
|
|
|
|
// This method is needed just for InsertResourceEntry, but this method is not
|
|
|
|
// exposed to workers.
|
|
|
|
MOZ_CRASH("This should not be called.");
|
|
|
|
}
|
|
|
|
|
2014-08-30 03:50:06 +04:00
|
|
|
END_WORKERS_NAMESPACE
|