bug 570341 - Initial implementation of web timing specification

r=smaug sr=biesi

--HG--
extra : rebase_source : e8b233ebcf1065ea5e6df61446cfd013262a61d0
This commit is contained in:
Igor Bazarny 2011-05-23 14:19:36 -07:00
Родитель ed147e5327
Коммит 0dd92c4fcb
36 изменённых файлов: 1608 добавлений и 33 удалений

Просмотреть файл

@ -110,6 +110,7 @@ class nsFrameLoader;
class nsIBoxObject;
class imgIRequest;
class nsISHEntry;
class nsDOMNavigationTiming;
namespace mozilla {
namespace css {
@ -124,8 +125,8 @@ class Element;
#define NS_IDOCUMENT_IID \
{ 0x26ef6218, 0xcd5e, 0x4953, \
{ 0xbb, 0x57, 0xb8, 0x50, 0x29, 0xa1, 0xae, 0x40 } }
{ 0x2c6ad63f, 0xb7b9, 0x42f8, \
{ 0xbd, 0xde, 0x76, 0x0a, 0x83, 0xe3, 0xb0, 0x49 } }
// Flag for AddStyleSheet().
#define NS_STYLESHEET_FROM_CATALOG (1 << 0)
@ -1519,6 +1520,11 @@ public:
virtual nsresult GetStateObject(nsIVariant** aResult) = 0;
virtual nsDOMNavigationTiming* GetNavigationTiming() const = 0;
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming) = 0;
protected:
~nsIDocument()
{

Просмотреть файл

@ -211,6 +211,7 @@ INCLUDES += \
-I$(topsrcdir)/js/src/xpconnect/src \
-I$(topsrcdir)/caps/include \
-I$(topsrcdir)/netwerk/base/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -183,6 +183,7 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
#include "mozAutoDocUpdate.h"
#include "nsGlobalWindow.h"
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
#include "nsDOMNavigationTiming.h"
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
@ -4103,6 +4104,10 @@ nsDocument::DispatchContentLoadedEvents()
// Unpin references to preloaded images
mPreloadingImages.Clear();
if (mTiming) {
mTiming->NotifyDOMContentLoadedStart(nsIDocument::GetDocumentURI());
}
// Fire a DOM event notifying listeners that this document has been
// loaded (excluding images and other loads initiated by this
@ -4111,6 +4116,10 @@ nsDocument::DispatchContentLoadedEvents()
NS_LITERAL_STRING("DOMContentLoaded"),
PR_TRUE, PR_TRUE);
if (mTiming) {
mTiming->NotifyDOMContentLoadedEnd(nsIDocument::GetDocumentURI());
}
// If this document is a [i]frame, fire a DOMFrameContentLoaded
// event on all parent documents notifying that the HTML (excluding
// other external files such as images and stylesheets) in a frame
@ -7695,6 +7704,26 @@ void
nsDocument::SetReadyStateInternal(ReadyState rs)
{
mReadyState = rs;
if (mTiming) {
switch (rs) {
case READYSTATE_LOADING:
mTiming->NotifyDOMLoading(nsIDocument::GetDocumentURI());
break;
case READYSTATE_INTERACTIVE:
mTiming->NotifyDOMInteractive(nsIDocument::GetDocumentURI());
break;
case READYSTATE_COMPLETE:
mTiming->NotifyDOMComplete(nsIDocument::GetDocumentURI());
break;
default:
NS_WARNING("Unexpected ReadyState value");
break;
}
}
// At the time of loading start, we don't have timing object, record time.
if (READYSTATE_LOADING == rs) {
mLoadingTimeStamp = mozilla::TimeStamp::Now();
}
nsRefPtr<nsPLDOMEvent> plevent =
new nsPLDOMEvent(this, NS_LITERAL_STRING("readystatechange"), PR_FALSE, PR_FALSE);
@ -8163,6 +8192,22 @@ nsDocument::GetStateObject(nsIVariant** aState)
return NS_OK;
}
nsDOMNavigationTiming*
nsDocument::GetNavigationTiming() const
{
return mTiming;
}
nsresult
nsDocument::SetNavigationTiming(nsDOMNavigationTiming* aTiming)
{
mTiming = aTiming;
if (!mLoadingTimeStamp.IsNull() && mTiming) {
mTiming->SetDOMLoadingTimeStamp(nsIDocument::GetDocumentURI(), mLoadingTimeStamp);
}
return NS_OK;
}
nsresult
nsDocument::AddImage(imgIRequest* aImage)
{
@ -8383,4 +8428,3 @@ nsDocument::CreateTouchList(nsIVariant* aPoints,
*aRetVal = retval.forget().get();
return NS_OK;
}

Просмотреть файл

@ -106,6 +106,8 @@
#include "nsIDOMDOMImplementation.h"
#include "nsIDOMTouchEvent.h"
#include "TimeStamp.h"
#define XML_DECLARATION_BITS_DECLARATION_EXISTS (1 << 0)
#define XML_DECLARATION_BITS_ENCODING_EXISTS (1 << 1)
#define XML_DECLARATION_BITS_STANDALONE_EXISTS (1 << 2)
@ -127,6 +129,7 @@ class nsChildContentList;
class nsXMLEventsManager;
class nsHTMLStyleSheet;
class nsHTMLCSSStyleSheet;
class nsDOMNavigationTiming;
/**
* Right now our identifier map entries contain information for 'name'
@ -961,6 +964,10 @@ public:
virtual nsresult GetStateObject(nsIVariant** aResult);
virtual nsDOMNavigationTiming* GetNavigationTiming() const;
virtual nsresult SetNavigationTiming(nsDOMNavigationTiming* aTiming);
protected:
friend class nsNodeUtils;
@ -1095,6 +1102,9 @@ protected:
nsClassHashtable<nsStringHashKey, nsRadioGroupStruct> mRadioGroups;
// Recorded time of change to 'loading' state.
mozilla::TimeStamp mLoadingTimeStamp;
// True if the document has been detached from its content viewer.
PRPackedBool mIsGoingAway:1;
// True if the document is being destroyed.
@ -1153,6 +1163,7 @@ protected:
nsEventStates mDocumentState;
nsEventStates mGotDocumentState;
nsRefPtr<nsDOMNavigationTiming> mTiming;
private:
friend class nsUnblockOnloadEvent;

Просмотреть файл

@ -145,6 +145,7 @@ INCLUDES += \
-I$(srcdir)/../../../../editor/libeditor/base \
-I$(srcdir)/../../../../editor/libeditor/text \
-I$(srcdir) \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -77,6 +77,7 @@ INCLUDES += \
-I$(srcdir)/../../../../dom/base \
-I$(srcdir)/../../../../xpcom/io \
-I$(srcdir)/../../../../caps/include \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -63,6 +63,7 @@ INCLUDES += \
-I$(srcdir)/../../../../layout/style \
-I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../events/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -88,6 +88,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../events/src \
-I$(srcdir)/../../../layout/style \
-I$(srcdir)/../../../dom/base \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -69,6 +69,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../../events/src \
-I$(srcdir)/../../../../dom/base \
-I$(srcdir)/../../../../caps/include \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -73,6 +73,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../../html/content/src \
-I$(srcdir)/../../../events/src \
-I$(srcdir)/../../../xbl/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -75,6 +75,7 @@ LOCAL_INCLUDES = -I$(srcdir)/../../../base/src \
-I$(srcdir)/../../../xml/document/src \
-I$(srcdir)/../../../xbl/src \
-I$(srcdir)/../../../events/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -118,6 +118,8 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir)/../shistory/src \
-I$(topsrcdir)/dom/base \
-I$(topsrcdir)/layout/base \
-I$(topsrcdir)/js/src/xpconnect/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)

Просмотреть файл

@ -235,6 +235,8 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#include "nsXULAppAPI.h"
#include "nsDOMNavigationTiming.h"
using namespace mozilla;
// Number of documents currently loading
@ -674,6 +676,45 @@ DispatchPings(nsIContent *content, nsIURI *referrer)
ForEachPing(content, SendPing, &info);
}
static nsDOMPerformanceNavigationType
ConvertLoadTypeToNavigationType(PRUint32 aLoadType)
{
nsDOMPerformanceNavigationType result = nsIDOMPerformanceNavigation::TYPE_RESERVED;
switch (aLoadType) {
case LOAD_NORMAL:
case LOAD_NORMAL_EXTERNAL:
case LOAD_NORMAL_BYPASS_CACHE:
case LOAD_NORMAL_BYPASS_PROXY:
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
case LOAD_LINK:
result = nsIDOMPerformanceNavigation::TYPE_NAVIGATE;
break;
case LOAD_HISTORY:
result = nsIDOMPerformanceNavigation::TYPE_BACK_FORWARD;
break;
case LOAD_RELOAD_NORMAL:
case LOAD_RELOAD_CHARSET_CHANGE:
case LOAD_RELOAD_BYPASS_CACHE:
case LOAD_RELOAD_BYPASS_PROXY:
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
result = nsIDOMPerformanceNavigation::TYPE_RELOAD;
break;
case LOAD_NORMAL_REPLACE:
case LOAD_STOP_CONTENT:
case LOAD_STOP_CONTENT_AND_REPLACE:
case LOAD_REFRESH:
case LOAD_BYPASS_HISTORY:
case LOAD_ERROR_PAGE:
case LOAD_PUSHSTATE:
result = nsIDOMPerformanceNavigation::TYPE_RESERVED;
break;
default:
NS_NOTREACHED("Unexpected load type value");
}
return result;
}
static nsISHEntry* GetRootSHEntry(nsISHEntry *entry);
//*****************************************************************************
@ -1520,8 +1561,16 @@ nsDocShell::FirePageHideNotification(PRBool aIsUnload)
nsCOMPtr<nsIContentViewer> kungFuDeathGrip(mContentViewer);
mFiredUnloadEvent = PR_TRUE;
if (mTiming) {
mTiming->NotifyUnloadEventStart();
}
mContentViewer->PageHide(aIsUnload);
if (mTiming) {
mTiming->NotifyUnloadEventEnd();
}
nsAutoTArray<nsCOMPtr<nsIDocShell>, 8> kids;
PRInt32 i, n = mChildList.Count();
kids.SetCapacity(n);
@ -1543,6 +1592,23 @@ nsDocShell::FirePageHideNotification(PRBool aIsUnload)
return NS_OK;
}
nsresult
nsDocShell::MaybeInitTiming()
{
if (mTiming) {
return NS_OK;
}
PRBool enabled;
nsresult rv = mPrefs->GetBoolPref("dom.enable_performance", &enabled);
if (NS_SUCCEEDED(rv) && enabled) {
mTiming = new nsDOMNavigationTiming();
mTiming->NotifyNavigationStart();
}
return NS_OK;
}
//
// Bug 13871: Prevent frameset spoofing
//
@ -5824,15 +5890,22 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
nsresult rv;
if ((~aStateFlags & (STATE_START | STATE_IS_NETWORK)) == 0) {
// Save timing statistics.
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
// Make sure timing is created
rv = MaybeInitTiming();
nsCOMPtr<nsIURI> uri;
channel->GetURI(getter_AddRefs(uri));
if (mTiming) {
mTiming->NotifyFetchStart(uri, ConvertLoadTypeToNavigationType(mLoadType));
}
nsCOMPtr<nsIWyciwygChannel> wcwgChannel(do_QueryInterface(aRequest));
nsCOMPtr<nsIWebProgress> webProgress =
do_QueryInterface(GetAsSupports(this));
// Was the wyciwyg document loaded on this docshell?
if (wcwgChannel && !mLSHE && (mItemType == typeContent) && aProgress == webProgress.get()) {
nsCOMPtr<nsIURI> uri;
wcwgChannel->GetURI(getter_AddRefs(uri));
PRBool equalUri = PR_TRUE;
// Store the wyciwyg url in session history, only if it is
// being loaded fresh for the first time. We don't want
@ -5955,6 +6028,13 @@ nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
if (!oldURI || !newURI) {
return;
}
// On session restore we get a redirect from page to itself. Don't count it.
PRBool equals = PR_FALSE;
if (mTiming &&
!(mLoadType == LOAD_HISTORY &&
NS_SUCCEEDED(newURI->Equals(oldURI, &equals)) && equals)) {
mTiming->NotifyRedirect(oldURI, newURI);
}
// Below a URI visit is saved (see AddURIVisit method doc).
// The visit chain looks something like:
@ -6038,7 +6118,10 @@ nsDocShell::EndPageLoad(nsIWebProgress * aProgress,
nsCOMPtr<nsIURI> url;
nsresult rv = aChannel->GetURI(getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
// Timing is picked up by the window, we don't need it anymore
mTiming = nsnull;
// clean up reload state for meta charset
if (eCharsetReloadRequested == mCharsetReloadState)
mCharsetReloadState = eCharsetReloadStopOrigional;
@ -6467,6 +6550,13 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
// with about:blank. And also ensure we fire the unload events
// in the current document.
// Make sure timing is created. Unload gets fired first for
// document loaded from the session history.
rv = MaybeInitTiming();
if (mTiming) {
mTiming->NotifyBeforeUnload();
}
PRBool okToUnload;
rv = mContentViewer->PermitUnload(PR_FALSE, &okToUnload);
@ -6478,6 +6568,10 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
mSavingOldViewer = aTryToSaveOldPresentation &&
CanSavePresentation(LOAD_NORMAL, nsnull, nsnull);
if (mTiming) {
mTiming->NotifyUnloadAccepted(mCurrentURI);
}
// Make sure to blow away our mLoadingURI just in case. No loads
// from inside this pagehide.
mLoadingURI = nsnull;
@ -7697,6 +7791,12 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
nsIntRect bounds(x, y, cx, cy);
nsCOMPtr<nsIDocumentViewer> docviewer =
do_QueryInterface(mContentViewer);
if (docviewer) {
docviewer->SetNavigationTiming(mTiming);
}
if (NS_FAILED(mContentViewer->Init(widget, bounds))) {
mContentViewer = nsnull;
NS_ERROR("ContentViewer Initialization failed");
@ -7729,9 +7829,6 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
// Stuff the bgcolor from the old pres shell into the new
// pres shell. This improves page load continuity.
nsCOMPtr<nsIDocumentViewer> docviewer =
do_QueryInterface(mContentViewer);
if (docviewer) {
nsCOMPtr<nsIPresShell> shell;
docviewer->GetPresShell(getter_AddRefs(shell));
@ -8458,6 +8555,10 @@ nsDocShell::InternalLoad(nsIURI * aURI,
// (bug#331040)
nsCOMPtr<nsIDocShell> kungFuDeathGrip(this);
rv = MaybeInitTiming();
if (mTiming) {
mTiming->NotifyBeforeUnload();
}
// Check if the page doesn't want to be unloaded. The javascript:
// protocol handler deals with this for javascript: URLs.
if (!bIsJavascript && mContentViewer) {
@ -8471,6 +8572,10 @@ nsDocShell::InternalLoad(nsIURI * aURI,
}
}
if (mTiming) {
mTiming->NotifyUnloadAccepted(mCurrentURI);
}
// Check for saving the presentation here, before calling Stop().
// This is necessary so that we can catch any pending requests.
// Since the new request has not been created yet, we pass null for the
@ -11681,7 +11786,6 @@ nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
#endif
}
#ifdef DEBUG
unsigned long nsDocShell::gNumberOfDocShells = 0;
#endif

Просмотреть файл

@ -119,6 +119,7 @@ class nsDocShell;
class nsIController;
class OnLinkClickEvent;
class nsIScrollableFrame;
class nsDOMNavigationTiming;
/* load commands were moved to nsIDocShell.h */
/* load types were moved to nsDocShellLoadTypes.h */
@ -684,6 +685,8 @@ protected:
void ClearFrameHistory(nsISHEntry* aEntry);
nsresult MaybeInitTiming();
// Event type dispatched by RestorePresentation
class RestorePresentationEvent : public nsRunnable {
public:
@ -837,6 +840,8 @@ protected:
static nsIURIFixup *sURIFixup;
nsRefPtr<nsDOMNavigationTiming> mTiming;
#ifdef DEBUG
private:
// We're counting the number of |nsDocShells| to help find leaks

Просмотреть файл

@ -104,6 +104,8 @@ _TEST_FILES = \
test_framedhistoryframes.html \
test_windowedhistoryframes.html \
historyframes.html \
test_bug570341.html \
bug570341_recordevents.html \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)

Просмотреть файл

@ -0,0 +1,25 @@
<html>
<head>
<script>
var start = Date.now();
window._testing_js_start = Math.floor(start);
window._testing_js_start_fine = start;
window['_testing_js_after_' + document.readyState] = Math.floor(start);
document.addEventListener('DOMContentLoaded',
function () {
window._testing_evt_DOMContentLoaded = Math.floor(Date.now());
window._testing_evt_DOMContentLoaded_fine = Date.now();
}, true);
document.addEventListener('readystatechange', function(){
window['_testing_evt_DOM_' + document.readyState] = Math.floor(Date.now());
window['_testing_evt_DOM_' + document.readyState + '_fine'] = Date.now();
}, true);
function recordLoad() {
window._testing_evt_load = Math.floor(Date.now());
window._testing_evt_load_fine = Date.now();
}
</script>
</head>
<body onload="recordLoad()">This document collects time
for events related to the page load progress.</body>
</html>

Просмотреть файл

@ -0,0 +1,149 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=570341
-->
<head>
<title>Test for Bug 570341</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script>
var start = Date.now();
var moments = {};
var unload = 0;
var wasEnabled = true;
function collectMoments() {
var win = frames[0];
var timing = (win.performance && win.performance.timing) || {};
for (var p in timing) {
moments[p] = timing[p];
}
for (var p in win) {
if (p.substring(0,9) == '_testing_') {
moments[p.substring(9)] = win[p];
}
}
moments['evt_unload'] = Math.floor(unload);
moments['evt_unload_fine'] = unload;
return moments;
}
function showSequence(node){
while(node.firstChild) {
node.removeChild(node.firstChild);
}
var sequence = [];
for (var p in moments) {
sequence.push(p);
}
sequence.sort(function(a, b){
return moments[a] - moments[b];
});
table = document.createElement('table');
node.appendChild(table);
row = document.createElement('tr');
table.appendChild(row);
cell = document.createElement('td');
row.appendChild(cell);
cell.appendChild(document.createTextNode('start'));
cell = document.createElement('td');
row.appendChild(cell);
cell.appendChild(document.createTextNode(start));
for (var i = 0; i < sequence.length; ++i) {
var prop = sequence[i];
row = document.createElement('tr');
table.appendChild(row);
cell = document.createElement('td');
row.appendChild(cell);
cell.appendChild(document.createTextNode(prop));
cell = document.createElement('td');
row.appendChild(cell);
cell.appendChild(document.createTextNode(moments[prop]));
}
}
function checkValues(){
collectMoments();
var sequences = [
['navigationStart', 'unloadEventStart', 'evt_unload' , 'unloadEventEnd'],
['navigationStart', 'fetchStart', 'domainLookupStart', 'domainLookupEnd',
'connectStart', 'connectEnd', 'requestStart', 'responseStart', 'responseEnd'],
['responseStart', 'domLoading', 'domInteractive', 'domComplete'],
['domContentLoadedEventStart', 'evt_DOMContentLoaded', 'domContentLoadedEventEnd',
'loadEventStart', 'evt_load', 'loadEventEnd']
]
for (var i = 0; i < sequences.length; ++i) {
var seq = sequences[i];
for (var j = 0; j < seq.length; ++j) {
var prop = seq[j];
if (j > 0) {
var prevProp = seq[j-1];
ok(moments[prevProp] <= moments[prop],
['Expected ', prevProp, ' to happen before ', prop,
', got ', prevProp, ' = ', moments[prevProp],
', ', prop, ' = ', moments[prop]].join(''));
}
}
}
try {
SpecialPowers.setBoolPref('dom.enable_performance', wasEnabled);
} catch (err) {
todo(false, 'Exception in SpecialPowers: ' + err + ' at ' + err.stack);
}
SimpleTest.finish()
}
window.onload = function() {
try {
wasEnabled = SpecialPowers.getBoolPref('dom.enable_performance');
} catch (err) {
todo(false, 'Exception in SpecialPowers: ' + err + ' at ' + err.stack);
}
SpecialPowers.setBoolPref('dom.enable_performance', true);
var win = frames[0];
win.addEventListener('unload', function(){
unload = Date.now();
}, true);
frames[0].location = 'bug570341_recordevents.html'
var seenLoad = 0;
win.addEventListener('load', function (){
seenLoad = Date.now();
}, true);
var interval = setInterval(function () {
var stopPolling = (win.performance && win.performance.loadEventEnd) ||
(seenLoad && Date.now() >= seenLoad + 200);
if (stopPolling) {
clearInterval(interval);
checkValues();
} else if (win._testing_evt_load) {
seenLoad = Date.now();
}
}, 100);
}
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=570341">Mozilla Bug 570341</a>
<div id="frames">
<iframe name="child0" src="navigation/blank.html"></iframe>
</div>
<button type="button" onclick="showSequence(document.getElementById('display'))">
Show Events</button>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
</script>
</pre>
</body>
</html>

Просмотреть файл

@ -110,6 +110,8 @@ CPPSRCS = \
nsQueryContentEventResult.cpp \
nsContentPermissionHelper.cpp \
nsStructuredCloneContainer.cpp \
nsDOMNavigationTiming.cpp \
nsPerformance.cpp \
$(NULL)
include $(topsrcdir)/dom/dom-config.mk
@ -126,6 +128,7 @@ include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES += \
-I$(srcdir)/../../js/src/xpconnect/src \
-I$(srcdir)/../../js/src/xpconnect/wrappers \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
ifdef MOZ_X11

Просмотреть файл

@ -121,6 +121,9 @@
#include "nsIDOMMediaList.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMConstructor.h"
#include "nsIDOMPerformanceTiming.h"
#include "nsIDOMPerformanceNavigation.h"
#include "nsIDOMPerformance.h"
#include "nsClientRect.h"
// DOM core includes
@ -695,6 +698,12 @@ static nsDOMClassInfoData sClassInfoData[] = {
NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH,
ARRAY_SCRIPTABLE_FLAGS |
nsIXPCScriptable::WANT_PRECREATE)
NS_DEFINE_CLASSINFO_DATA(PerformanceTiming, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(PerformanceNavigation, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Performance, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(Screen, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMConstructorSH,
@ -2397,26 +2406,53 @@ nsDOMClassInfo::Init()
NS_ENSURE_SUCCESS(rv, rv);
if (nsGlobalWindow::HasIndexedDBSupport()) {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
if (nsGlobalWindow::HasPerformanceSupport()) {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance)
DOM_CLASSINFO_MAP_END
} else {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
}
} else {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
if (nsGlobalWindow::HasPerformanceSupport()) {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowPerformance)
DOM_CLASSINFO_MAP_END
} else {
DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
DOM_CLASSINFO_MAP_END
}
}
DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
@ -2466,6 +2502,21 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceTiming, nsIDOMPerformanceTiming,
!nsGlobalWindow::HasPerformanceSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceTiming)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(PerformanceNavigation, nsIDOMPerformanceNavigation,
!nsGlobalWindow::HasPerformanceSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformanceNavigation)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_MAYBE_DISABLE(Performance, nsIDOMPerformance,
!nsGlobalWindow::HasPerformanceSupport())
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen)
DOM_CLASSINFO_MAP_END

Просмотреть файл

@ -45,6 +45,9 @@ DOMCI_CLASS(MimeType)
DOMCI_CLASS(MimeTypeArray)
DOMCI_CLASS(BarProp)
DOMCI_CLASS(History)
DOMCI_CLASS(PerformanceTiming)
DOMCI_CLASS(PerformanceNavigation)
DOMCI_CLASS(Performance)
DOMCI_CLASS(Screen)
DOMCI_CLASS(DOMPrototype)
DOMCI_CLASS(DOMConstructor)

Просмотреть файл

@ -0,0 +1,420 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (lots of improvements)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDOMNavigationTiming.h"
#include "nsCOMPtr.h"
#include "nscore.h"
#include "TimeStamp.h"
#include "nsContentUtils.h"
#include "nsIDOMEventTarget.h"
#include "nsIDocument.h"
#include "nsIScriptSecurityManager.h"
nsDOMNavigationTiming::nsDOMNavigationTiming()
{
Clear();
}
nsDOMNavigationTiming::~nsDOMNavigationTiming()
{
}
void
nsDOMNavigationTiming::Clear()
{
mNavigationType = nsIDOMPerformanceNavigation::TYPE_RESERVED;
mNavigationStart = 0;
mFetchStart = 0;
mRedirectStart = 0;
mRedirectEnd = 0;
mBeforeUnloadStart = 0;
mUnloadStart = 0;
mUnloadEnd = 0;
mLoadEventStart = 0;
mLoadEventEnd = 0;
mDOMLoading = 0;
mDOMInteractive = 0;
mDOMContentLoadedEventStart = 0;
mDOMContentLoadedEventEnd = 0;
mDOMComplete = 0;
mRedirectCheck = NOT_CHECKED;
}
DOMTimeMilliSec nsDOMNavigationTiming::DurationFromStart(){
mozilla::TimeDuration duration = mozilla::TimeStamp::Now() - mNavigationStartTimeStamp;
return mNavigationStart + (int)(duration.ToMilliseconds() + 0.5);
}
void
nsDOMNavigationTiming::NotifyNavigationStart()
{
mNavigationStart = PR_Now() / PR_USEC_PER_MSEC;
mNavigationStartTimeStamp = mozilla::TimeStamp::Now();
}
void
nsDOMNavigationTiming::NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType)
{
mFetchStart = DurationFromStart();
mNavigationType = aNavigationType;
// At the unload event time we don't really know the loading uri.
// Need it for later check for unload timing access.
mLoadedURI = aURI;
}
void
nsDOMNavigationTiming::NotifyRedirect(nsIURI* aOldURI, nsIURI* aNewURI)
{
if (mRedirects.Count() == 0) {
mRedirectStart = mFetchStart;
}
mFetchStart = DurationFromStart();
mRedirectEnd = mFetchStart;
// At the unload event time we don't really know the loading uri.
// Need it for later check for unload timing access.
mLoadedURI = aNewURI;
mRedirects.AppendObject(aOldURI);
}
void
nsDOMNavigationTiming::NotifyBeforeUnload()
{
mBeforeUnloadStart = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyUnloadAccepted(nsIURI* aOldURI)
{
mUnloadStart = mBeforeUnloadStart;
mUnloadedURI = aOldURI;
}
void
nsDOMNavigationTiming::NotifyUnloadEventStart()
{
mUnloadStart = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyUnloadEventEnd()
{
mUnloadEnd = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyLoadEventStart()
{
mLoadEventStart = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyLoadEventEnd()
{
mLoadEventEnd = DurationFromStart();
}
PRBool
nsDOMNavigationTiming::ReportRedirects()
{
if (mRedirectCheck == NOT_CHECKED) {
if (mRedirects.Count() == 0) {
mRedirectCheck = NO_REDIRECTS;
} else {
mRedirectCheck = CHECK_PASSED;
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
for (int i = mRedirects.Count() - 1; i >= 0; --i) {
nsIURI * curr = mRedirects[i];
nsresult rv = ssm->CheckSameOriginURI(curr, mLoadedURI, PR_FALSE);
if (!NS_SUCCEEDED(rv)) {
mRedirectCheck = CHECK_FAILED;
break;
}
}
// All we need to know is in mRedirectCheck now. Clear history.
mRedirects.Clear();
}
}
return mRedirectCheck == CHECK_PASSED;
}
void
nsDOMNavigationTiming::SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue)
{
mLoadedURI = aURI;
mozilla::TimeDuration duration = aValue - mNavigationStartTimeStamp;
mDOMLoading = mNavigationStart + (int)(duration.ToMilliseconds() + 0.5);
}
void
nsDOMNavigationTiming::NotifyDOMLoading(nsIURI* aURI)
{
mLoadedURI = aURI;
mDOMLoading = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI)
{
mLoadedURI = aURI;
mDOMInteractive = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI)
{
mLoadedURI = aURI;
mDOMComplete = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI)
{
mLoadedURI = aURI;
mDOMContentLoadedEventStart = DurationFromStart();
}
void
nsDOMNavigationTiming::NotifyDOMContentLoadedEnd(nsIURI* aURI)
{
mLoadedURI = aURI;
mDOMContentLoadedEventEnd = DurationFromStart();
}
NS_IMPL_ADDREF(nsDOMNavigationTiming)
NS_IMPL_RELEASE(nsDOMNavigationTiming)
// QueryInterface implementation for nsDOMNavigationTiming
NS_INTERFACE_MAP_BEGIN(nsDOMNavigationTiming)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPerformanceTiming)
NS_INTERFACE_MAP_ENTRY(nsIDOMPerformanceTiming)
NS_INTERFACE_MAP_ENTRY(nsIDOMPerformanceNavigation)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsDOMNavigationTiming::GetType(
nsDOMPerformanceNavigationType* aNavigationType)
{
*aNavigationType = mNavigationType;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetRedirectCount(PRUint16* aRedirectCount)
{
*aRedirectCount = 0;
if (ReportRedirects()) {
*aRedirectCount = mRedirects.Count();
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetRedirectStart(DOMTimeMilliSec* aRedirectStart)
{
*aRedirectStart = 0;
if (ReportRedirects()) {
*aRedirectStart = mRedirectStart;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetRedirectEnd(DOMTimeMilliSec* aEnd)
{
*aEnd = 0;
if (ReportRedirects()) {
*aEnd = mRedirectEnd;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetNavigationStart(DOMTimeMilliSec* aNavigationStart)
{
*aNavigationStart = mNavigationStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetUnloadEventStart(DOMTimeMilliSec* aStart)
{
*aStart = 0;
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
nsresult rv = ssm->CheckSameOriginURI(mLoadedURI, mUnloadedURI, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
*aStart = mUnloadStart;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetUnloadEventEnd(DOMTimeMilliSec* aEnd)
{
*aEnd = 0;
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
nsresult rv = ssm->CheckSameOriginURI(mLoadedURI, mUnloadedURI, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
*aEnd = mUnloadEnd;
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetFetchStart(DOMTimeMilliSec* aStart)
{
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomainLookupStart(DOMTimeMilliSec* aStart)
{
// TODO: Implement me! (bug 659126)
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomainLookupEnd(DOMTimeMilliSec* aEnd)
{
// TODO: Implement me! (bug 659126)
*aEnd = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetConnectStart(DOMTimeMilliSec* aStart)
{
// TODO: Implement me! (bug 659126)
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetConnectEnd(DOMTimeMilliSec* aEnd)
{
// TODO: Implement me! (bug 659126)
*aEnd = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetHandshakeStart(DOMTimeMilliSec* aStart)
{
// TODO: Implement me! (bug 659126)
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetRequestStart(DOMTimeMilliSec* aStart)
{
// TODO: Implement me! (bug 659126)
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetResponseStart(DOMTimeMilliSec* aStart)
{
// TODO: Implement me! (bug 659126)
*aStart = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetResponseEnd(DOMTimeMilliSec* aEnd)
{
// TODO: Implement me! (bug 659126)
*aEnd = mFetchStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomLoading(DOMTimeMilliSec* aTime)
{
*aTime = mDOMLoading;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomInteractive(DOMTimeMilliSec* aTime)
{
*aTime = mDOMInteractive;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomContentLoadedEventStart(DOMTimeMilliSec* aStart)
{
*aStart = mDOMContentLoadedEventStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomContentLoadedEventEnd(DOMTimeMilliSec* aEnd)
{
*aEnd = mDOMContentLoadedEventEnd;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetDomComplete(DOMTimeMilliSec* aTime)
{
*aTime = mDOMComplete;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetLoadEventStart(DOMTimeMilliSec* aStart)
{
*aStart = mLoadEventStart;
return NS_OK;
}
NS_IMETHODIMP
nsDOMNavigationTiming::GetLoadEventEnd(DOMTimeMilliSec* aEnd)
{
*aEnd = mLoadEventEnd;
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,121 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (lots of improvements)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDOMNavigationTiming_h___
#define nsDOMNavigationTiming_h___
#include "nsIDOMPerformanceTiming.h"
#include "nsIDOMPerformanceNavigation.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "TimeStamp.h"
class nsDOMNavigationTimingClock;
class nsIURI;
class nsIDocument;
class nsDOMNavigationTiming : public nsIDOMPerformanceTiming,
public nsIDOMPerformanceNavigation
{
public:
nsDOMNavigationTiming();
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMPERFORMANCETIMING
NS_DECL_NSIDOMPERFORMANCENAVIGATION
void NotifyNavigationStart();
void NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType);
void NotifyRedirect(nsIURI* aOldURI, nsIURI* aNewURI);
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);
private:
nsDOMNavigationTiming(const nsDOMNavigationTiming &){};
~nsDOMNavigationTiming();
void Clear();
PRBool ReportRedirects();
nsCOMPtr<nsIURI> mUnloadedURI;
nsCOMPtr<nsIURI> mLoadedURI;
nsCOMArray<nsIURI> mRedirects;
typedef enum { NOT_CHECKED,
CHECK_PASSED,
NO_REDIRECTS,
CHECK_FAILED} RedirectCheckState;
RedirectCheckState mRedirectCheck;
nsDOMPerformanceNavigationType mNavigationType;
DOMTimeMilliSec mNavigationStart;
mozilla::TimeStamp mNavigationStartTimeStamp;
DOMTimeMilliSec DurationFromStart();
DOMTimeMilliSec mFetchStart;
DOMTimeMilliSec mRedirectStart;
DOMTimeMilliSec mRedirectEnd;
DOMTimeMilliSec mBeforeUnloadStart;
DOMTimeMilliSec mUnloadStart;
DOMTimeMilliSec mUnloadEnd;
DOMTimeMilliSec mNavigationEnd;
DOMTimeMilliSec mLoadEventStart;
DOMTimeMilliSec mLoadEventEnd;
DOMTimeMilliSec mDOMLoading;
DOMTimeMilliSec mDOMInteractive;
DOMTimeMilliSec mDOMContentLoadedEventStart;
DOMTimeMilliSec mDOMContentLoadedEventEnd;
DOMTimeMilliSec mDOMComplete;
};
#endif /* nsDOMNavigationTiming_h___ */

Просмотреть файл

@ -52,6 +52,8 @@
#include "nsGlobalWindow.h"
#include "nsScreen.h"
#include "nsHistory.h"
#include "nsPerformance.h"
#include "nsDOMNavigationTiming.h"
#include "nsBarProps.h"
#include "nsDOMStorage.h"
#include "nsDOMOfflineResourceList.h"
@ -1117,6 +1119,7 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog)
mIndexedDB = nsnull;
mPendingStorageEventsObsolete = nsnull;
mPerformance = nsnull;
ClearControllers();
@ -1341,6 +1344,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
NS_INTERFACE_MAP_ENTRY(nsIDOMWindowPerformance)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
OUTER_WINDOW_ONLY
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@ -2720,7 +2724,6 @@ nsGlobalWindow::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
// be a pres context available). Since we're not firing a GUI
// event we don't need a pres context anyway so we just pass
// null as the pres context all the time here.
nsEventDispatcher::Dispatch(content, nsnull, &event, nsnull, &status);
}
}
@ -2950,6 +2953,25 @@ nsGlobalWindow::GetHistory(nsIDOMHistory** aHistory)
return NS_OK;
}
NS_IMETHODIMP
nsGlobalWindow::GetPerformance(nsIDOMPerformance** aPerformance)
{
FORWARD_TO_INNER(GetPerformance, (aPerformance), NS_ERROR_NOT_INITIALIZED);
*aPerformance = nsnull;
if (nsGlobalWindow::HasPerformanceSupport()) {
if (!mPerformance) {
nsRefPtr<nsDOMNavigationTiming> timing = mDoc->GetNavigationTiming();
if (timing) {
mPerformance = new nsPerformance(timing);
}
}
NS_IF_ADDREF(*aPerformance = mPerformance);
}
return NS_OK;
}
NS_IMETHODIMP
nsGlobalWindow::GetParent(nsIDOMWindow** aParent)
{

Просмотреть файл

@ -138,6 +138,7 @@ class nsLocation;
class nsNavigator;
class nsScreen;
class nsHistory;
class nsPerformance;
class nsIDocShellLoadInfo;
class WindowStateHolder;
class nsGlobalWindowObserver;
@ -285,7 +286,8 @@ class nsGlobalWindow : public nsPIDOMWindow,
public nsIInterfaceRequestor,
public nsIDOMWindow_2_0_BRANCH,
public nsWrapperCache,
public PRCListStr
public PRCListStr,
public nsIDOMWindowPerformance
{
public:
friend class nsDOMMozURLProperty;
@ -333,6 +335,9 @@ public:
// nsIDOMWindowInternal
NS_DECL_NSIDOMWINDOWINTERNAL
// nsIDOMWindowPerformance
NS_DECL_NSIDOMWINDOWPERFORMANCE
// nsIDOMJSWindow
NS_DECL_NSIDOMJSWINDOW
@ -572,6 +577,14 @@ public:
return nsContentUtils::GetBoolPref("indexedDB.feature.enabled", PR_TRUE);
}
static bool HasPerformanceSupport() {
#ifdef DEBUG
return nsContentUtils::GetBoolPref("dom.enable_performance", PR_TRUE);
#else
return nsContentUtils::GetBoolPref("dom.enable_performance", PR_FALSE);
#endif
}
private:
// Enable updates for the accelerometer.
void EnableAccelerationUpdates();
@ -906,6 +919,7 @@ protected:
nsCOMPtr<nsIPrincipal> mArgumentsOrigin;
nsRefPtr<nsNavigator> mNavigator;
nsRefPtr<nsScreen> mScreen;
nsRefPtr<nsPerformance> mPerformance;
nsRefPtr<nsDOMWindowList> mFrames;
nsRefPtr<nsBarProp> mMenubar;
nsRefPtr<nsBarProp> mToolbar;

276
dom/base/nsPerformance.cpp Normal file
Просмотреть файл

@ -0,0 +1,276 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (update to match bearly-final spec)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPerformance.h"
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsIDocShell.h"
#include "nsDOMClassInfo.h"
#include "nsDOMNavigationTiming.h"
DOMCI_DATA(PerformanceTiming, nsPerformanceTiming)
NS_IMPL_ADDREF(nsPerformanceTiming)
NS_IMPL_RELEASE(nsPerformanceTiming)
// QueryInterface implementation for nsPerformanceTiming
NS_INTERFACE_MAP_BEGIN(nsPerformanceTiming)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPerformanceTiming)
NS_INTERFACE_MAP_ENTRY(nsIDOMPerformanceTiming)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PerformanceTiming)
NS_INTERFACE_MAP_END
nsPerformanceTiming::nsPerformanceTiming(nsDOMNavigationTiming* aData)
{
NS_ASSERTION(aData, "Timing data should be provided");
mData = aData;
}
nsPerformanceTiming::~nsPerformanceTiming()
{
}
NS_IMETHODIMP
nsPerformanceTiming::GetNavigationStart(DOMTimeMilliSec* aTime)
{
return mData->GetNavigationStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetUnloadEventStart(DOMTimeMilliSec* aTime)
{
return mData->GetUnloadEventStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetUnloadEventEnd(DOMTimeMilliSec* aTime)
{
return mData->GetUnloadEventEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetRedirectStart(DOMTimeMilliSec* aTime)
{
return mData->GetRedirectStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetRedirectEnd(DOMTimeMilliSec* aTime)
{
return mData->GetRedirectEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetFetchStart(DOMTimeMilliSec* aTime)
{
return mData->GetFetchStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomainLookupStart(DOMTimeMilliSec* aTime)
{
return mData->GetDomainLookupStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomainLookupEnd(DOMTimeMilliSec* aTime)
{
return mData->GetDomainLookupEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetConnectStart(DOMTimeMilliSec* aTime)
{
return mData->GetConnectStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetConnectEnd(DOMTimeMilliSec* aTime)
{
return mData->GetConnectEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetHandshakeStart(DOMTimeMilliSec* aTime)
{
return mData->GetHandshakeStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetRequestStart(DOMTimeMilliSec* aTime)
{
return mData->GetRequestStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetResponseStart(DOMTimeMilliSec* aTime)
{
return mData->GetResponseStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetResponseEnd(DOMTimeMilliSec* aTime)
{
return mData->GetResponseEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomLoading(DOMTimeMilliSec* aTime)
{
return mData->GetDomLoading(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomInteractive(DOMTimeMilliSec* aTime)
{
return mData->GetDomInteractive(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomContentLoadedEventStart(DOMTimeMilliSec* aTime)
{
return mData->GetDomContentLoadedEventStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomContentLoadedEventEnd(DOMTimeMilliSec* aTime)
{
return mData->GetDomContentLoadedEventEnd(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetDomComplete(DOMTimeMilliSec* aTime)
{
return mData->GetDomComplete(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetLoadEventStart(DOMTimeMilliSec* aTime)
{
return mData->GetLoadEventStart(aTime);
}
NS_IMETHODIMP
nsPerformanceTiming::GetLoadEventEnd(DOMTimeMilliSec* aTime)
{
return mData->GetLoadEventEnd(aTime);
}
DOMCI_DATA(PerformanceNavigation, nsPerformanceNavigation)
NS_IMPL_ADDREF(nsPerformanceNavigation)
NS_IMPL_RELEASE(nsPerformanceNavigation)
// QueryInterface implementation for nsPerformanceNavigation
NS_INTERFACE_MAP_BEGIN(nsPerformanceNavigation)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPerformanceNavigation)
NS_INTERFACE_MAP_ENTRY(nsIDOMPerformanceNavigation)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PerformanceNavigation)
NS_INTERFACE_MAP_END
nsPerformanceNavigation::nsPerformanceNavigation(nsDOMNavigationTiming* aData)
{
NS_ASSERTION(aData, "Timing data should be provided");
mData = aData;
}
nsPerformanceNavigation::~nsPerformanceNavigation()
{
}
NS_IMETHODIMP
nsPerformanceNavigation::GetType(
nsDOMPerformanceNavigationType* aNavigationType)
{
return mData->GetType(aNavigationType);
}
NS_IMETHODIMP
nsPerformanceNavigation::GetRedirectCount(PRUint16* aRedirectCount)
{
return mData->GetRedirectCount(aRedirectCount);
}
DOMCI_DATA(Performance, nsPerformance)
NS_IMPL_ADDREF(nsPerformance)
NS_IMPL_RELEASE(nsPerformance)
nsPerformance::nsPerformance(nsDOMNavigationTiming* aTiming)
{
NS_ASSERTION(aTiming, "Timing data should be provided");
mData = aTiming;
}
nsPerformance::~nsPerformance()
{
}
// QueryInterface implementation for nsPerformance
NS_INTERFACE_MAP_BEGIN(nsPerformance)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPerformance)
NS_INTERFACE_MAP_ENTRY(nsIDOMPerformance)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Performance)
NS_INTERFACE_MAP_END
//
// nsIDOMPerformance methods
//
NS_IMETHODIMP
nsPerformance::GetTiming(nsIDOMPerformanceTiming** aTiming)
{
if (!mTiming) {
mTiming = new nsPerformanceTiming(mData);
}
NS_IF_ADDREF(*aTiming = mTiming);
return NS_OK;
}
NS_IMETHODIMP
nsPerformance::GetNavigation(nsIDOMPerformanceNavigation** aNavigation)
{
if (!mNavigation) {
mNavigation = new nsPerformanceNavigation(mData);
}
NS_IF_ADDREF(*aNavigation = mNavigation);
return NS_OK;
}

95
dom/base/nsPerformance.h Normal file
Просмотреть файл

@ -0,0 +1,95 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (update to match bearly-final spec)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPerformance_h___
#define nsPerformance_h___
#include "nsIDOMPerformance.h"
#include "nsIDOMPerformanceTiming.h"
#include "nsIDOMPerformanceNavigation.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
class nsIDocument;
class nsIURI;
class nsDOMNavigationTiming;
// Script "performance.timing" object
class nsPerformanceTiming : public nsIDOMPerformanceTiming
{
public:
nsPerformanceTiming(nsDOMNavigationTiming* data);
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMPERFORMANCETIMING
private:
~nsPerformanceTiming();
nsRefPtr<nsDOMNavigationTiming> mData;
};
// Script "performance.navigation" object
class nsPerformanceNavigation : public nsIDOMPerformanceNavigation
{
public:
nsPerformanceNavigation(nsDOMNavigationTiming* data);
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMPERFORMANCENAVIGATION
private:
~nsPerformanceNavigation();
nsRefPtr<nsDOMNavigationTiming> mData;
};
// Script "performance" object
class nsPerformance : public nsIDOMPerformance
{
public:
nsPerformance(nsDOMNavigationTiming* timing);
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMPERFORMANCE
private:
~nsPerformance();
nsRefPtr<nsDOMNavigationTiming> mData;
nsCOMPtr<nsIDOMPerformanceTiming> mTiming;
nsCOMPtr<nsIDOMPerformanceNavigation> mNavigation;
};
#endif /* nsPerformance_h___ */

Просмотреть файл

@ -88,6 +88,9 @@ XPIDLSRCS = \
nsITabParent.idl \
nsIDOMGlobalPropertyInitializer.idl \
nsIStructuredCloneContainer.idl \
nsIDOMPerformance.idl \
nsIDOMPerformanceTiming.idl \
nsIDOMPerformanceNavigation.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsISupports.idl"
typedef unsigned long long DOMTimeStamp;
typedef unsigned long long DOMTimeMilliSec;
// Core
interface nsIDOMAttr;

Просмотреть файл

@ -0,0 +1,50 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (update to match nearly-final spec)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMPerformanceTiming;
interface nsIDOMPerformanceNavigation;
[scriptable, uuid(446faf26-000b-4e66-a5fd-ae37c5ed6beb)]
interface nsIDOMPerformance : nsISupports
{
readonly attribute nsIDOMPerformanceTiming timing;
readonly attribute nsIDOMPerformanceNavigation navigation;
};

Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (update to match nearly-final spec)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
typedef unsigned short nsDOMPerformanceNavigationType;
[scriptable, uuid(a2132ad8-a841-4285-a140-338e8de6c2e0)]
interface nsIDOMPerformanceNavigation : nsISupports
{
const nsDOMPerformanceNavigationType TYPE_NAVIGATE = 0;
const nsDOMPerformanceNavigationType TYPE_RELOAD = 1;
const nsDOMPerformanceNavigationType TYPE_BACK_FORWARD = 2;
const nsDOMPerformanceNavigationType TYPE_RESERVED = 255;
readonly attribute nsDOMPerformanceNavigationType type;
readonly attribute unsigned short redirectCount;
};

Просмотреть файл

@ -0,0 +1,67 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is implementation of Web Timing draft specification
* http://dev.w3.org/2006/webapi/WebTiming/
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Sergey Novikov <sergeyn@google.com> (original author)
* Igor Bazarny <igor.bazarny@gmail.com> (update to match nearly-final spec)
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
[scriptable, uuid(2a630b50-61b6-41b3-996d-70be67fbbcb0)]
interface nsIDOMPerformanceTiming : nsISupports
{
readonly attribute DOMTimeMilliSec navigationStart;
readonly attribute DOMTimeMilliSec unloadEventStart;
readonly attribute DOMTimeMilliSec unloadEventEnd;
readonly attribute DOMTimeMilliSec redirectStart;
readonly attribute DOMTimeMilliSec redirectEnd;
readonly attribute DOMTimeMilliSec fetchStart;
readonly attribute DOMTimeMilliSec domainLookupStart;
readonly attribute DOMTimeMilliSec domainLookupEnd;
readonly attribute DOMTimeMilliSec connectStart;
readonly attribute DOMTimeMilliSec connectEnd;
readonly attribute DOMTimeMilliSec handshakeStart;
readonly attribute DOMTimeMilliSec requestStart;
readonly attribute DOMTimeMilliSec responseStart;
readonly attribute DOMTimeMilliSec responseEnd;
readonly attribute DOMTimeMilliSec domLoading;
readonly attribute DOMTimeMilliSec domInteractive;
readonly attribute DOMTimeMilliSec domContentLoadedEventStart;
readonly attribute DOMTimeMilliSec domContentLoadedEventEnd;
readonly attribute DOMTimeMilliSec domComplete;
readonly attribute DOMTimeMilliSec loadEventStart;
readonly attribute DOMTimeMilliSec loadEventEnd;
};

Просмотреть файл

@ -46,11 +46,12 @@
interface nsIPrompt;
interface nsIControllers;
interface nsIDOMLocation;
interface nsIDOMPerformance;
interface nsIVariant;
interface nsIAnimationFrameListener;
interface nsIDOMMediaQueryList;
[scriptable, uuid(3a7b0839-b9d6-42ff-8ba6-910aba60a966)]
[scriptable, uuid(5930f197-259e-4f6b-aeca-c96a74518cc6)]
interface nsIDOMWindowInternal : nsIDOMWindow2
{
readonly attribute nsIDOMWindowInternal window;
@ -256,3 +257,13 @@ interface nsIDOMWindow_2_0_BRANCH : nsISupports
{
readonly attribute nsIDOMMozURLProperty URL;
};
[scriptable, uuid(2146c906-57f7-486c-a1b4-8cdb57ef577f)]
interface nsIDOMWindowPerformance : nsISupports
{
/**
* A namespace to hold performance related data and statistics.
*/
readonly attribute nsIDOMPerformance performance;
};

Просмотреть файл

@ -121,6 +121,7 @@ LOCAL_INCLUDES = \
-I$(topsrcdir)/layout/style \
-I$(topsrcdir)/layout/base \
-I$(topsrcdir)/dom/base \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
EXTRA_DSO_LDOPTS += \

Просмотреть файл

@ -165,6 +165,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../dom/base \
-I$(srcdir)/../../content/html/content/src \
-I$(srcdir)/../../content/svg/content/src \
-I$(topsrcdir)/xpcom/ds \
$(NULL)
ifdef MOZ_MATHML

Просмотреть файл

@ -115,6 +115,7 @@
#include "nsIClipboardHelper.h"
#include "nsPIDOMWindow.h"
#include "nsDOMNavigationTiming.h"
#include "nsPIWindowRoot.h"
#include "nsJSEnvironment.h"
#include "nsFocusManager.h"
@ -324,6 +325,11 @@ public:
*/
virtual nsIView* FindContainerView();
/**
* Set collector for navigation timing data (load, unload events).
*/
virtual void SetNavigationTiming(nsDOMNavigationTiming* timing);
// nsIContentViewerEdit
NS_DECL_NSICONTENTVIEWEREDIT
@ -992,6 +998,14 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
return rv;
}
void DocumentViewerImpl::SetNavigationTiming(nsDOMNavigationTiming* timing)
{
NS_ASSERTION(mDocument, "Must have a document to set navigation timing.");
if (mDocument) {
mDocument->SetNavigationTiming(timing);
}
}
//
// LoadComplete(aStatus)
//
@ -1053,8 +1067,15 @@ DocumentViewerImpl::LoadComplete(nsresult aStatus)
docShell->GetRestoringDocument(&restoring);
if (!restoring) {
nsRefPtr<nsDOMNavigationTiming> timing(mDocument->GetNavigationTiming());
if (timing) {
timing->NotifyLoadEventStart();
}
nsEventDispatcher::Dispatch(window, mPresContext, &event, nsnull,
&status);
if (timing) {
timing->NotifyLoadEventEnd();
}
#ifdef MOZ_TIMELINE
// if navigator.xul's load is complete, the main nav window is visible
// mark that point.

Просмотреть файл

@ -48,6 +48,8 @@ class nsIPresShell;
class nsIStyleSheet;
class nsIView;
class nsDOMNavigationTiming;
#define NS_IDOCUMENT_VIEWER_IID \
{ 0x5a5c9a1d, 0x49c4, 0x4f3f, \
{ 0x80, 0xcd, 0x12, 0x09, 0x5b, 0x1e, 0x1f, 0x61 } }
@ -69,6 +71,8 @@ public:
PRBool aForceReuseInnerWindow) = 0;
virtual nsIView* FindContainerView() = 0;
virtual void SetNavigationTiming(nsDOMNavigationTiming* timing) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewer, NS_IDOCUMENT_VIEWER_IID)