LCOV - code coverage report
Current view: directory - dom/indexedDB - FileInfo.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 42 0 0.0 %
Date: 2012-06-02 Functions: 4 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* vim: set ts=2 et sw=2 tw=80: */
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is Indexed Database.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is
      19                 :  * The Mozilla Foundation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #include "IndexedDatabaseManager.h"
      40                 : #include "FileInfo.h"
      41                 : 
      42                 : USING_INDEXEDDB_NAMESPACE
      43                 : 
      44                 : // static
      45                 : FileInfo*
      46               0 : FileInfo::Create(FileManager* aFileManager, PRInt64 aId)
      47                 : {
      48               0 :   NS_ASSERTION(aId > 0, "Wrong id!");
      49                 : 
      50               0 :   if (aId <= PR_INT16_MAX) {
      51               0 :     return new FileInfo16(aFileManager, aId);
      52                 :   }
      53                 : 
      54               0 :   if (aId <= PR_INT32_MAX) {
      55               0 :     return new FileInfo32(aFileManager, aId);
      56                 :   }
      57                 : 
      58               0 :   return new FileInfo64(aFileManager, aId);
      59                 : }
      60                 : 
      61                 : void
      62               0 : FileInfo::GetReferences(PRInt32* aRefCnt, PRInt32* aDBRefCnt,
      63                 :                         PRInt32* aSliceRefCnt)
      64                 : {
      65               0 :   if (IndexedDatabaseManager::IsClosed()) {
      66               0 :     NS_ERROR("Shouldn't be called after shutdown!");
      67                 : 
      68               0 :     if (aRefCnt) {
      69               0 :       *aRefCnt = -1;
      70                 :     }
      71                 : 
      72               0 :     if (aDBRefCnt) {
      73               0 :       *aDBRefCnt = -1;
      74                 :     }
      75                 : 
      76               0 :     if (aSliceRefCnt) {
      77               0 :       *aSliceRefCnt = -1;
      78                 :     }
      79                 : 
      80               0 :     return;
      81                 :   }
      82                 : 
      83               0 :   MutexAutoLock lock(IndexedDatabaseManager::FileMutex());
      84                 : 
      85               0 :   if (aRefCnt) {
      86               0 :     *aRefCnt = mRefCnt;
      87                 :   }
      88                 : 
      89               0 :   if (aDBRefCnt) {
      90               0 :     *aDBRefCnt = mDBRefCnt;
      91                 :   }
      92                 : 
      93               0 :   if (aSliceRefCnt) {
      94               0 :     *aSliceRefCnt = mSliceRefCnt;
      95                 :   }
      96                 : }
      97                 : 
      98                 : void
      99               0 : FileInfo::UpdateReferences(nsAutoRefCnt& aRefCount, PRInt32 aDelta,
     100                 :                            bool aClear)
     101                 : {
     102               0 :   if (IndexedDatabaseManager::IsClosed()) {
     103               0 :     NS_ERROR("Shouldn't be called after shutdown!");
     104               0 :     return;
     105                 :   }
     106                 : 
     107                 :   {
     108               0 :     MutexAutoLock lock(IndexedDatabaseManager::FileMutex());
     109                 : 
     110               0 :     aRefCount = aClear ? 0 : aRefCount + aDelta;
     111                 : 
     112               0 :     if (mRefCnt + mDBRefCnt + mSliceRefCnt > 0) {
     113                 :       return;
     114                 :     }
     115                 : 
     116               0 :     mFileManager->mFileInfos.Remove(Id());
     117                 :   }
     118                 : 
     119               0 :   Cleanup();
     120                 : 
     121               0 :   delete this;
     122                 : }
     123                 : 
     124                 : void
     125               0 : FileInfo::Cleanup()
     126                 : {
     127               0 :   if (IndexedDatabaseManager::IsShuttingDown() ||
     128               0 :       mFileManager->Invalidated()) {
     129               0 :     return;
     130                 :   }
     131                 : 
     132               0 :   nsRefPtr<IndexedDatabaseManager> mgr = IndexedDatabaseManager::Get();
     133               0 :   NS_ASSERTION(mgr, "Shouldn't be null!");
     134                 : 
     135               0 :   if (NS_FAILED(mgr->AsyncDeleteFile(mFileManager, Id()))) {
     136               0 :     NS_WARNING("Failed to delete file asynchronously!");
     137                 :   }
     138                 : }

Generated by: LCOV version 1.7