/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
already_AddRefed<PerformanceMark> PerformanceMark::Constructor(
JSContext* aCx, nsIGlobalObject* aGlobal, const nsAString& aMarkName, const PerformanceMarkOptions& aMarkOptions, ErrorResult& aRv) {
RefPtr<Performance> performance = Performance::Get(aCx, aGlobal); if (!performance) { // This is similar to the message that occurs when accessing `performance` // from outside a valid global.
aRv.ThrowTypeError( "can't access PerformanceMark constructor, performance is null"); return nullptr;
}
if (performance->IsGlobalObjectWindow() &&
performance->IsPerformanceTimingAttribute(aMarkName)) {
aRv.ThrowSyntaxError("markName cannot be a performance timing attribute"); return nullptr;
}
DOMHighResTimeStamp startTime = aMarkOptions.mStartTime.WasPassed()
? aMarkOptions.mStartTime.Value()
: performance->Now(); // We need to get the unclamped start time to be able to add profiler markers // with precise time/duration. This is not exposed to web and only used by the // profiler. // If a mStartTime is passed by the user, we will always have a clamped value.
DOMHighResTimeStamp unclampedStartTime = aMarkOptions.mStartTime.WasPassed()
? startTime
: performance->NowUnclamped(); if (startTime < 0) {
aRv.ThrowTypeError("Expected startTime >= 0"); return nullptr;
}
void PerformanceMark::GetDetail(JSContext* aCx,
JS::MutableHandle<JS::Value> aRetval) { // Return a copy so that this method always returns the value it is set to // (i.e. it'll return the same value even if the caller assigns to it). Note // that if detail is an object, its contents can be mutated and this is // expected.
aRetval.set(mDetail);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.