Bug 1842773 - Part 5: Add ArrayBuffer.prototype.{maxByteLength,resizable} getters...
[gecko.git] / dom / base / PlacesWeakCallbackWrapper.cpp
blob5e60c174b2dbe2a7ca26f32cee51b6a992240c55
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 #include "mozilla/dom/PlacesWeakCallbackWrapper.h"
9 #include "mozilla/dom/ContentProcessMessageManager.h"
11 namespace mozilla::dom {
13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK_PTR(PlacesWeakCallbackWrapper,
14 mParent, mCallback)
16 PlacesWeakCallbackWrapper::PlacesWeakCallbackWrapper(
17 nsISupports* aParent, PlacesEventCallback& aCallback)
18 : mParent(do_GetWeakReference(aParent)), mCallback(&aCallback) {}
20 already_AddRefed<PlacesWeakCallbackWrapper>
21 PlacesWeakCallbackWrapper::Constructor(const GlobalObject& aGlobal,
22 PlacesEventCallback& aCallback) {
23 nsCOMPtr<nsISupports> parent = aGlobal.GetAsSupports();
24 RefPtr<PlacesWeakCallbackWrapper> wrapper =
25 new PlacesWeakCallbackWrapper(parent, aCallback);
26 return wrapper.forget();
29 PlacesWeakCallbackWrapper::~PlacesWeakCallbackWrapper() = default;
31 nsISupports* PlacesWeakCallbackWrapper::GetParentObject() const {
32 nsCOMPtr<nsISupports> parent = do_QueryReferent(mParent);
33 return parent;
36 JSObject* PlacesWeakCallbackWrapper::WrapObject(
37 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
38 return PlacesWeakCallbackWrapper_Binding::Wrap(aCx, this, aGivenProto);
41 } // namespace mozilla::dom