1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/IDBWrapperCache.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_indexeddb_idbwrappercache_h__ 1.11 +#define mozilla_dom_indexeddb_idbwrappercache_h__ 1.12 + 1.13 +#include "mozilla/DOMEventTargetHelper.h" 1.14 +#include "mozilla/dom/indexedDB/IndexedDatabase.h" 1.15 + 1.16 +BEGIN_INDEXEDDB_NAMESPACE 1.17 + 1.18 +class IDBWrapperCache : public DOMEventTargetHelper 1.19 +{ 1.20 +public: 1.21 + NS_DECL_ISUPPORTS_INHERITED 1.22 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED( 1.23 + IDBWrapperCache, 1.24 + DOMEventTargetHelper) 1.25 + 1.26 + JSObject* GetScriptOwner() const 1.27 + { 1.28 + return mScriptOwner; 1.29 + } 1.30 + void SetScriptOwner(JSObject* aScriptOwner); 1.31 + 1.32 + JSObject* GetParentObject() 1.33 + { 1.34 + if (mScriptOwner) { 1.35 + return mScriptOwner; 1.36 + } 1.37 + 1.38 + // Do what nsEventTargetSH::PreCreate does. 1.39 + nsCOMPtr<nsIScriptGlobalObject> parent; 1.40 + DOMEventTargetHelper::GetParentObject(getter_AddRefs(parent)); 1.41 + 1.42 + return parent ? parent->GetGlobalJSObject() : nullptr; 1.43 + } 1.44 + 1.45 +#ifdef DEBUG 1.46 + void AssertIsRooted() const; 1.47 +#else 1.48 + inline void AssertIsRooted() const 1.49 + { 1.50 + } 1.51 +#endif 1.52 + 1.53 +protected: 1.54 + IDBWrapperCache(DOMEventTargetHelper* aOwner) 1.55 + : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) 1.56 + { } 1.57 + IDBWrapperCache(nsPIDOMWindow* aOwner) 1.58 + : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr) 1.59 + { } 1.60 + 1.61 + virtual ~IDBWrapperCache(); 1.62 + 1.63 +private: 1.64 + JS::Heap<JSObject*> mScriptOwner; 1.65 +}; 1.66 + 1.67 +END_INDEXEDDB_NAMESPACE 1.68 + 1.69 +#endif // mozilla_dom_indexeddb_idbwrappercache_h__