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__
|
|
|
|
|
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
|
|
|
|
2012-02-07 18:53:33 -08:00
|
|
|
#include "nsDOMEventTargetHelper.h"
|
2012-01-24 02:03:37 -08:00
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2012-02-07 18:53:33 -08:00
|
|
|
class IDBWrapperCache : public nsDOMEventTargetHelper
|
2012-01-24 02:03:37 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
|
|
|
IDBWrapperCache,
|
2012-02-07 18:53:33 -08:00
|
|
|
nsDOMEventTargetHelper)
|
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;
|
2012-02-07 18:53:33 -08:00
|
|
|
nsDOMEventTargetHelper::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
|
|
|
}
|
|
|
|
|
|
|
|
static IDBWrapperCache* FromSupports(nsISupports* aSupports)
|
|
|
|
{
|
|
|
|
return static_cast<IDBWrapperCache*>(
|
2012-02-07 18:53:33 -08:00
|
|
|
nsDOMEventTargetHelper::FromSupports(aSupports));
|
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:
|
|
|
|
IDBWrapperCache()
|
2012-07-30 07:20:58 -07:00
|
|
|
: 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:
|
2012-01-24 02:03:37 -08:00
|
|
|
JSObject* mScriptOwner;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_idbwrappercache_h__
|