LCOV - code coverage report
Current view: top level - storage - mozStorageBindingParamsArray.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 17 29 58.6 %
Date: 2017-07-14 16:53:18 Functions: 6 9 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "mozStorageBindingParamsArray.h"
       8             : #include "mozStorageBindingParams.h"
       9             : #include "StorageBaseStatementInternal.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace storage {
      13             : 
      14             : ////////////////////////////////////////////////////////////////////////////////
      15             : //// BindingParamsArray
      16             : 
      17          19 : BindingParamsArray::BindingParamsArray(
      18             :   StorageBaseStatementInternal *aOwningStatement
      19          19 : )
      20             : : mOwningStatement(aOwningStatement)
      21          19 : , mLocked(false)
      22             : {
      23          19 : }
      24             : 
      25             : void
      26          19 : BindingParamsArray::lock()
      27             : {
      28          19 :   NS_ASSERTION(mLocked == false, "Array has already been locked!");
      29          19 :   mLocked = true;
      30             : 
      31             :   // We also no longer need to hold a reference to our statement since it owns
      32             :   // us.
      33          19 :   mOwningStatement = nullptr;
      34          19 : }
      35             : 
      36             : const StorageBaseStatementInternal *
      37           0 : BindingParamsArray::getOwner() const
      38             : {
      39           0 :   return mOwningStatement;
      40             : }
      41             : 
      42         328 : NS_IMPL_ISUPPORTS(
      43             :   BindingParamsArray,
      44             :   mozIStorageBindingParamsArray
      45             : )
      46             : 
      47             : ///////////////////////////////////////////////////////////////////////////////
      48             : //// mozIStorageBindingParamsArray
      49             : 
      50             : NS_IMETHODIMP
      51           0 : BindingParamsArray::NewBindingParams(mozIStorageBindingParams **_params)
      52             : {
      53           0 :   NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED);
      54             : 
      55             :   nsCOMPtr<mozIStorageBindingParams> params(
      56           0 :     mOwningStatement->newBindingParams(this));
      57           0 :   NS_ENSURE_TRUE(params, NS_ERROR_UNEXPECTED);
      58             : 
      59           0 :   params.forget(_params);
      60           0 :   return NS_OK;
      61             : }
      62             : 
      63             : NS_IMETHODIMP
      64          19 : BindingParamsArray::AddParams(mozIStorageBindingParams *aParameters)
      65             : {
      66          19 :   NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED);
      67             : 
      68          19 :   BindingParams *params = static_cast<BindingParams *>(aParameters);
      69             : 
      70             :   // Check to make sure that this set of parameters was created with us.
      71          19 :   if (params->getOwner() != this)
      72           0 :     return NS_ERROR_UNEXPECTED;
      73             : 
      74          19 :   NS_ENSURE_TRUE(mArray.AppendElement(params), NS_ERROR_OUT_OF_MEMORY);
      75             : 
      76             :   // Lock the parameters only after we've successfully added them.
      77          19 :   params->lock();
      78             : 
      79          19 :   return NS_OK;
      80             : }
      81             : 
      82             : NS_IMETHODIMP
      83           0 : BindingParamsArray::GetLength(uint32_t *_length)
      84             : {
      85           0 :   *_length = length();
      86           0 :   return NS_OK;
      87             : }
      88             : 
      89             : } // namespace storage
      90             : } // namespace mozilla

Generated by: LCOV version 1.13