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: #ifndef mozilla_dom_indexeddb_idbwrappercache_h__ michael@0: #define mozilla_dom_indexeddb_idbwrappercache_h__ michael@0: michael@0: #include "mozilla/DOMEventTargetHelper.h" michael@0: #include "mozilla/dom/indexedDB/IndexedDatabase.h" michael@0: michael@0: BEGIN_INDEXEDDB_NAMESPACE michael@0: michael@0: class IDBWrapperCache : public DOMEventTargetHelper michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( michael@0: IDBWrapperCache, michael@0: DOMEventTargetHelper) michael@0: michael@0: JSObject* GetScriptOwner() const michael@0: { michael@0: return mScriptOwner; michael@0: } michael@0: void SetScriptOwner(JSObject* aScriptOwner); michael@0: michael@0: JSObject* GetParentObject() michael@0: { michael@0: if (mScriptOwner) { michael@0: return mScriptOwner; michael@0: } michael@0: michael@0: // Do what nsEventTargetSH::PreCreate does. michael@0: nsCOMPtr parent; michael@0: DOMEventTargetHelper::GetParentObject(getter_AddRefs(parent)); michael@0: michael@0: return parent ? parent->GetGlobalJSObject() : nullptr; michael@0: } michael@0: michael@0: #ifdef DEBUG michael@0: void AssertIsRooted() const; michael@0: #else michael@0: inline void AssertIsRooted() const michael@0: { michael@0: } michael@0: #endif michael@0: michael@0: protected: michael@0: IDBWrapperCache(DOMEventTargetHelper* aOwner) michael@0: : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) michael@0: { } michael@0: IDBWrapperCache(nsPIDOMWindow* aOwner) michael@0: : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) michael@0: { } michael@0: michael@0: virtual ~IDBWrapperCache(); michael@0: michael@0: private: michael@0: JS::Heap mScriptOwner; michael@0: }; michael@0: michael@0: END_INDEXEDDB_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_indexeddb_idbwrappercache_h__