/src/mozilla-central/storage/mozStorageStatementJSHelper.h
Line | Count | Source (jump to first uncovered line) |
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 | | class StatementParams; |
19 | | class StatementRow; |
20 | | |
21 | | class StatementJSHelper : public nsIXPCScriptable |
22 | | { |
23 | | public: |
24 | | NS_DECL_ISUPPORTS |
25 | | NS_DECL_NSIXPCSCRIPTABLE |
26 | | |
27 | | private: |
28 | | nsresult getRow(Statement *, JSContext *, JSObject *, JS::Value *); |
29 | | nsresult getParams(Statement *, JSContext *, JSObject *, JS::Value *); |
30 | | }; |
31 | | |
32 | | /** |
33 | | * Wrappers used to clean up the references JS helpers hold to the statement. |
34 | | * For cycle-avoidance reasons they do not hold reference-counted references, |
35 | | * so it is important we do this. |
36 | | */ |
37 | | |
38 | | class StatementParamsHolder final: public nsISupports { |
39 | | public: |
40 | | NS_DECL_ISUPPORTS |
41 | | |
42 | | explicit StatementParamsHolder(StatementParams* aParams) |
43 | | : mParams(aParams) |
44 | 0 | { |
45 | 0 | } |
46 | | |
47 | 0 | StatementParams* Get() const { |
48 | 0 | MOZ_ASSERT(mParams); |
49 | 0 | return mParams; |
50 | 0 | } |
51 | | |
52 | | private: |
53 | | virtual ~StatementParamsHolder(); |
54 | | |
55 | | RefPtr<StatementParams> mParams; |
56 | | }; |
57 | | |
58 | | class StatementRowHolder final: public nsISupports { |
59 | | public: |
60 | | NS_DECL_ISUPPORTS |
61 | | |
62 | | explicit StatementRowHolder(StatementRow* aRow) |
63 | | : mRow(aRow) |
64 | 0 | { |
65 | 0 | } |
66 | | |
67 | 0 | StatementRow* Get() const { |
68 | 0 | MOZ_ASSERT(mRow); |
69 | 0 | return mRow; |
70 | 0 | } |
71 | | |
72 | | private: |
73 | | virtual ~StatementRowHolder(); |
74 | | |
75 | | RefPtr<StatementRow> mRow; |
76 | | }; |
77 | | |
78 | | } // namespace storage |
79 | | } // namespace mozilla |
80 | | |
81 | | #endif // MOZSTORAGESTATEMENTJSHELPER_H |