Bug 1660051 [wpt PR 25111] - Origin isolation: expand getter test coverage, a=testonly
[gecko.git] / dom / base / PlacesWeakCallbackWrapper.cpp
blob740d5cd40bbb48842a3a24a49838e03f7a6802ed
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/HoldDropJSObjects.h"
10 #include "mozilla/dom/ContentProcessMessageManager.h"
12 namespace mozilla {
13 namespace dom {
15 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK_PTR(PlacesWeakCallbackWrapper,
16 mParent, mCallback)
17 NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(PlacesWeakCallbackWrapper, AddRef)
18 NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(PlacesWeakCallbackWrapper, Release)
20 PlacesWeakCallbackWrapper::PlacesWeakCallbackWrapper(
21 nsISupports* aParent, PlacesEventCallback& aCallback)
22 : mParent(do_GetWeakReference(aParent)), mCallback(&aCallback) {}
24 already_AddRefed<PlacesWeakCallbackWrapper>
25 PlacesWeakCallbackWrapper::Constructor(const GlobalObject& aGlobal,
26 PlacesEventCallback& aCallback) {
27 nsCOMPtr<nsISupports> parent = aGlobal.GetAsSupports();
28 RefPtr<PlacesWeakCallbackWrapper> wrapper =
29 new PlacesWeakCallbackWrapper(parent, aCallback);
30 return wrapper.forget();
33 PlacesWeakCallbackWrapper::~PlacesWeakCallbackWrapper() = default;
35 nsISupports* PlacesWeakCallbackWrapper::GetParentObject() const {
36 nsCOMPtr<nsISupports> parent = do_QueryReferent(mParent);
37 return parent;
40 JSObject* PlacesWeakCallbackWrapper::WrapObject(
41 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
42 return PlacesWeakCallbackWrapper_Binding::Wrap(aCx, this, aGivenProto);
45 } // namespace dom
46 } // namespace mozilla