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 file,
5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_PerformanceObserverEntryList_h__
8 #define mozilla_dom_PerformanceObserverEntryList_h__
9 
10 #include "nsCOMPtr.h"
11 #include "nsISupports.h"
12 #include "nsTArray.h"
13 #include "nsWrapperCache.h"
14 #include "mozilla/dom/DOMPrefs.h"
15 #include "mozilla/dom/PerformanceEntryBinding.h"
16 
17 namespace mozilla {
18 namespace dom {
19 
20 struct PerformanceEntryFilterOptions;
21 class PerformanceEntry;
22 template <typename T>
23 class Optional;
24 
25 class PerformanceObserverEntryList final : public nsISupports,
26                                            public nsWrapperCache {
27   ~PerformanceObserverEntryList();
28 
29  public:
PerformanceObserverEntryList(nsISupports * aOwner,nsTArray<RefPtr<PerformanceEntry>> & aEntries)30   PerformanceObserverEntryList(nsISupports* aOwner,
31                                nsTArray<RefPtr<PerformanceEntry>>& aEntries)
32       : mOwner(aOwner), mEntries(aEntries) {}
33 
GetParentObject()34   nsISupports* GetParentObject() const { return mOwner; }
35 
36   virtual JSObject* WrapObject(JSContext* aCx,
37                                JS::Handle<JSObject*> aGivenProto) override;
38 
39   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
40   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceObserverEntryList)
41 
42   void GetEntries(const PerformanceEntryFilterOptions& aFilter,
43                   nsTArray<RefPtr<PerformanceEntry>>& aRetval);
44   void GetEntriesByType(const nsAString& aEntryType,
45                         nsTArray<RefPtr<PerformanceEntry>>& aRetval);
46   void GetEntriesByName(const nsAString& aName,
47                         const Optional<nsAString>& aEntryType,
48                         nsTArray<RefPtr<PerformanceEntry>>& aRetval);
49 
50  private:
51   nsCOMPtr<nsISupports> mOwner;
52   nsTArray<RefPtr<PerformanceEntry>> mEntries;
53 };
54 
55 }  // namespace dom
56 }  // namespace mozilla
57 
58 #endif
59