2011-06-23 14:39:48 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +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/. */
|
2011-06-23 14:39:48 +04:00
|
|
|
#ifndef nsPerformance_h___
|
|
|
|
#define nsPerformance_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2012-06-15 06:31:55 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-17 05:42:18 +04:00
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
#include "nsDOMNavigationTiming.h"
|
2013-05-11 02:57:58 +04:00
|
|
|
#include "nsContentUtils.h"
|
2013-08-23 09:17:11 +04:00
|
|
|
#include "nsIDOMWindow.h"
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h"
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2011-07-04 20:44:00 +04:00
|
|
|
class nsITimedChannel;
|
2012-07-17 05:42:18 +04:00
|
|
|
class nsPerformance;
|
2011-06-23 14:39:48 +04:00
|
|
|
|
|
|
|
// Script "performance.timing" object
|
2012-12-07 01:01:59 +04:00
|
|
|
class nsPerformanceTiming MOZ_FINAL : public nsWrapperCache
|
2011-06-23 14:39:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-07-17 05:42:18 +04:00
|
|
|
nsPerformanceTiming(nsPerformance* aPerformance,
|
|
|
|
nsITimedChannel* aChannel);
|
2012-12-07 01:01:59 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsPerformanceTiming)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsPerformanceTiming)
|
2012-07-17 05:42:18 +04:00
|
|
|
|
|
|
|
nsDOMNavigationTiming* GetDOMTiming() const;
|
|
|
|
|
|
|
|
nsPerformance* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mPerformance;
|
|
|
|
}
|
|
|
|
|
2013-04-25 20:29:54 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
2012-07-17 05:42:18 +04:00
|
|
|
|
|
|
|
// PerformanceNavigation WebIDL methods
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec NavigationStart() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetNavigationStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec UnloadEventStart() {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetUnloadEventStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec UnloadEventEnd() {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetUnloadEventEnd();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec RedirectStart() {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetRedirectStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec RedirectEnd() {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetRedirectEnd();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec FetchStart() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetFetchStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec DomainLookupStart() const;
|
|
|
|
DOMTimeMilliSec DomainLookupEnd() const;
|
|
|
|
DOMTimeMilliSec ConnectStart() const;
|
|
|
|
DOMTimeMilliSec ConnectEnd() const;
|
|
|
|
DOMTimeMilliSec RequestStart() const;
|
|
|
|
DOMTimeMilliSec ResponseStart() const;
|
|
|
|
DOMTimeMilliSec ResponseEnd() const;
|
|
|
|
DOMTimeMilliSec DomLoading() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetDomLoading();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec DomInteractive() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetDomInteractive();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec DomContentLoadedEventStart() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetDomContentLoadedEventStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec DomContentLoadedEventEnd() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetDomContentLoadedEventEnd();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec DomComplete() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetDomComplete();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec LoadEventStart() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetLoadEventStart();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
DOMTimeMilliSec LoadEventEnd() const {
|
2013-05-11 02:57:58 +04:00
|
|
|
if (!nsContentUtils::IsPerformanceTimingEnabled()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetLoadEventEnd();
|
|
|
|
}
|
|
|
|
|
2011-06-23 14:39:48 +04:00
|
|
|
private:
|
|
|
|
~nsPerformanceTiming();
|
2012-07-17 05:42:18 +04:00
|
|
|
nsRefPtr<nsPerformance> mPerformance;
|
2011-07-04 20:44:00 +04:00
|
|
|
nsCOMPtr<nsITimedChannel> mChannel;
|
2011-06-23 14:39:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Script "performance.navigation" object
|
2012-12-07 01:01:59 +04:00
|
|
|
class nsPerformanceNavigation MOZ_FINAL : public nsWrapperCache
|
2011-06-23 14:39:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-07-17 05:42:18 +04:00
|
|
|
explicit nsPerformanceNavigation(nsPerformance* aPerformance);
|
2012-12-07 01:01:59 +04:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsPerformanceNavigation)
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsPerformanceNavigation)
|
2012-07-17 05:42:18 +04:00
|
|
|
|
|
|
|
nsDOMNavigationTiming* GetDOMTiming() const;
|
|
|
|
|
|
|
|
nsPerformance* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mPerformance;
|
|
|
|
}
|
|
|
|
|
2013-04-25 20:29:54 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
2012-07-17 05:42:18 +04:00
|
|
|
|
|
|
|
// PerformanceNavigation WebIDL methods
|
2012-09-11 23:08:24 +04:00
|
|
|
uint16_t Type() const {
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetType();
|
|
|
|
}
|
2012-09-11 23:08:24 +04:00
|
|
|
uint16_t RedirectCount() const {
|
2012-07-17 05:42:18 +04:00
|
|
|
return GetDOMTiming()->GetRedirectCount();
|
|
|
|
}
|
|
|
|
|
2011-06-23 14:39:48 +04:00
|
|
|
private:
|
|
|
|
~nsPerformanceNavigation();
|
2012-07-17 05:42:18 +04:00
|
|
|
nsRefPtr<nsPerformance> mPerformance;
|
2011-06-23 14:39:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Script "performance" object
|
2012-07-17 06:44:22 +04:00
|
|
|
class nsPerformance MOZ_FINAL : public nsISupports,
|
2012-07-17 05:42:18 +04:00
|
|
|
public nsWrapperCache
|
2011-06-23 14:39:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-07-17 05:42:18 +04:00
|
|
|
nsPerformance(nsIDOMWindow* aWindow,
|
|
|
|
nsDOMNavigationTiming* aDOMTiming,
|
|
|
|
nsITimedChannel* aChannel);
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2012-07-17 05:42:18 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsPerformance)
|
|
|
|
|
|
|
|
nsDOMNavigationTiming* GetDOMTiming() const
|
|
|
|
{
|
|
|
|
return mDOMTiming;
|
|
|
|
}
|
|
|
|
|
2012-08-09 07:47:04 +04:00
|
|
|
nsITimedChannel* GetChannel() const
|
|
|
|
{
|
|
|
|
return mChannel;
|
|
|
|
}
|
|
|
|
|
2012-07-17 05:42:18 +04:00
|
|
|
nsIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mWindow.get();
|
|
|
|
}
|
|
|
|
|
2013-04-25 20:29:54 +04:00
|
|
|
virtual JSObject* WrapObject(JSContext *cx,
|
|
|
|
JS::Handle<JSObject*> scope) MOZ_OVERRIDE;
|
2012-07-17 05:42:18 +04:00
|
|
|
|
|
|
|
// Performance WebIDL methods
|
|
|
|
DOMHighResTimeStamp Now();
|
2012-09-11 23:08:24 +04:00
|
|
|
nsPerformanceTiming* Timing();
|
|
|
|
nsPerformanceNavigation* Navigation();
|
2011-06-23 14:39:48 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
~nsPerformance();
|
|
|
|
|
2012-07-17 05:42:18 +04:00
|
|
|
nsCOMPtr<nsIDOMWindow> mWindow;
|
2011-07-04 20:44:00 +04:00
|
|
|
nsRefPtr<nsDOMNavigationTiming> mDOMTiming;
|
|
|
|
nsCOMPtr<nsITimedChannel> mChannel;
|
2012-07-17 05:42:18 +04:00
|
|
|
nsRefPtr<nsPerformanceTiming> mTiming;
|
|
|
|
nsRefPtr<nsPerformanceNavigation> mNavigation;
|
2011-06-23 14:39:48 +04:00
|
|
|
};
|
|
|
|
|
2012-07-17 05:42:18 +04:00
|
|
|
inline nsDOMNavigationTiming*
|
|
|
|
nsPerformanceNavigation::GetDOMTiming() const
|
|
|
|
{
|
|
|
|
return mPerformance->GetDOMTiming();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsDOMNavigationTiming*
|
|
|
|
nsPerformanceTiming::GetDOMTiming() const
|
|
|
|
{
|
|
|
|
return mPerformance->GetDOMTiming();
|
|
|
|
}
|
|
|
|
|
2011-06-23 14:39:48 +04:00
|
|
|
#endif /* nsPerformance_h___ */
|
|
|
|
|