2012-01-24 14:03:37 +04: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/. */
|
|
|
|
|
|
|
|
#include "IDBWrapperCache.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
#include "mozilla/HoldDropJSObjects.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2013-08-17 00:10:17 +04:00
|
|
|
#include "nsCycleCollector.h"
|
2014-09-27 03:21:57 +04:00
|
|
|
#endif
|
2012-01-24 14:03:37 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace indexedDB {
|
2012-01-24 14:03:37 +04:00
|
|
|
|
2013-08-02 05:29:05 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache)
|
|
|
|
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2012-01-24 14:03:37 +04:00
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
2014-04-01 10:13:50 +04:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2012-02-27 20:52:19 +04:00
|
|
|
if (tmp->mScriptOwner) {
|
2012-07-30 18:20:58 +04:00
|
|
|
tmp->mScriptOwner = nullptr;
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::DropJSObjects(tmp);
|
2012-02-27 20:52:19 +04:00
|
|
|
}
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache,
|
2014-04-01 10:13:50 +04:00
|
|
|
DOMEventTargetHelper)
|
2012-01-24 14:03:37 +04:00
|
|
|
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
2014-04-01 10:13:50 +04:00
|
|
|
// DOMEventTargetHelper does it for us.
|
2012-06-11 03:44:50 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScriptOwner)
|
2012-01-24 14:03:37 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBWrapperCache)
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
2012-01-24 14:03:37 +04:00
|
|
|
|
2014-04-01 10:13:50 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, DOMEventTargetHelper)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, DOMEventTargetHelper)
|
2012-02-27 20:52:19 +04:00
|
|
|
|
2014-09-27 03:21:57 +04:00
|
|
|
IDBWrapperCache::IDBWrapperCache(DOMEventTargetHelper* aOwner)
|
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
IDBWrapperCache::IDBWrapperCache(nsPIDOMWindow* aOwner)
|
|
|
|
: DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
|
|
|
|
{ }
|
|
|
|
|
2012-02-27 20:52:19 +04:00
|
|
|
IDBWrapperCache::~IDBWrapperCache()
|
|
|
|
{
|
2012-11-28 05:37:57 +04:00
|
|
|
mScriptOwner = nullptr;
|
2013-08-02 11:04:01 +04:00
|
|
|
ReleaseWrapper(this);
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::DropJSObjects(this);
|
2012-02-27 20:52:19 +04:00
|
|
|
}
|
|
|
|
|
2012-11-30 02:54:14 +04:00
|
|
|
void
|
2012-02-27 20:52:19 +04:00
|
|
|
IDBWrapperCache::SetScriptOwner(JSObject* aScriptOwner)
|
|
|
|
{
|
2014-09-27 03:21:57 +04:00
|
|
|
MOZ_ASSERT(aScriptOwner);
|
2012-02-27 20:52:19 +04:00
|
|
|
|
|
|
|
mScriptOwner = aScriptOwner;
|
2013-08-17 00:10:17 +04:00
|
|
|
mozilla::HoldJSObjects(this);
|
2012-02-27 20:52:19 +04:00
|
|
|
}
|
2012-07-06 21:28:51 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
IDBWrapperCache::AssertIsRooted() const
|
|
|
|
{
|
2013-08-17 00:10:17 +04:00
|
|
|
MOZ_ASSERT(cyclecollector::IsJSHolder(const_cast<IDBWrapperCache*>(this)),
|
|
|
|
"Why aren't we rooted?!");
|
2012-07-06 21:28:51 +04:00
|
|
|
}
|
|
|
|
#endif
|
2014-09-27 03:21:57 +04:00
|
|
|
|
|
|
|
} // namespace indexedDB
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|