tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

PlacesWeakCallbackWrapper.h (1526B)


      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_PlacesWeakCallbackWrapper_h
      8 #define mozilla_dom_PlacesWeakCallbackWrapper_h
      9 
     10 #include "mozilla/WeakPtr.h"
     11 #include "mozilla/dom/PlacesObserversBinding.h"
     12 #include "nsIWeakReferenceUtils.h"
     13 #include "nsWrapperCache.h"
     14 
     15 namespace mozilla::dom {
     16 
     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)
     22 
     23  explicit PlacesWeakCallbackWrapper(nsISupports* aParent,
     24                                     PlacesEventCallback& aCallback);
     25 
     26  static already_AddRefed<PlacesWeakCallbackWrapper> Constructor(
     27      const GlobalObject& aGlobal, PlacesEventCallback& aCallback);
     28 
     29  nsISupports* GetParentObject() const;
     30 
     31  JSObject* WrapObject(JSContext* aCx,
     32                       JS::Handle<JSObject*> aGivenProto) override;
     33 
     34 protected:
     35  friend class PlacesObservers;
     36  ~PlacesWeakCallbackWrapper();
     37  nsWeakPtr mParent;
     38  RefPtr<PlacesEventCallback> mCallback;
     39 };
     40 
     41 }  // namespace mozilla::dom
     42 
     43 #endif  // mozilla_dom_PlacesWeakCallbackWrapper_h