1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_PerformanceMainThread_h
8 #define mozilla_dom_PerformanceMainThread_h
9 
10 #include "Performance.h"
11 
12 namespace mozilla {
13 namespace dom {
14 
15 class PerformanceMainThread final : public Performance
16 {
17 public:
18   PerformanceMainThread(nsPIDOMWindowInner* aWindow,
19                         nsDOMNavigationTiming* aDOMTiming,
20                         nsITimedChannel* aChannel,
21                         Performance* aParentPerformance);
22 
23   NS_DECL_ISUPPORTS_INHERITED
24   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(PerformanceMainThread,
25                                                          Performance)
26 
27   // Performance WebIDL methods
28   DOMHighResTimeStamp Now() const override;
29 
30   virtual PerformanceTiming* Timing() override;
31 
32   virtual PerformanceNavigation* Navigation() override;
33 
34   virtual void AddEntry(nsIHttpChannel* channel,
35                         nsITimedChannel* timedChannel) override;
36 
37   TimeStamp CreationTimeStamp() const override;
38 
39   DOMHighResTimeStamp CreationTime() const override;
40 
41   virtual void GetMozMemory(JSContext *aCx,
42                             JS::MutableHandle<JSObject*> aObj) override;
43 
GetDOMTiming()44   virtual nsDOMNavigationTiming* GetDOMTiming() const override
45   {
46     return mDOMTiming;
47   }
48 
GetChannel()49   virtual nsITimedChannel* GetChannel() const override
50   {
51     return mChannel;
52   }
53 
GetParentPerformance()54   virtual Performance* GetParentPerformance() const override
55   {
56     return mParentPerformance;
57   }
58 
59 protected:
60   ~PerformanceMainThread();
61 
GetAsISupports()62   nsISupports* GetAsISupports() override
63   {
64     return this;
65   }
66 
67   void InsertUserEntry(PerformanceEntry* aEntry) override;
68 
69   bool IsPerformanceTimingAttribute(const nsAString& aName) override;
70 
71   DOMHighResTimeStamp
72   GetPerformanceTimingFromString(const nsAString& aTimingName) override;
73 
74   void DispatchBufferFullEvent() override;
75 
76   RefPtr<nsDOMNavigationTiming> mDOMTiming;
77   nsCOMPtr<nsITimedChannel> mChannel;
78   RefPtr<PerformanceTiming> mTiming;
79   RefPtr<PerformanceNavigation> mNavigation;
80   RefPtr<Performance> mParentPerformance;
81   JS::Heap<JSObject*> mMozMemory;
82 };
83 
84 } // namespace dom
85 } // namespace mozilla
86 
87 #endif // mozilla_dom_PerformanceMainThread_h
88