Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
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
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef MOZSTORAGESTATEMENTJSHELPER_H
8 : #define MOZSTORAGESTATEMENTJSHELPER_H
9 :
10 : #include "nsIXPCScriptable.h"
11 : #include "nsIXPConnect.h"
12 :
13 : class Statement;
14 :
15 : namespace mozilla {
16 : namespace storage {
17 :
18 0 : class StatementJSHelper : public nsIXPCScriptable
19 : {
20 : public:
21 : NS_DECL_ISUPPORTS
22 : NS_DECL_NSIXPCSCRIPTABLE
23 :
24 : private:
25 : nsresult getRow(Statement *, JSContext *, JSObject *, JS::Value *);
26 : nsresult getParams(Statement *, JSContext *, JSObject *, JS::Value *);
27 : };
28 :
29 : /**
30 : * Wrappers used to clean up the references JS helpers hold to the statement.
31 : * For cycle-avoidance reasons they do not hold reference-counted references,
32 : * so it is important we do this.
33 : */
34 : class StatementJSObjectHolder : public nsIXPConnectJSObjectHolder
35 : {
36 : public:
37 : NS_DECL_ISUPPORTS
38 : NS_DECL_NSIXPCONNECTJSOBJECTHOLDER
39 :
40 : explicit StatementJSObjectHolder(nsIXPConnectJSObjectHolder* aHolder);
41 :
42 : protected:
43 0 : virtual ~StatementJSObjectHolder() {};
44 : nsCOMPtr<nsIXPConnectJSObjectHolder> mHolder;
45 : };
46 :
47 : class StatementParamsHolder final: public StatementJSObjectHolder {
48 : public:
49 0 : explicit StatementParamsHolder(nsIXPConnectJSObjectHolder* aHolder)
50 0 : : StatementJSObjectHolder(aHolder) {
51 0 : }
52 :
53 : private:
54 : virtual ~StatementParamsHolder();
55 : };
56 :
57 : class StatementRowHolder final: public StatementJSObjectHolder {
58 : public:
59 0 : explicit StatementRowHolder(nsIXPConnectJSObjectHolder* aHolder)
60 0 : : StatementJSObjectHolder(aHolder) {
61 0 : }
62 :
63 : private:
64 : virtual ~StatementRowHolder();
65 : };
66 :
67 : } // namespace storage
68 : } // namespace mozilla
69 :
70 : #endif // MOZSTORAGESTATEMENTJSHELPER_H
|