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