Line data Source code
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_PerformanceObserver_h__
8 : #define mozilla_dom_PerformanceObserver_h__
9 :
10 : #include "nsCOMPtr.h"
11 : #include "nsISupports.h"
12 : #include "mozilla/RefPtr.h"
13 : #include "nsString.h"
14 : #include "nsTArray.h"
15 : #include "nsWrapperCache.h"
16 :
17 : class nsPIDOMWindowInner;
18 :
19 : namespace mozilla {
20 :
21 : class ErrorResult;
22 :
23 : namespace dom {
24 :
25 : class GlobalObject;
26 : class Performance;
27 : class PerformanceEntry;
28 : class PerformanceObserverCallback;
29 : struct PerformanceObserverInit;
30 : namespace workers {
31 : class WorkerPrivate;
32 : } // namespace workers
33 :
34 : class PerformanceObserver final : public nsISupports,
35 : public nsWrapperCache
36 : {
37 : public:
38 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceObserver)
40 :
41 : static already_AddRefed<PerformanceObserver>
42 : Constructor(const GlobalObject& aGlobal,
43 : PerformanceObserverCallback& aCb,
44 : ErrorResult& aRv);
45 :
46 : PerformanceObserver(nsPIDOMWindowInner* aOwner,
47 : PerformanceObserverCallback& aCb);
48 :
49 : PerformanceObserver(workers::WorkerPrivate* aWorkerPrivate,
50 : PerformanceObserverCallback& aCb);
51 :
52 : virtual JSObject* WrapObject(JSContext* aCx,
53 : JS::Handle<JSObject*> aGivenProto) override;
54 :
55 0 : nsISupports* GetParentObject() const { return mOwner; }
56 :
57 : void Observe(const PerformanceObserverInit& aOptions,
58 : mozilla::ErrorResult& aRv);
59 :
60 : void Disconnect();
61 :
62 : void Notify();
63 : void QueueEntry(PerformanceEntry* aEntry);
64 :
65 : private:
66 : ~PerformanceObserver();
67 :
68 : nsCOMPtr<nsISupports> mOwner;
69 : RefPtr<PerformanceObserverCallback> mCallback;
70 : RefPtr<Performance> mPerformance;
71 : nsTArray<nsString> mEntryTypes;
72 : bool mConnected;
73 : nsTArray<RefPtr<PerformanceEntry>> mQueuedEntries;
74 : };
75 :
76 : } // namespace dom
77 : } // namespace mozilla
78 :
79 : #endif
|