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 #include "mozStorageBindingParamsArray.h"
8 #include "mozStorageBindingParams.h"
9 #include "StorageBaseStatementInternal.h"
14 ////////////////////////////////////////////////////////////////////////////////
15 //// BindingParamsArray
17 BindingParamsArray::BindingParamsArray(
18 StorageBaseStatementInternal
* aOwningStatement
)
19 : mOwningStatement(aOwningStatement
), mLocked(false) {}
21 void BindingParamsArray::lock() {
22 NS_ASSERTION(mLocked
== false, "Array has already been locked!");
25 // We also no longer need to hold a reference to our statement since it owns
27 mOwningStatement
= nullptr;
30 const StorageBaseStatementInternal
* BindingParamsArray::getOwner() const {
31 return mOwningStatement
;
34 NS_IMPL_ISUPPORTS(BindingParamsArray
, mozIStorageBindingParamsArray
)
36 ///////////////////////////////////////////////////////////////////////////////
37 //// mozIStorageBindingParamsArray
40 BindingParamsArray::NewBindingParams(mozIStorageBindingParams
** _params
) {
41 NS_ENSURE_FALSE(mLocked
, NS_ERROR_UNEXPECTED
);
43 nsCOMPtr
<mozIStorageBindingParams
> params(
44 mOwningStatement
->newBindingParams(this));
45 NS_ENSURE_TRUE(params
, NS_ERROR_UNEXPECTED
);
47 params
.forget(_params
);
52 BindingParamsArray::AddParams(mozIStorageBindingParams
* aParameters
) {
53 NS_ENSURE_FALSE(mLocked
, NS_ERROR_UNEXPECTED
);
55 BindingParams
* params
= static_cast<BindingParams
*>(aParameters
);
57 // Check to make sure that this set of parameters was created with us.
58 if (params
->getOwner() != this) return NS_ERROR_UNEXPECTED
;
60 mArray
.AppendElement(params
);
62 // Lock the parameters only after we've successfully added them.
69 BindingParamsArray::GetLength(uint32_t* _length
) {
74 } // namespace storage
75 } // namespace mozilla