michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "IDBWrapperCache.h" michael@0: #include "nsCycleCollector.h" michael@0: michael@0: USING_INDEXEDDB_NAMESPACE michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache, michael@0: DOMEventTargetHelper) michael@0: // Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because michael@0: // DOMEventTargetHelper does it for us. michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache, michael@0: DOMEventTargetHelper) michael@0: if (tmp->mScriptOwner) { michael@0: tmp->mScriptOwner = nullptr; michael@0: mozilla::DropJSObjects(tmp); michael@0: } michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache, michael@0: DOMEventTargetHelper) michael@0: // Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because michael@0: // DOMEventTargetHelper does it for us. michael@0: NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScriptOwner) michael@0: NS_IMPL_CYCLE_COLLECTION_TRACE_END michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBWrapperCache) michael@0: NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, DOMEventTargetHelper) michael@0: NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, DOMEventTargetHelper) michael@0: michael@0: IDBWrapperCache::~IDBWrapperCache() michael@0: { michael@0: mScriptOwner = nullptr; michael@0: ReleaseWrapper(this); michael@0: mozilla::DropJSObjects(this); michael@0: } michael@0: michael@0: void michael@0: IDBWrapperCache::SetScriptOwner(JSObject* aScriptOwner) michael@0: { michael@0: NS_ASSERTION(aScriptOwner, "This should never be null!"); michael@0: michael@0: mScriptOwner = aScriptOwner; michael@0: mozilla::HoldJSObjects(this); michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: void michael@0: IDBWrapperCache::AssertIsRooted() const michael@0: { michael@0: MOZ_ASSERT(cyclecollector::IsJSHolder(const_cast(this)), michael@0: "Why aren't we rooted?!"); michael@0: } michael@0: #endif