2008-09-13 01:30:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2009-04-13 20:29:41 +04:00
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-09-13 01:30:41 +04:00
|
|
|
|
2010-06-01 16:38:00 +04:00
|
|
|
#ifndef MOZSTORAGESTATEMENTJSHELPER_H
|
|
|
|
#define MOZSTORAGESTATEMENTJSHELPER_H
|
2008-09-13 01:30:41 +04:00
|
|
|
|
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
|
2009-05-09 04:29:56 +04:00
|
|
|
class Statement;
|
2008-09-13 01:30:41 +04:00
|
|
|
|
2009-04-08 20:24:25 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace storage {
|
|
|
|
|
2017-08-24 11:52:52 +03:00
|
|
|
class StatementParams;
|
2017-08-22 10:25:37 +03:00
|
|
|
class StatementRow;
|
|
|
|
|
2009-04-08 20:24:25 +04:00
|
|
|
class StatementJSHelper : public nsIXPCScriptable {
|
2008-09-13 01:30:41 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIXPCSCRIPTABLE
|
|
|
|
|
|
|
|
private:
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult getRow(Statement*, JSContext*, JSObject*, JS::Value*);
|
|
|
|
nsresult getParams(Statement*, JSContext*, JSObject*, JS::Value*);
|
2008-09-13 01:30:41 +04:00
|
|
|
};
|
|
|
|
|
2015-03-12 19:55:56 +03:00
|
|
|
/**
|
|
|
|
* Wrappers used to clean up the references JS helpers hold to the statement.
|
|
|
|
* For cycle-avoidance reasons they do not hold reference-counted references,
|
|
|
|
* so it is important we do this.
|
|
|
|
*/
|
2017-08-24 11:52:52 +03:00
|
|
|
|
|
|
|
class StatementParamsHolder final : public nsISupports {
|
2015-03-12 19:55:56 +03:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
explicit StatementParamsHolder(StatementParams* aParams) : mParams(aParams) {}
|
2015-03-12 19:55:56 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
StatementParams* Get() const {
|
2017-08-24 11:52:52 +03:00
|
|
|
MOZ_ASSERT(mParams);
|
|
|
|
return mParams;
|
2015-03-12 19:55:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~StatementParamsHolder();
|
2017-08-24 11:52:52 +03:00
|
|
|
|
|
|
|
RefPtr<StatementParams> mParams;
|
2015-03-12 19:55:56 +03:00
|
|
|
};
|
|
|
|
|
2017-08-22 10:25:37 +03:00
|
|
|
class StatementRowHolder final : public nsISupports {
|
2015-03-12 19:55:56 +03:00
|
|
|
public:
|
2017-08-22 10:25:37 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
explicit StatementRowHolder(StatementRow* aRow) : mRow(aRow) {}
|
2017-08-22 10:25:37 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
StatementRow* Get() const {
|
2017-08-22 10:25:37 +03:00
|
|
|
MOZ_ASSERT(mRow);
|
|
|
|
return mRow;
|
2015-03-12 19:55:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~StatementRowHolder();
|
2017-08-22 10:25:37 +03:00
|
|
|
|
|
|
|
RefPtr<StatementRow> mRow;
|
2015-03-12 19:55:56 +03:00
|
|
|
};
|
|
|
|
|
2009-04-08 20:24:25 +04:00
|
|
|
} // namespace storage
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2010-06-01 16:38:00 +04:00
|
|
|
#endif // MOZSTORAGESTATEMENTJSHELPER_H
|