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: */
|
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 nsDOMNavigationTiming_h___
|
|
|
|
#define nsDOMNavigationTiming_h___
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCOMArray.h"
|
2017-04-19 09:00:00 +03:00
|
|
|
#include "mozilla/WeakPtr.h"
|
2018-03-13 20:36:34 +03:00
|
|
|
#include "mozilla/RelativeTimeline.h"
|
2011-09-16 03:47:29 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2017-04-19 09:00:00 +03:00
|
|
|
class nsDocShell;
|
2013-08-15 22:17:48 +04:00
|
|
|
class nsIURI;
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2012-07-17 06:44:22 +04:00
|
|
|
typedef unsigned long long DOMTimeMilliSec;
|
|
|
|
typedef double DOMHighResTimeStamp;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDOMNavigationTiming final
|
2018-03-13 20:36:34 +03:00
|
|
|
: public mozilla::RelativeTimeline
|
2011-06-23 14:39:48 +04:00
|
|
|
{
|
|
|
|
public:
|
2016-06-10 17:29:46 +03:00
|
|
|
enum Type {
|
|
|
|
TYPE_NAVIGATE = 0,
|
|
|
|
TYPE_RELOAD = 1,
|
|
|
|
TYPE_BACK_FORWARD = 2,
|
|
|
|
TYPE_RESERVED = 255,
|
|
|
|
};
|
|
|
|
|
2017-04-19 09:00:00 +03:00
|
|
|
explicit nsDOMNavigationTiming(nsDocShell* aDocShell);
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2011-07-04 20:44:00 +04:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
|
|
|
|
|
2016-06-10 17:29:46 +03:00
|
|
|
Type GetType() const
|
|
|
|
{
|
2012-07-17 05:42:18 +04:00
|
|
|
return mNavigationType;
|
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
|
|
|
|
inline DOMHighResTimeStamp GetNavigationStartHighRes() const
|
|
|
|
{
|
2013-10-16 05:35:44 +04:00
|
|
|
return mNavigationStartHighRes;
|
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
|
|
|
|
DOMTimeMilliSec GetNavigationStart() const
|
|
|
|
{
|
2013-10-16 05:35:44 +04:00
|
|
|
return static_cast<int64_t>(GetNavigationStartHighRes());
|
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
|
|
|
|
mozilla::TimeStamp GetNavigationStartTimeStamp() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return mNavigationStart;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec GetUnloadEventStart()
|
|
|
|
{
|
|
|
|
return TimeStampToDOM(GetUnloadEventStartTimeStamp());
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMTimeMilliSec GetUnloadEventEnd()
|
|
|
|
{
|
|
|
|
return TimeStampToDOM(GetUnloadEventEndTimeStamp());
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
|
|
|
|
DOMTimeMilliSec GetDomLoading() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mDOMLoading);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetDomInteractive() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mDOMInteractive);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetDomContentLoadedEventStart() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mDOMContentLoadedEventStart);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetDomContentLoadedEventEnd() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mDOMContentLoadedEventEnd);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetDomComplete() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mDOMComplete);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetLoadEventStart() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mLoadEventStart);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2016-06-10 17:29:46 +03:00
|
|
|
DOMTimeMilliSec GetLoadEventEnd() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mLoadEventEnd);
|
2012-07-17 05:42:18 +04:00
|
|
|
}
|
2017-07-06 02:51:50 +03:00
|
|
|
DOMTimeMilliSec GetTimeToNonBlankPaint() const
|
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
return TimeStampToDOM(mNonBlankPaint);
|
|
|
|
}
|
2018-04-27 01:36:52 +03:00
|
|
|
DOMTimeMilliSec GetTimeToDOMContentFlushed() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOM(mDOMContentFlushed);
|
|
|
|
}
|
2017-10-04 05:05:39 +03:00
|
|
|
|
|
|
|
DOMHighResTimeStamp GetUnloadEventStartHighRes()
|
|
|
|
{
|
|
|
|
mozilla::TimeStamp stamp = GetUnloadEventStartTimeStamp();
|
|
|
|
if (stamp.IsNull()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighRes(stamp);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetUnloadEventEndHighRes()
|
|
|
|
{
|
|
|
|
mozilla::TimeStamp stamp = GetUnloadEventEndTimeStamp();
|
|
|
|
if (stamp.IsNull()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return TimeStampToDOMHighRes(stamp);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetDomInteractiveHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mDOMInteractive);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetDomContentLoadedEventStartHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mDOMContentLoadedEventStart);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetDomContentLoadedEventEndHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mDOMContentLoadedEventEnd);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetDomCompleteHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mDOMComplete);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetLoadEventStartHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mLoadEventStart);
|
|
|
|
}
|
|
|
|
DOMHighResTimeStamp GetLoadEventEndHighRes() const
|
|
|
|
{
|
|
|
|
return TimeStampToDOMHighRes(mLoadEventEnd);
|
2017-07-06 02:51:50 +03:00
|
|
|
}
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2016-11-10 22:26:54 +03:00
|
|
|
enum class DocShellState : uint8_t {
|
|
|
|
eActive,
|
|
|
|
eInactive
|
|
|
|
};
|
|
|
|
|
|
|
|
void NotifyNavigationStart(DocShellState aDocShellState);
|
2016-06-10 17:29:46 +03:00
|
|
|
void NotifyFetchStart(nsIURI* aURI, Type aNavigationType);
|
2011-06-23 14:39:48 +04:00
|
|
|
void NotifyBeforeUnload();
|
|
|
|
void NotifyUnloadAccepted(nsIURI* aOldURI);
|
|
|
|
void NotifyUnloadEventStart();
|
|
|
|
void NotifyUnloadEventEnd();
|
|
|
|
void NotifyLoadEventStart();
|
|
|
|
void NotifyLoadEventEnd();
|
|
|
|
|
|
|
|
// Document changes state to 'loading' before connecting to timing
|
|
|
|
void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
|
|
|
|
void NotifyDOMLoading(nsIURI* aURI);
|
|
|
|
void NotifyDOMInteractive(nsIURI* aURI);
|
|
|
|
void NotifyDOMComplete(nsIURI* aURI);
|
|
|
|
void NotifyDOMContentLoadedStart(nsIURI* aURI);
|
|
|
|
void NotifyDOMContentLoadedEnd(nsIURI* aURI);
|
2016-11-11 00:00:45 +03:00
|
|
|
|
2016-11-10 22:26:54 +03:00
|
|
|
void NotifyNonBlankPaintForRootContentDocument();
|
2018-04-27 01:36:52 +03:00
|
|
|
void NotifyDOMContentFlushedForRootContentDocument();
|
2016-11-10 22:26:54 +03:00
|
|
|
void NotifyDocShellStateChanged(DocShellState aDocShellState);
|
2016-11-11 00:00:45 +03:00
|
|
|
|
2012-07-17 05:42:18 +04:00
|
|
|
DOMTimeMilliSec TimeStampToDOM(mozilla::TimeStamp aStamp) const;
|
2011-06-23 14:39:48 +04:00
|
|
|
|
2017-07-06 02:51:50 +03:00
|
|
|
inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp) const
|
2012-04-27 11:22:06 +04:00
|
|
|
{
|
2017-10-04 05:05:39 +03:00
|
|
|
if (aStamp.IsNull()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mozilla::TimeDuration duration = aStamp - mNavigationStart;
|
2012-04-27 11:22:06 +04:00
|
|
|
return duration.ToMilliseconds();
|
|
|
|
}
|
|
|
|
|
2011-06-23 14:39:48 +04:00
|
|
|
private:
|
2015-01-07 02:35:02 +03:00
|
|
|
nsDOMNavigationTiming(const nsDOMNavigationTiming &) = delete;
|
2011-06-23 14:39:48 +04:00
|
|
|
~nsDOMNavigationTiming();
|
|
|
|
|
|
|
|
void Clear();
|
|
|
|
|
2017-10-04 05:05:39 +03:00
|
|
|
mozilla::TimeStamp GetUnloadEventStartTimeStamp() const;
|
|
|
|
mozilla::TimeStamp GetUnloadEventEndTimeStamp() const;
|
|
|
|
|
2017-08-23 06:09:24 +03:00
|
|
|
bool IsTopLevelContentDocumentInContentProcess() const;
|
2017-04-19 09:00:00 +03:00
|
|
|
|
|
|
|
mozilla::WeakPtr<nsDocShell> mDocShell;
|
|
|
|
|
2011-06-23 14:39:48 +04:00
|
|
|
nsCOMPtr<nsIURI> mUnloadedURI;
|
|
|
|
nsCOMPtr<nsIURI> mLoadedURI;
|
|
|
|
|
2016-06-10 17:29:46 +03:00
|
|
|
Type mNavigationType;
|
2013-10-16 05:35:44 +04:00
|
|
|
DOMHighResTimeStamp mNavigationStartHighRes;
|
2017-10-04 05:05:39 +03:00
|
|
|
mozilla::TimeStamp mNavigationStart;
|
|
|
|
mozilla::TimeStamp mNonBlankPaint;
|
2018-04-27 01:36:52 +03:00
|
|
|
mozilla::TimeStamp mDOMContentFlushed;
|
2017-10-04 05:05:39 +03:00
|
|
|
|
|
|
|
mozilla::TimeStamp mBeforeUnloadStart;
|
|
|
|
mozilla::TimeStamp mUnloadStart;
|
|
|
|
mozilla::TimeStamp mUnloadEnd;
|
|
|
|
mozilla::TimeStamp mLoadEventStart;
|
|
|
|
mozilla::TimeStamp mLoadEventEnd;
|
|
|
|
|
|
|
|
mozilla::TimeStamp mDOMLoading;
|
|
|
|
mozilla::TimeStamp mDOMInteractive;
|
|
|
|
mozilla::TimeStamp mDOMContentLoadedEventStart;
|
|
|
|
mozilla::TimeStamp mDOMContentLoadedEventEnd;
|
|
|
|
mozilla::TimeStamp mDOMComplete;
|
|
|
|
|
2016-11-10 22:26:54 +03:00
|
|
|
bool mDocShellHasBeenActiveSinceNavigationStart : 1;
|
2011-06-23 14:39:48 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* nsDOMNavigationTiming_h___ */
|