2012-01-24 10:03:37 +00: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-04-01 06:13:50 +00:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2012-01-24 10:03:37 +00:00
|
|
|
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
|
|
|
|
|
|
|
BEGIN_INDEXEDDB_NAMESPACE
|
|
|
|
|
2014-04-01 06:13:50 +00:00
|
|
|
class IDBWrapperCache : public DOMEventTargetHelper
|
2012-01-24 10:03:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
|
|
|
IDBWrapperCache,
|
2014-04-01 06:13:50 +00:00
|
|
|
DOMEventTargetHelper)
|
2012-01-24 10:03:37 +00:00
|
|
|
|
|
|
|
JSObject* GetScriptOwner() const
|
|
|
|
{
|
|
|
|
return mScriptOwner;
|
|
|
|
}
|
2012-11-29 22:54:14 +00:00
|
|
|
void SetScriptOwner(JSObject* aScriptOwner);
|
2012-01-24 10:03:37 +00:00
|
|
|
|
|
|
|
JSObject* GetParentObject()
|
|
|
|
{
|
|
|
|
if (mScriptOwner) {
|
|
|
|
return mScriptOwner;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do what nsEventTargetSH::PreCreate does.
|
|
|
|
nsCOMPtr<nsIScriptGlobalObject> parent;
|
2014-04-01 06:13:50 +00:00
|
|
|
DOMEventTargetHelper::GetParentObject(getter_AddRefs(parent));
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return parent ? parent->GetGlobalJSObject() : nullptr;
|
2012-01-24 10:03:37 +00:00
|
|
|
}
|
|
|
|
|
2012-07-06 17:28:51 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void AssertIsRooted() const;
|
|
|
|
#else
|
|
|
|
inline void AssertIsRooted() const
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-24 10:03:37 +00:00
|
|
|
protected:
|
2014-04-01 06:13:50 +00:00
|
|
|
IDBWrapperCache(DOMEventTargetHelper* aOwner)
|
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
2014-01-07 05:32:20 +00:00
|
|
|
{ }
|
|
|
|
IDBWrapperCache(nsPIDOMWindow* aOwner)
|
2014-04-01 06:13:50 +00:00
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
2012-01-24 10:03:37 +00:00
|
|
|
{ }
|
|
|
|
|
2012-02-27 16:52:19 +00:00
|
|
|
virtual ~IDBWrapperCache();
|
2012-01-24 10:03:37 +00:00
|
|
|
|
2012-02-27 16:52:19 +00:00
|
|
|
private:
|
2013-06-18 10:00:38 +00:00
|
|
|
JS::Heap<JSObject*> mScriptOwner;
|
2012-01-24 10:03:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_INDEXEDDB_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_indexeddb_idbwrappercache_h__
|