2009-06-17 12:12:51 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
|
2012-05-21 04:12:37 -07: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/. */
|
2009-06-17 12:12:51 -07:00
|
|
|
|
|
|
|
#include "mozStorageBindingParamsArray.h"
|
|
|
|
#include "mozStorageBindingParams.h"
|
2010-03-24 00:32:40 -07:00
|
|
|
#include "StorageBaseStatementInternal.h"
|
2009-06-17 12:12:51 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace storage {
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// BindingParamsArray
|
|
|
|
|
2010-03-24 00:32:40 -07:00
|
|
|
BindingParamsArray::BindingParamsArray(
|
|
|
|
StorageBaseStatementInternal *aOwningStatement
|
|
|
|
)
|
2009-06-17 12:12:51 -07:00
|
|
|
: mOwningStatement(aOwningStatement)
|
|
|
|
, mLocked(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BindingParamsArray::lock()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mLocked == false, "Array has already been locked!");
|
|
|
|
mLocked = true;
|
|
|
|
|
|
|
|
// We also no longer need to hold a reference to our statement since it owns
|
|
|
|
// us.
|
2012-07-30 07:20:58 -07:00
|
|
|
mOwningStatement = nullptr;
|
2009-06-17 12:12:51 -07:00
|
|
|
}
|
|
|
|
|
2010-03-24 00:32:40 -07:00
|
|
|
const StorageBaseStatementInternal *
|
2009-06-17 12:12:51 -07:00
|
|
|
BindingParamsArray::getOwner() const
|
|
|
|
{
|
|
|
|
return mOwningStatement;
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(
|
2009-06-17 12:12:51 -07:00
|
|
|
BindingParamsArray,
|
|
|
|
mozIStorageBindingParamsArray
|
|
|
|
)
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// mozIStorageBindingParamsArray
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
BindingParamsArray::NewBindingParams(mozIStorageBindingParams **_params)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED);
|
|
|
|
|
2010-03-24 00:32:40 -07:00
|
|
|
nsCOMPtr<mozIStorageBindingParams> params(
|
|
|
|
mOwningStatement->newBindingParams(this));
|
|
|
|
NS_ENSURE_TRUE(params, NS_ERROR_UNEXPECTED);
|
2009-06-17 12:12:51 -07:00
|
|
|
|
|
|
|
params.forget(_params);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
BindingParamsArray::AddParams(mozIStorageBindingParams *aParameters)
|
|
|
|
{
|
|
|
|
NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
BindingParams *params = static_cast<BindingParams *>(aParameters);
|
|
|
|
|
|
|
|
// Check to make sure that this set of parameters was created with us.
|
|
|
|
if (params->getOwner() != this)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(mArray.AppendElement(params), NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
// Lock the parameters only after we've successfully added them.
|
|
|
|
params->lock();
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-15 10:23:39 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
BindingParamsArray::GetLength(uint32_t *_length)
|
2010-03-15 10:23:39 -07:00
|
|
|
{
|
|
|
|
*_length = length();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-06-17 12:12:51 -07:00
|
|
|
} // namespace storage
|
|
|
|
} // namespace mozilla
|