PlacesWeakCallbackWrapper.cpp (1586B)
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 #include "mozilla/dom/PlacesWeakCallbackWrapper.h" 8 9 #include "mozilla/dom/ContentProcessMessageManager.h" 10 11 namespace mozilla::dom { 12 13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK_PTR(PlacesWeakCallbackWrapper, 14 mParent, mCallback) 15 16 PlacesWeakCallbackWrapper::PlacesWeakCallbackWrapper( 17 nsISupports* aParent, PlacesEventCallback& aCallback) 18 : mParent(do_GetWeakReference(aParent)), mCallback(&aCallback) {} 19 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(); 27 } 28 29 PlacesWeakCallbackWrapper::~PlacesWeakCallbackWrapper() = default; 30 31 nsISupports* PlacesWeakCallbackWrapper::GetParentObject() const { 32 nsCOMPtr<nsISupports> parent = do_QueryReferent(mParent); 33 return parent; 34 } 35 36 JSObject* PlacesWeakCallbackWrapper::WrapObject( 37 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { 38 return PlacesWeakCallbackWrapper_Binding::Wrap(aCx, this, aGivenProto); 39 } 40 41 } // namespace mozilla::dom