+
X
Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 494409 Details for
Bug 570341
[patch]
Draft implementation of the web timing spec
timing_20101201.diff (text/plain), 34.34 KB, created by
Igor Bazarny
(
hide
)
Description:
Draft implementation of the web timing spec
Filename:
MIME Type:
Creator:
Igor Bazarny
Size:
34.34 KB
patch
obsolete
>diff -r e1983b9db75d docshell/base/Makefile.in >--- a/docshell/base/Makefile.in Sat Nov 27 14:52:33 2010 +0100 >+++ b/docshell/base/Makefile.in Wed Dec 01 17:21:23 2010 +0100 >@@ -110,4 +110,5 @@ > > LOCAL_INCLUDES += -I$(srcdir)/../shistory/src \ > -I$(srcdir)/../../layout/base \ >+ -I$(srcdir)/../../dom/base \ > $(NULL) >diff -r e1983b9db75d docshell/base/nsDocShell.cpp >--- a/docshell/base/nsDocShell.cpp Sat Nov 27 14:52:33 2010 +0100 >+++ b/docshell/base/nsDocShell.cpp Wed Dec 01 17:21:23 2010 +0100 >@@ -234,6 +234,8 @@ > #include "nsXULAppAPI.h" > #endif > >+#include "nsDOMNavigationTiming.h" >+ > using namespace mozilla; > > // Number of documents currently loading >@@ -675,6 +677,47 @@ > ForEachPing(content, SendPing, &info); > } > >+static nsDOMNavigationTimingType >+ConvertLoadTypeToNavigationType(PRUint32 aLoadType) >+{ >+ nsDOMNavigationTimingType result = nsIDOMNavigationTiming::NAVIGATION_OTHER; >+ 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: >+ result = nsIDOMNavigationTiming::NAVIGATION_BROWSER; >+ break; >+ case LOAD_HISTORY: >+ result = nsIDOMNavigationTiming::NAVIGATION_FORWARD_BACK; >+ 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 = nsIDOMNavigationTiming::NAVIGATION_RELOAD; >+ break; >+ case LOAD_LINK: >+ result = nsIDOMNavigationTiming::NAVIGATION_LINK; >+ 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 = nsIDOMNavigationTiming::NAVIGATION_OTHER; >+ break; >+ default: >+ NS_NOTREACHED("Unexpected load type value"); >+ } >+ >+ return result; >+} >+ > static nsISHEntry* GetRootSHEntry(nsISHEntry *entry); > > //***************************************************************************** >@@ -1534,10 +1577,37 @@ > // Now make sure our editor, if any, is detached before we go > // any farther. > DetachEditorFromWindow(); >- } >- >- return NS_OK; >-} >+ // Make sure timing is created. mCurrentURI is out of date. >+ nsresult rv = initTiming(mLoadingURI); >+ NS_ENSURE_SUCCESS(rv, rv); >+ mTiming->NotifyLastUnload(mCurrentURI); >+ } >+ >+ return NS_OK; >+} >+ >+nsresult >+nsDocShell::initTiming(nsIURI* aCurrentURI) >+{ >+ if (mTiming) { >+ return NS_OK; >+ } >+ mTiming = new nsDOMNavigationTiming(); >+ NS_ENSURE_TRUE(mTiming, NS_ERROR_OUT_OF_MEMORY); >+ >+ // Is this a new window or a frame? >+ nsDOMNavigationTimingType navType = >+ nsIDOMNavigationTiming::NAVIGATION_NEW_WINDOW; >+ nsCOMPtr<nsIDocShellTreeItem> root; >+ GetSameTypeParent(getter_AddRefs(root)); >+ if (root && root != this) { >+ navType = nsIDOMNavigationTiming::NAVIGATION_FRAME; >+ } >+ >+ mTiming->NotifyNavigationStart(aCurrentURI, navType); >+ return NS_OK; >+} >+ > > // > // Bug 13871: Prevent frameset spoofing >@@ -5789,15 +5859,26 @@ > nsresult rv; > > if ((~aStateFlags & (STATE_START | STATE_IS_NETWORK)) == 0) { >+ // Save timing statistics. >+ nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest)); >+ nsCOMPtr<nsIURI> uri; >+ channel->GetURI(getter_AddRefs(uri)); >+ if (mTiming) { >+ mTiming->NotifyNavigationStart(uri, >+ ConvertLoadTypeToNavigationType(mLoadType)); >+ } >+ else { >+ // Create and notify about the navigation start >+ rv = initTiming(uri); >+ NS_ENSURE_SUCCESS(rv, rv); >+ } >+ > 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 >@@ -5915,6 +5996,7 @@ > nsCOMPtr<nsIURI> oldURI, newURI; > aOldChannel->GetURI(getter_AddRefs(oldURI)); > aNewChannel->GetURI(getter_AddRefs(newURI)); >+ mTiming->NotifyRedirectStart(newURI); > if (!oldURI || !newURI) { > return; > } >@@ -6003,7 +6085,9 @@ > nsCOMPtr<nsIURI> url; > nsresult rv = aChannel->GetURI(getter_AddRefs(url)); > if (NS_FAILED(rv)) return rv; >- >+ >+ mTiming->NotifyNavigationEnd(url); >+ > // clean up reload state for meta charset > if (eCharsetReloadRequested == mCharsetReloadState) > mCharsetReloadState = eCharsetReloadStopOrigional; >@@ -11583,6 +11667,13 @@ > #endif > } > >+NS_IMETHODIMP >+nsDocShell::GetNavigationTiming(nsIDOMNavigationTiming** aNavigationTiming) >+{ >+ NS_IF_ADDREF(*aNavigationTiming = mTiming); >+ return NS_OK; >+} >+ > > #ifdef DEBUG > unsigned long nsDocShell::gNumberOfDocShells = 0; >diff -r e1983b9db75d docshell/base/nsDocShell.h >--- a/docshell/base/nsDocShell.h Sat Nov 27 14:52:33 2010 +0100 >+++ b/docshell/base/nsDocShell.h Wed Dec 01 17:21:23 2010 +0100 >@@ -120,6 +120,7 @@ > class nsIController; > class OnLinkClickEvent; > class nsIScrollableFrame; >+class nsDOMNavigationTiming; > > /* load commands were moved to nsIDocShell.h */ > /* load types were moved to nsDocShellLoadTypes.h */ >@@ -673,6 +674,8 @@ > > void ClearFrameHistory(nsISHEntry* aEntry); > >+ nsresult initTiming(nsIURI* aCurrentURI); >+ > // Event type dispatched by RestorePresentation > class RestorePresentationEvent : public nsRunnable { > public: >@@ -825,6 +828,8 @@ > > static nsIURIFixup *sURIFixup; > >+ nsCOMPtr<nsDOMNavigationTiming> mTiming; >+ > #ifdef DEBUG > private: > // We're counting the number of |nsDocShells| to help find leaks >diff -r e1983b9db75d docshell/base/nsIDocShell.idl >--- a/docshell/base/nsIDocShell.idl Sat Nov 27 14:52:33 2010 +0100 >+++ b/docshell/base/nsIDocShell.idl Wed Dec 01 17:21:23 2010 +0100 >@@ -70,6 +70,7 @@ > interface nsIPrincipal; > interface nsIWebBrowserPrint; > interface nsIVariant; >+interface nsIDOMNavigationTiming; > > [scriptable, uuid(98cdbcc4-2d81-4191-a63f-b6c52085edbc)] > interface nsIDocShell : nsISupports >@@ -540,6 +541,11 @@ > * handling link clicks. Docshells are not app tabs unless told otherwise. > */ > attribute boolean isAppTab; >+ >+ /** >+ * Time statistics been collected during last navigations. >+ */ >+ readonly attribute nsIDOMNavigationTiming navigationTiming; > }; > > [uuid(5f7a2184-31b6-4d67-9c75-0c17477766e2)] >diff -r e1983b9db75d dom/base/Makefile.in >--- a/dom/base/Makefile.in Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/base/Makefile.in Wed Dec 01 17:21:23 2010 +0100 >@@ -106,6 +106,8 @@ > nsScriptNameSpaceManager.cpp \ > nsDOMScriptObjectFactory.cpp \ > nsQueryContentEventResult.cpp \ >+ nsDOMNavigationTiming.cpp \ >+ nsPerformance.cpp \ > $(NULL) > > ifdef MOZ_IPC >diff -r e1983b9db75d dom/base/nsDOMClassInfo.cpp >--- a/dom/base/nsDOMClassInfo.cpp Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/base/nsDOMClassInfo.cpp Wed Dec 01 17:21:23 2010 +0100 >@@ -118,6 +118,8 @@ > #include "nsIDOMMediaList.h" > #include "nsIDOMChromeWindow.h" > #include "nsIDOMConstructor.h" >+#include "nsIDOMNavigationTiming.h" >+#include "nsIDOMPerformance.h" > #include "nsClientRect.h" > > // DOM core includes >@@ -666,6 +668,10 @@ > NS_DEFINE_CLASSINFO_DATA(History, nsHistorySH, > ARRAY_SCRIPTABLE_FLAGS | > nsIXPCScriptable::WANT_PRECREATE) >+ NS_DEFINE_CLASSINFO_DATA(NavigationTiming, 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, >@@ -2291,6 +2297,14 @@ > DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory) > DOM_CLASSINFO_MAP_END > >+ DOM_CLASSINFO_MAP_BEGIN(NavigationTiming, nsIDOMNavigationTiming) >+ DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigationTiming) >+ DOM_CLASSINFO_MAP_END >+ >+ DOM_CLASSINFO_MAP_BEGIN(Performance, nsIDOMPerformance) >+ DOM_CLASSINFO_MAP_ENTRY(nsIDOMPerformance) >+ DOM_CLASSINFO_MAP_END >+ > DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen) > DOM_CLASSINFO_MAP_ENTRY(nsIDOMScreen) > DOM_CLASSINFO_MAP_END >diff -r e1983b9db75d dom/base/nsDOMClassInfoClasses.h >--- a/dom/base/nsDOMClassInfoClasses.h Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/base/nsDOMClassInfoClasses.h Wed Dec 01 17:21:23 2010 +0100 >@@ -45,6 +45,8 @@ > DOMCI_CLASS(MimeTypeArray) > DOMCI_CLASS(BarProp) > DOMCI_CLASS(History) >+DOMCI_CLASS(NavigationTiming) >+DOMCI_CLASS(Performance) > DOMCI_CLASS(Screen) > DOMCI_CLASS(DOMPrototype) > DOMCI_CLASS(DOMConstructor) >diff -r e1983b9db75d dom/base/nsDOMNavigationTiming.cpp >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/base/nsDOMNavigationTiming.cpp Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,205 @@ >+/* -*- 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) >+ * >+ * 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 "prinrval.h" >+#include "nsContentUtils.h" >+ >+#define _IMPL_NS_LAYOUT 1 >+#include "nsDOMClassInfo.h" >+ >+// Helper class. >+class nsDOMNavigationTimingClock >+{ >+public: >+ nsDOMNavigationTimingClock() { Reset(); } >+ >+ void Reset() >+ { >+ mStartMilliSec = PR_Now()/PR_USEC_PER_MSEC; >+ mIntervalEpoch = PR_IntervalNow(); >+ } >+ >+ PRUint64 GetTimeMilliSec() >+ { >+ return mStartMilliSec + >+ PR_IntervalToMilliseconds(PR_IntervalNow() - mIntervalEpoch); >+ } >+private: >+ PRUint64 mStartMilliSec; >+ PRIntervalTime mIntervalEpoch; >+}; >+ >+ >+nsDOMNavigationTiming::nsDOMNavigationTiming() : mClock(new nsDOMNavigationTimingClock) >+{ >+ Clear(); >+} >+ >+nsDOMNavigationTiming::~nsDOMNavigationTiming() >+{ >+ delete mClock; >+} >+ >+void >+nsDOMNavigationTiming::Clear() >+{ >+ mClock->Reset(); >+ mNavigationType = nsIDOMNavigationTiming::NAVIGATION_OTHER; >+ mNavigationStart = 0; >+ mRedirectStart = 0; >+ mRedirectCount = 0; >+ mLastUnload = 0; >+ mNavigationEnd = 0; >+} >+ >+void >+nsDOMNavigationTiming::NotifyNavigationStart(nsIURI* aURI, >+ nsDOMNavigationTimingType aNavigationType) >+{ >+ Clear(); >+ mNavigationType = aNavigationType; >+ mNavigationStart = mClock->GetTimeMilliSec(); >+ mCurrentURI = aURI; >+} >+ >+void >+nsDOMNavigationTiming::NotifyRedirectStart(nsIURI* aURI) >+{ >+ if (mRedirectCount == 0) >+ mRedirectStart = mNavigationStart; >+ >+ mNavigationStart = mClock->GetTimeMilliSec(); >+ ++mRedirectCount; >+ mCurrentURI = aURI; >+} >+ >+void >+nsDOMNavigationTiming::NotifyLastUnload(nsIURI* aURI) >+{ >+ mLastUnload = mClock->GetTimeMilliSec(); >+ mUnloadedURI = aURI; >+} >+ >+void >+nsDOMNavigationTiming::NotifyNavigationEnd(nsIURI* aURI) >+{ >+ mNavigationEnd = mClock->GetTimeMilliSec(); >+ mCurrentURI = aURI; >+} >+ >+void >+nsDOMNavigationTiming::SetRequestorURI(nsIURI* aURI) >+{ >+ mRequestorURI = aURI; >+} >+ >+DOMCI_DATA(NavigationTiming, nsDOMNavigationTiming) >+ >+NS_IMPL_ADDREF(nsDOMNavigationTiming) >+NS_IMPL_RELEASE(nsDOMNavigationTiming) >+ >+// QueryInterface implementation for nsDOMNavigationTiming >+NS_INTERFACE_MAP_BEGIN(nsDOMNavigationTiming) >+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMNavigationTiming) >+ NS_INTERFACE_MAP_ENTRY(nsIDOMNavigationTiming) >+ NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(NavigationTiming) >+NS_INTERFACE_MAP_END >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetUserNavigationType( >+ nsDOMNavigationTimingType* aNavigationType) >+{ >+ nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); >+ // TODO: Do we want a trace in the error console? >+ nsresult rv = >+ ssm->CheckSameOriginURI(mRequestorURI, mCurrentURI, PR_TRUE); >+ NS_ENSURE_SUCCESS(rv, rv); >+ *aNavigationType = mNavigationType; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetNavigationStart(DOMTimeMilliSec* aNavigationStart) >+{ >+ nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); >+ // TODO: Do we want a trace in the error console? >+ nsresult rv = >+ ssm->CheckSameOriginURI(mRequestorURI, mCurrentURI, PR_TRUE); >+ NS_ENSURE_SUCCESS(rv, rv); >+ *aNavigationStart = mNavigationStart; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetRedirectStart(DOMTimeMilliSec* aRedirectStart) >+{ >+ // TODO: Security check accorting to spec (urls before and after redirect). >+ *aRedirectStart = mRedirectStart; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetRedirectCount(PRUint16* aRedirectCount) >+{ >+ // TODO: Security check accorting to spec (urls before and after redirect). >+ *aRedirectCount = mRedirectCount; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetLastUnload(DOMTimeMilliSec* aLastUnload) >+{ >+ // TODO: Security check accorting to spec (unloades vs requestor). >+ *aLastUnload = mLastUnload; >+ return NS_OK; >+} >+ >+NS_IMETHODIMP >+nsDOMNavigationTiming::GetNavigationEnd(DOMTimeMilliSec* aNavigationEnd) >+{ >+ nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); >+ // TODO: Do we want a trace in the error console? >+ nsresult rv = >+ ssm->CheckSameOriginURI(mRequestorURI, mCurrentURI, PR_TRUE); >+ NS_ENSURE_SUCCESS(rv, rv); >+ *aNavigationEnd = mNavigationEnd; >+ return NS_OK; >+} >diff -r e1983b9db75d dom/base/nsDOMNavigationTiming.h >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/base/nsDOMNavigationTiming.h Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,84 @@ >+/* -*- 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) >+ * >+ * 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 "nsIDOMNavigationTiming.h" >+#include "nscore.h" >+#include "nsCOMPtr.h" >+ >+class nsDOMNavigationTimingClock; >+class nsIURI; >+ >+class nsDOMNavigationTiming : public nsIDOMNavigationTiming >+{ >+public: >+ nsDOMNavigationTiming(); >+ >+ NS_DECL_ISUPPORTS >+ NS_DECL_NSIDOMNAVIGATIONTIMING >+ >+ void NotifyNavigationStart(nsIURI* aURI, >+ nsDOMNavigationTimingType aNavigationType); >+ void NotifyRedirectStart(nsIURI* aURI); >+ void NotifyLastUnload(nsIURI* aURI); >+ void NotifyNavigationEnd(nsIURI* aURI); >+ void SetRequestorURI(nsIURI* aURI); >+ >+private: >+ nsDOMNavigationTiming(const nsDOMNavigationTiming &){}; >+ ~nsDOMNavigationTiming(); >+ void Clear(); >+ >+ nsDOMNavigationTimingClock* mClock; >+ >+ nsCOMPtr<nsIURI> mUnloadedURI; >+ nsCOMPtr<nsIURI> mCurrentURI; >+ nsCOMPtr<nsIURI> mRequestorURI; >+ >+ nsDOMNavigationTimingType mNavigationType; >+ DOMTimeMilliSec mNavigationStart; >+ DOMTimeMilliSec mRedirectStart; >+ PRUint16 mRedirectCount; >+ DOMTimeMilliSec mLastUnload; >+ DOMTimeMilliSec mNavigationEnd; >+}; >+ >+#endif /* nsDOMNavigationTiming_h___ */ >+ >diff -r e1983b9db75d dom/base/nsGlobalWindow.cpp >--- a/dom/base/nsGlobalWindow.cpp Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/base/nsGlobalWindow.cpp Wed Dec 01 17:21:23 2010 +0100 >@@ -53,6 +53,7 @@ > #include "nsGlobalWindow.h" > #include "nsScreen.h" > #include "nsHistory.h" >+#include "nsPerformance.h" > #include "nsBarProps.h" > #include "nsDOMStorage.h" > #include "nsDOMOfflineResourceList.h" >@@ -1089,6 +1090,7 @@ > mFrames = nsnull; > mApplicationCache = nsnull; > mIndexedDB = nsnull; >+ mPerformance = nsnull; > > ClearControllers(); > >@@ -2142,6 +2144,11 @@ > html_doc); > } > >+ // Force performance to be reinitialized if requested >+ if (newInnerWindow) { >+ newInnerWindow->mPerformance = nsnull; >+ } >+ > if (aDocument) { > aDocument->SetScriptGlobalObject(newInnerWindow); > } >@@ -2915,6 +2922,27 @@ > } > > NS_IMETHODIMP >+nsGlobalWindow::GetMozPerformance(nsIDOMPerformance** aPerformance) >+{ >+ FORWARD_TO_INNER(GetMozPerformance, (aPerformance), NS_ERROR_NOT_INITIALIZED); >+ >+ *aPerformance = nsnull; >+ >+ nsIDocShell* docShell = GetDocShell(); >+ if (!mPerformance && docShell) { >+ mPerformance = new nsPerformance(docShell); >+ if (!mPerformance) { >+ return NS_ERROR_OUT_OF_MEMORY; >+ } >+ // mPerformance is cleared in SetNewDocument() >+ mPerformance->SetRequestorURI(mDoc->GetDocumentURI()); >+ } >+ >+ NS_IF_ADDREF(*aPerformance = mPerformance); >+ return NS_OK; >+} >+ >+NS_IMETHODIMP > nsGlobalWindow::GetParent(nsIDOMWindow** aParent) > { > FORWARD_TO_OUTER(GetParent, (aParent), NS_ERROR_NOT_INITIALIZED); >diff -r e1983b9db75d dom/base/nsGlobalWindow.h >--- a/dom/base/nsGlobalWindow.h Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/base/nsGlobalWindow.h Wed Dec 01 17:21:23 2010 +0100 >@@ -137,6 +137,7 @@ > class nsNavigator; > class nsScreen; > class nsHistory; >+class nsPerformance; > class nsIDocShellLoadInfo; > class WindowStateHolder; > class nsGlobalWindowObserver; >@@ -877,6 +878,7 @@ > nsRefPtr<nsNavigator> mNavigator; > nsRefPtr<nsScreen> mScreen; > nsRefPtr<nsHistory> mHistory; >+ nsRefPtr<nsPerformance> mPerformance; > nsRefPtr<nsDOMWindowList> mFrames; > nsRefPtr<nsBarProp> mMenubar; > nsRefPtr<nsBarProp> mToolbar; >diff -r e1983b9db75d dom/base/nsPerformance.cpp >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/base/nsPerformance.cpp Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,96 @@ >+/* -*- 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) >+ * >+ * 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" >+ >+nsPerformance::nsPerformance(nsIDocShell* aDocShell) >+{ >+ SetDocShell(aDocShell); >+} >+ >+nsPerformance::~nsPerformance() >+{ >+} >+ >+DOMCI_DATA(Performance, nsPerformance) >+ >+NS_IMPL_ADDREF(nsPerformance) >+NS_IMPL_RELEASE(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 >+ >+void >+nsPerformance::SetDocShell(nsIDocShell* aDocShell) >+{ >+ mDocShell = do_GetWeakReference(aDocShell); >+} >+ >+void >+nsPerformance::SetRequestorURI(nsIURI* aURI) >+{ >+ mRequestorURI = aURI; >+} >+ >+// >+// nsIDOMPerformance methods >+// >+NS_IMETHODIMP >+nsPerformance::GetTiming(nsIDOMNavigationTiming** aNavigationTiming) >+{ >+ *aNavigationTiming = nsnull; >+ >+ nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell)); >+ NS_ENSURE_TRUE(docShell, NS_ERROR_NOT_AVAILABLE); >+ >+ nsresult rv = docShell->GetNavigationTiming(aNavigationTiming); >+ NS_ENSURE_SUCCESS(rv, rv); >+ static_cast<nsDOMNavigationTiming*>(*aNavigationTiming) >+ ->SetRequestorURI(mRequestorURI); >+ return NS_OK; >+} >+ >diff -r e1983b9db75d dom/base/nsPerformance.h >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/base/nsPerformance.h Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,68 @@ >+/* -*- 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) >+ * >+ * 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 "nscore.h" >+#include "nsWeakPtr.h" >+ >+class nsIDocShell; >+class nsIURI; >+ >+// Script "performance" object >+class nsPerformance : public nsIDOMPerformance >+{ >+public: >+ nsPerformance(nsIDocShell* aDocShell); >+ >+ NS_DECL_ISUPPORTS >+ NS_DECL_NSIDOMPERFORMANCE >+ >+ void SetDocShell(nsIDocShell* aDocShell); >+ void SetRequestorURI(nsIURI* aURI); >+ >+private: >+ ~nsPerformance(); >+ >+ nsWeakPtr mDocShell; >+ nsCOMPtr<nsIURI> mRequestorURI; >+}; >+ >+#endif /* nsPerformance_h___ */ >+ >diff -r e1983b9db75d dom/interfaces/base/Makefile.in >--- a/dom/interfaces/base/Makefile.in Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/interfaces/base/Makefile.in Wed Dec 01 17:21:23 2010 +0100 >@@ -86,6 +86,8 @@ > nsITabChild.idl \ > nsITabParent.idl \ > nsIDOMGlobalPropertyInitializer.idl \ >+ nsIDOMPerformance.idl \ >+ nsIDOMNavigationTiming.idl \ > $(NULL) > > include $(topsrcdir)/config/rules.mk >diff -r e1983b9db75d dom/interfaces/base/domstubs.idl >--- a/dom/interfaces/base/domstubs.idl Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/interfaces/base/domstubs.idl Wed Dec 01 17:21:23 2010 +0100 >@@ -40,6 +40,7 @@ > #include "nsISupports.idl" > > typedef unsigned long long DOMTimeStamp; >+typedef unsigned long long DOMTimeMilliSec; > > // Core > interface nsIDOMAttr; >diff -r e1983b9db75d dom/interfaces/base/nsIDOMNavigationTiming.idl >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/interfaces/base/nsIDOMNavigationTiming.idl Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,73 @@ >+/* -*- 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) >+ * >+ * 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 nsDOMNavigationTimingType; >+ >+[scriptable, uuid(2a630b50-61b6-41b3-996d-70be67fbbcb0)] >+interface nsIDOMNavigationTiming : nsISupports >+{ >+ const nsDOMNavigationTimingType NAVIGATION_OTHER = 0; >+ const nsDOMNavigationTimingType NAVIGATION_LINK = 1; >+ const nsDOMNavigationTimingType NAVIGATION_FORWARD_BACK = 2; >+ const nsDOMNavigationTimingType NAVIGATION_BROWSER = 3; >+ const nsDOMNavigationTimingType NAVIGATION_NEW_WINDOW = 4; >+ const nsDOMNavigationTimingType NAVIGATION_RELOAD = 5; >+ const nsDOMNavigationTimingType NAVIGATION_FRAME = 6; >+ readonly attribute nsDOMNavigationTimingType userNavigationType; >+ >+ readonly attribute DOMTimeMilliSec redirectStart; >+ readonly attribute unsigned short redirectCount; >+ readonly attribute DOMTimeMilliSec navigationStart; >+ readonly attribute DOMTimeMilliSec lastUnload; >+ readonly attribute DOMTimeMilliSec navigationEnd; >+ >+ // TODO: Implement commented attributes. >+ // 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 requestStart; >+ // readonly attribute DOMTimeMilliSec requestEnd; >+ // readonly attribute DOMTimeMilliSec responseStart; >+ // readonly attribute DOMTimeMilliSec responseEnd; >+}; >+ >diff -r e1983b9db75d dom/interfaces/base/nsIDOMPerformance.idl >--- /dev/null Thu Jan 01 00:00:00 1970 +0000 >+++ b/dom/interfaces/base/nsIDOMPerformance.idl Wed Dec 01 17:21:23 2010 +0100 >@@ -0,0 +1,48 @@ >+/* -*- 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) >+ * >+ * 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 nsIDOMNavigationTiming; >+interface nsIURI; >+ >+[scriptable, uuid(446faf26-000b-4e66-a5fd-ae37c5ed6beb)] >+interface nsIDOMPerformance : nsISupports >+{ >+ readonly attribute nsIDOMNavigationTiming timing; >+}; >+ >diff -r e1983b9db75d dom/interfaces/base/nsIDOMWindowInternal.idl >--- a/dom/interfaces/base/nsIDOMWindowInternal.idl Sat Nov 27 14:52:33 2010 +0100 >+++ b/dom/interfaces/base/nsIDOMWindowInternal.idl Wed Dec 01 17:21:23 2010 +0100 >@@ -42,10 +42,11 @@ > interface nsIPrompt; > interface nsIControllers; > interface nsIDOMLocation; >+interface nsIDOMPerformance; > interface nsIVariant; > interface nsIAnimationFrameListener; > >-[scriptable, uuid(9d6a1157-0719-46a7-b49f-7ffeaa0b5c86)] >+[scriptable, uuid(5930f197-259e-4f6b-aeca-c96a74518cc6)] > interface nsIDOMWindowInternal : nsIDOMWindow2 > { > readonly attribute nsIDOMWindowInternal window; >@@ -232,6 +233,11 @@ > * The current animation start time in milliseconds since the epoch. > */ > readonly attribute long long mozAnimationStartTime; >+ >+ /** >+ * A namespace to hold performance related data and statistics. >+ */ >+ readonly attribute nsIDOMPerformance mozPerformance; > }; > > [scriptable, uuid(8fc58f56-f769-4368-a098-edd08550cf1a)]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 570341
:
449469
|
456252
|
456279
|
494409
|
504681
|
507393
|
523992
|
524173
|
524820
|
524938
|
525089
|
525386
|
531923
|
532204
|
534567
|
534661
|
534663
|
534776
|
536050
|
537130
|
540060
|
541142
|
541145
|
541149
|
541319
|
554254
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载