Bug 1527719 [wpt PR 15359] - KV storage: make backingStore return the same frozen...
[gecko.git] / storage / mozStorageStatementJSHelper.h
blobe62a86e2e55e7e31761a1f83ea05a6d8c9bda6d9
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/. */
7 #ifndef MOZSTORAGESTATEMENTJSHELPER_H
8 #define MOZSTORAGESTATEMENTJSHELPER_H
10 #include "nsIXPCScriptable.h"
11 #include "nsIXPConnect.h"
13 class Statement;
15 namespace mozilla {
16 namespace storage {
18 class StatementParams;
19 class StatementRow;
21 class StatementJSHelper : public nsIXPCScriptable {
22 public:
23 NS_DECL_ISUPPORTS
24 NS_DECL_NSIXPCSCRIPTABLE
26 private:
27 nsresult getRow(Statement *, JSContext *, JSObject *, JS::Value *);
28 nsresult getParams(Statement *, JSContext *, JSObject *, JS::Value *);
31 /**
32 * Wrappers used to clean up the references JS helpers hold to the statement.
33 * For cycle-avoidance reasons they do not hold reference-counted references,
34 * so it is important we do this.
37 class StatementParamsHolder final : public nsISupports {
38 public:
39 NS_DECL_ISUPPORTS
41 explicit StatementParamsHolder(StatementParams *aParams) : mParams(aParams) {}
43 StatementParams *Get() const {
44 MOZ_ASSERT(mParams);
45 return mParams;
48 private:
49 virtual ~StatementParamsHolder();
51 RefPtr<StatementParams> mParams;
54 class StatementRowHolder final : public nsISupports {
55 public:
56 NS_DECL_ISUPPORTS
58 explicit StatementRowHolder(StatementRow *aRow) : mRow(aRow) {}
60 StatementRow *Get() const {
61 MOZ_ASSERT(mRow);
62 return mRow;
65 private:
66 virtual ~StatementRowHolder();
68 RefPtr<StatementRow> mRow;
71 } // namespace storage
72 } // namespace mozilla
74 #endif // MOZSTORAGESTATEMENTJSHELPER_H