Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / base / PlacesWeakCallbackWrapper.h
blob0b20276fc451644c70fc213d8828af02f09a9fc0
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/. */
7 #ifndef mozilla_dom_PlacesWeakCallbackWrapper_h
8 #define mozilla_dom_PlacesWeakCallbackWrapper_h
10 #include "mozilla/WeakPtr.h"
11 #include "mozilla/dom/PlacesObserversBinding.h"
12 #include "nsIWeakReferenceUtils.h"
13 #include "nsWrapperCache.h"
15 namespace mozilla::dom {
17 class PlacesWeakCallbackWrapper final : public nsWrapperCache,
18 public SupportsWeakPtr {
19 public:
20 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(PlacesWeakCallbackWrapper)
21 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(PlacesWeakCallbackWrapper)
23 explicit PlacesWeakCallbackWrapper(nsISupports* aParent,
24 PlacesEventCallback& aCallback);
26 static already_AddRefed<PlacesWeakCallbackWrapper> Constructor(
27 const GlobalObject& aGlobal, PlacesEventCallback& aCallback);
29 nsISupports* GetParentObject() const;
31 JSObject* WrapObject(JSContext* aCx,
32 JS::Handle<JSObject*> aGivenProto) override;
34 protected:
35 friend class PlacesObservers;
36 ~PlacesWeakCallbackWrapper();
37 nsWeakPtr mParent;
38 RefPtr<PlacesEventCallback> mCallback;
41 } // namespace mozilla::dom
43 #endif // mozilla_dom_PlacesWeakCallbackWrapper_h