dom/indexedDB/IDBWrapperCache.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_indexeddb_idbwrappercache_h__
michael@0 8 #define mozilla_dom_indexeddb_idbwrappercache_h__
michael@0 9
michael@0 10 #include "mozilla/DOMEventTargetHelper.h"
michael@0 11 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
michael@0 12
michael@0 13 BEGIN_INDEXEDDB_NAMESPACE
michael@0 14
michael@0 15 class IDBWrapperCache : public DOMEventTargetHelper
michael@0 16 {
michael@0 17 public:
michael@0 18 NS_DECL_ISUPPORTS_INHERITED
michael@0 19 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
michael@0 20 IDBWrapperCache,
michael@0 21 DOMEventTargetHelper)
michael@0 22
michael@0 23 JSObject* GetScriptOwner() const
michael@0 24 {
michael@0 25 return mScriptOwner;
michael@0 26 }
michael@0 27 void SetScriptOwner(JSObject* aScriptOwner);
michael@0 28
michael@0 29 JSObject* GetParentObject()
michael@0 30 {
michael@0 31 if (mScriptOwner) {
michael@0 32 return mScriptOwner;
michael@0 33 }
michael@0 34
michael@0 35 // Do what nsEventTargetSH::PreCreate does.
michael@0 36 nsCOMPtr<nsIScriptGlobalObject> parent;
michael@0 37 DOMEventTargetHelper::GetParentObject(getter_AddRefs(parent));
michael@0 38
michael@0 39 return parent ? parent->GetGlobalJSObject() : nullptr;
michael@0 40 }
michael@0 41
michael@0 42 #ifdef DEBUG
michael@0 43 void AssertIsRooted() const;
michael@0 44 #else
michael@0 45 inline void AssertIsRooted() const
michael@0 46 {
michael@0 47 }
michael@0 48 #endif
michael@0 49
michael@0 50 protected:
michael@0 51 IDBWrapperCache(DOMEventTargetHelper* aOwner)
michael@0 52 : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
michael@0 53 { }
michael@0 54 IDBWrapperCache(nsPIDOMWindow* aOwner)
michael@0 55 : DOMEventTargetHelper(aOwner), mScriptOwner(nullptr)
michael@0 56 { }
michael@0 57
michael@0 58 virtual ~IDBWrapperCache();
michael@0 59
michael@0 60 private:
michael@0 61 JS::Heap<JSObject*> mScriptOwner;
michael@0 62 };
michael@0 63
michael@0 64 END_INDEXEDDB_NAMESPACE
michael@0 65
michael@0 66 #endif // mozilla_dom_indexeddb_idbwrappercache_h__

mercurial