LCOV - code coverage report
Current view: directory - objdir/dist/include/mozilla/dom/indexedDB - FileManager.h (source / functions) Found Hit Coverage
Test: app.info Lines: 16 12 75.0 %
Date: 2012-06-02 Functions: 9 7 77.8 %

       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                 : #ifndef mozilla_dom_indexeddb_filemanager_h__
      40                 : #define mozilla_dom_indexeddb_filemanager_h__
      41                 : 
      42                 : #include "IndexedDatabase.h"
      43                 : #include "nsIFile.h"
      44                 : #include "nsILocalFile.h"
      45                 : #include "nsIDOMFile.h"
      46                 : #include "nsDataHashtable.h"
      47                 : 
      48                 : class mozIStorageConnection;
      49                 : 
      50                 : BEGIN_INDEXEDDB_NAMESPACE
      51                 : 
      52                 : class FileInfo;
      53                 : 
      54                 : class FileManager
      55                 : {
      56                 :   friend class FileInfo;
      57                 : 
      58                 : public:
      59              52 :   FileManager(const nsACString& aOrigin,
      60                 :               const nsAString& aDatabaseName)
      61                 :   : mOrigin(aOrigin), mDatabaseName(aDatabaseName), mLastFileId(0),
      62              52 :     mLoaded(false), mInvalidated(false)
      63              52 :   { }
      64                 : 
      65              52 :   ~FileManager()
      66              52 :   { }
      67                 : 
      68            4240 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FileManager)
      69                 : 
      70               0 :   const nsACString& Origin() const
      71                 :   {
      72               0 :     return mOrigin;
      73                 :   }
      74                 : 
      75              26 :   const nsAString& DatabaseName() const
      76                 :   {
      77              26 :     return mDatabaseName;
      78                 :   }
      79                 : 
      80              75 :   bool Inited() const
      81                 :   {
      82              75 :     return !mDirectoryPath.IsEmpty();
      83                 :   }
      84                 : 
      85              75 :   bool Loaded() const
      86                 :   {
      87              75 :     return mLoaded;
      88                 :   }
      89                 : 
      90               0 :   bool Invalidated() const
      91                 :   {
      92               0 :     return mInvalidated;
      93                 :   }
      94                 : 
      95                 :   nsresult Init(nsIFile* aDirectory,
      96                 :                 mozIStorageConnection* aConnection);
      97                 : 
      98                 :   nsresult Load(mozIStorageConnection* aConnection);
      99                 : 
     100                 :   nsresult Invalidate();
     101                 : 
     102                 :   already_AddRefed<nsIFile> GetDirectory();
     103                 : 
     104                 :   already_AddRefed<FileInfo> GetFileInfo(PRInt64 aId);
     105                 : 
     106                 :   already_AddRefed<FileInfo> GetNewFileInfo();
     107                 : 
     108                 :   static already_AddRefed<nsIFile> GetFileForId(nsIFile* aDirectory,
     109                 :                                                 PRInt64 aId);
     110                 : 
     111                 : private:
     112                 :   nsCString mOrigin;
     113                 :   nsString mDatabaseName;
     114                 : 
     115                 :   nsString mDirectoryPath;
     116                 : 
     117                 :   PRInt64 mLastFileId;
     118                 : 
     119                 :   // Protected by IndexedDatabaseManager::FileMutex()
     120                 :   nsDataHashtable<nsUint64HashKey, FileInfo*> mFileInfos;
     121                 : 
     122                 :   bool mLoaded;
     123                 :   bool mInvalidated;
     124                 : };
     125                 : 
     126                 : END_INDEXEDDB_NAMESPACE
     127                 : 
     128                 : #endif // mozilla_dom_indexeddb_filemanager_h__

Generated by: LCOV version 1.7