1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is implementation of Web Timing draft specification
16 : * http://dev.w3.org/2006/webapi/WebTiming/
17 : *
18 : * The Initial Developer of the Original Code is Google Inc.
19 : * Portions created by the Initial Developer are Copyright (C) 2010
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Sergey Novikov <sergeyn@google.com> (original author)
24 : * Igor Bazarny <igor.bazarny@gmail.com> (lots of improvements)
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either of the GNU General Public License Version 2 or later (the "GPL"),
28 : * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef nsDOMNavigationTiming_h___
41 : #define nsDOMNavigationTiming_h___
42 :
43 : #include "nsIDOMPerformanceTiming.h"
44 : #include "nsIDOMPerformanceNavigation.h"
45 : #include "nscore.h"
46 : #include "nsCOMPtr.h"
47 : #include "nsCOMArray.h"
48 : #include "mozilla/TimeStamp.h"
49 : #include "nsIURI.h"
50 :
51 : class nsDOMNavigationTimingClock;
52 : class nsIDocument;
53 :
54 : class nsDOMNavigationTiming
55 : {
56 : public:
57 : nsDOMNavigationTiming();
58 :
59 0 : NS_INLINE_DECL_REFCOUNTING(nsDOMNavigationTiming)
60 : nsresult GetType(nsDOMPerformanceNavigationType* aNavigationType);
61 : nsresult GetRedirectCount(PRUint16* aCount);
62 :
63 : nsresult GetRedirectStart(DOMTimeMilliSec* aRedirectStart);
64 : nsresult GetRedirectEnd(DOMTimeMilliSec* aEnd);
65 : nsresult GetNavigationStart(DOMTimeMilliSec* aNavigationStart);
66 : nsresult GetUnloadEventStart(DOMTimeMilliSec* aStart);
67 : nsresult GetUnloadEventEnd(DOMTimeMilliSec* aEnd);
68 : nsresult GetFetchStart(DOMTimeMilliSec* aStart);
69 : nsresult GetDomLoading(DOMTimeMilliSec* aTime);
70 : nsresult GetDomInteractive(DOMTimeMilliSec* aTime);
71 : nsresult GetDomContentLoadedEventStart(DOMTimeMilliSec* aStart);
72 : nsresult GetDomContentLoadedEventEnd(DOMTimeMilliSec* aEnd);
73 : nsresult GetDomComplete(DOMTimeMilliSec* aTime);
74 : nsresult GetLoadEventStart(DOMTimeMilliSec* aStart);
75 : nsresult GetLoadEventEnd(DOMTimeMilliSec* aEnd);
76 :
77 : void NotifyNavigationStart();
78 : void NotifyFetchStart(nsIURI* aURI, nsDOMPerformanceNavigationType aNavigationType);
79 : void NotifyRedirect(nsIURI* aOldURI, nsIURI* aNewURI);
80 : void NotifyBeforeUnload();
81 : void NotifyUnloadAccepted(nsIURI* aOldURI);
82 : void NotifyUnloadEventStart();
83 : void NotifyUnloadEventEnd();
84 : void NotifyLoadEventStart();
85 : void NotifyLoadEventEnd();
86 :
87 : // Document changes state to 'loading' before connecting to timing
88 : void SetDOMLoadingTimeStamp(nsIURI* aURI, mozilla::TimeStamp aValue);
89 : void NotifyDOMLoading(nsIURI* aURI);
90 : void NotifyDOMInteractive(nsIURI* aURI);
91 : void NotifyDOMComplete(nsIURI* aURI);
92 : void NotifyDOMContentLoadedStart(nsIURI* aURI);
93 : void NotifyDOMContentLoadedEnd(nsIURI* aURI);
94 : nsresult TimeStampToDOM(mozilla::TimeStamp aStamp, DOMTimeMilliSec* aResult);
95 : nsresult TimeStampToDOMOrFetchStart(mozilla::TimeStamp aStamp,
96 : DOMTimeMilliSec* aResult);
97 :
98 : private:
99 : nsDOMNavigationTiming(const nsDOMNavigationTiming &){};
100 : ~nsDOMNavigationTiming();
101 :
102 : void Clear();
103 : bool ReportRedirects();
104 :
105 : nsCOMPtr<nsIURI> mUnloadedURI;
106 : nsCOMPtr<nsIURI> mLoadedURI;
107 : nsCOMArray<nsIURI> mRedirects;
108 :
109 : typedef enum { NOT_CHECKED,
110 : CHECK_PASSED,
111 : NO_REDIRECTS,
112 : CHECK_FAILED} RedirectCheckState;
113 : RedirectCheckState mRedirectCheck;
114 : PRInt16 mRedirectCount;
115 :
116 : nsDOMPerformanceNavigationType mNavigationType;
117 : DOMTimeMilliSec mNavigationStart;
118 : mozilla::TimeStamp mNavigationStartTimeStamp;
119 : DOMTimeMilliSec DurationFromStart();
120 :
121 : DOMTimeMilliSec mFetchStart;
122 : DOMTimeMilliSec mRedirectStart;
123 : DOMTimeMilliSec mRedirectEnd;
124 : DOMTimeMilliSec mBeforeUnloadStart;
125 : DOMTimeMilliSec mUnloadStart;
126 : DOMTimeMilliSec mUnloadEnd;
127 : DOMTimeMilliSec mNavigationEnd;
128 : DOMTimeMilliSec mLoadEventStart;
129 : DOMTimeMilliSec mLoadEventEnd;
130 :
131 : DOMTimeMilliSec mDOMLoading;
132 : DOMTimeMilliSec mDOMInteractive;
133 : DOMTimeMilliSec mDOMContentLoadedEventStart;
134 : DOMTimeMilliSec mDOMContentLoadedEventEnd;
135 : DOMTimeMilliSec mDOMComplete;
136 : };
137 :
138 : #endif /* nsDOMNavigationTiming_h___ */
|