2012-01-24 02:03:37 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_indexeddb_idbwrappercache_h__
|
|
|
|
#define mozilla_dom_indexeddb_idbwrappercache_h__
|
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2012-01-24 02:03:37 -08:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
class IDBWrapperCache : public DOMEventTargetHelper
|
2012-01-24 02:03:37 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
|
|
|
IDBWrapperCache,
|
2014-03-31 23:13:50 -07:00
|
|
|
DOMEventTargetHelper)
|
2012-01-24 02:03:37 -08:00
|
|
|
|
|
|
|
JSObject* GetScriptOwner() const
|
|
|
|
{
|
|
|
|
return mScriptOwner;
|
|
|
|
}
|
2012-11-29 14:54:14 -08:00
|
|
|
void SetScriptOwner(JSObject* aScriptOwner);
|
2012-01-24 02:03:37 -08:00
|
|
|
|
|
|
|
JSObject* GetParentObject()
|
|
|
|
{
|
|
|
|
if (mScriptOwner) {
|
|
|
|
return mScriptOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do what nsEventTargetSH::PreCreate does.
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> parent;
|
2014-03-31 23:13:50 -07:00
|
|
|
DOMEventTargetHelper::GetParentObject(getter_AddRefs(parent));
|
2012-01-24 02:03:37 -08:00
|
|
|
|
2012-07-30 07:20:58 -07:00
|
|
|
return parent ? parent->GetGlobalJSObject() : nullptr;
|
2012-01-24 02:03:37 -08:00
|
|
|
}
|
|
|
|
|
2012-07-06 10:28:51 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
void AssertIsRooted() const;
|
|
|
|
#else
|
|
|
|
inline void AssertIsRooted() const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-24 02:03:37 -08:00
|
|
|
protected:
|
2014-03-31 23:13:50 -07:00
|
|
|
IDBWrapperCache(DOMEventTargetHelper* aOwner)
|
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
2014-01-06 21:32:20 -08:00
|
|
|
{ }
|
|
|
|
IDBWrapperCache(nsPIDOMWindow* aOwner)
|
2014-03-31 23:13:50 -07:00
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
2012-01-24 02:03:37 -08:00
|
|
|
{ }
|
|
|
|
|
2012-02-27 08:52:19 -08:00
|
|
|
virtual ~IDBWrapperCache();
|
2012-01-24 02:03:37 -08:00
|
|
|
|
2012-02-27 08:52:19 -08:00
|
|
|
private:
|
2013-06-18 03:00:38 -07:00
|
|
|
JS::Heap<JSObject*> mScriptOwner;
|
2012-01-24 02:03:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_idbwrappercache_h__
|