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/. */
7 #ifndef mozilla_dom_DebuggerNotificationObserver_h
8 #define mozilla_dom_DebuggerNotificationObserver_h
10 #include "DebuggerNotificationManager.h"
11 #include "mozilla/dom/DebuggerNotificationObserverBinding.h"
12 #include "mozilla/RefPtr.h"
13 #include "nsTObserverArray.h"
14 #include "nsWrapperCache.h"
16 class nsIGlobalObject
;
18 namespace mozilla::dom
{
20 class DebuggerNotification
;
22 class DebuggerNotificationObserver final
: public nsISupports
,
23 public nsWrapperCache
{
25 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
26 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(DebuggerNotificationObserver
)
28 static already_AddRefed
<DebuggerNotificationObserver
> Constructor(
29 GlobalObject
& aGlobal
, ErrorResult
& aRv
);
31 nsIGlobalObject
* GetParentObject() const { return mOwnerGlobal
; }
34 virtual JSObject
* WrapObject(JSContext
* aCx
,
35 JS::Handle
<JSObject
*> aGivenProto
) override
;
37 bool Connect(JSContext
* aCx
, JS::Handle
<JSObject
*> aDebuggeeGlobal
,
39 bool Disconnect(JSContext
* aCx
, JS::Handle
<JSObject
*> aDebuggeeGlobal
,
42 bool AddListener(DebuggerNotificationCallback
& aHandlerFn
);
43 bool RemoveListener(DebuggerNotificationCallback
& aHandlerFn
);
47 MOZ_CAN_RUN_SCRIPT
void NotifyListeners(DebuggerNotification
* aNotification
);
50 explicit DebuggerNotificationObserver(nsIGlobalObject
* aOwnerGlobal
);
51 ~DebuggerNotificationObserver() = default;
53 nsTObserverArray
<RefPtr
<DebuggerNotificationCallback
>>
54 mEventListenerCallbacks
;
55 nsCOMPtr
<nsIGlobalObject
> mOwnerGlobal
;
58 } // namespace mozilla::dom
60 #endif // mozilla_dom_DebuggerNotificationObserver_h