LCOV - code coverage report
Current view: directory - dom/indexedDB - IDBCursor.h (source / functions) Found Hit Coverage
Test: app.info Lines: 2 2 100.0 %
Date: 2012-06-02 Functions: 5 5 100.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) 2010
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   Ben Turner <bent.mozilla@gmail.com>
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #ifndef mozilla_dom_indexeddb_idbcursor_h__
      41                 : #define mozilla_dom_indexeddb_idbcursor_h__
      42                 : 
      43                 : #include "mozilla/dom/indexedDB/IndexedDatabase.h"
      44                 : #include "mozilla/dom/indexedDB/IDBObjectStore.h"
      45                 : #include "mozilla/dom/indexedDB/Key.h"
      46                 : 
      47                 : #include "nsIIDBCursorWithValue.h"
      48                 : 
      49                 : #include "nsCycleCollectionParticipant.h"
      50                 : 
      51                 : class nsIRunnable;
      52                 : class nsIScriptContext;
      53                 : class nsPIDOMWindow;
      54                 : 
      55                 : BEGIN_INDEXEDDB_NAMESPACE
      56                 : 
      57                 : class IDBIndex;
      58                 : class IDBRequest;
      59                 : class IDBTransaction;
      60                 : 
      61                 : class ContinueHelper;
      62                 : class ContinueObjectStoreHelper;
      63                 : class ContinueIndexHelper;
      64                 : class ContinueIndexObjectHelper;
      65                 : 
      66                 : class IDBCursor : public nsIIDBCursorWithValue
      67                 : {
      68                 :   friend class ContinueHelper;
      69                 :   friend class ContinueObjectStoreHelper;
      70                 :   friend class ContinueIndexHelper;
      71                 :   friend class ContinueIndexObjectHelper;
      72                 : 
      73                 : public:
      74               8 :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      75                 :   NS_DECL_NSIIDBCURSOR
      76                 :   NS_DECL_NSIIDBCURSORWITHVALUE
      77                 : 
      78           17149 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
      79                 : 
      80                 :   enum Type
      81                 :   {
      82                 :     OBJECTSTORE = 0,
      83                 :     INDEXKEY,
      84                 :     INDEXOBJECT
      85                 :   };
      86                 : 
      87                 :   enum Direction
      88                 :   {
      89                 :     NEXT = 0,
      90                 :     NEXT_UNIQUE,
      91                 :     PREV,
      92                 :     PREV_UNIQUE
      93                 :   };
      94                 : 
      95                 :   // For OBJECTSTORE cursors.
      96                 :   static
      97                 :   already_AddRefed<IDBCursor>
      98                 :   Create(IDBRequest* aRequest,
      99                 :          IDBTransaction* aTransaction,
     100                 :          IDBObjectStore* aObjectStore,
     101                 :          Direction aDirection,
     102                 :          const Key& aRangeKey,
     103                 :          const nsACString& aContinueQuery,
     104                 :          const nsACString& aContinueToQuery,
     105                 :          const Key& aKey,
     106                 :          StructuredCloneReadInfo& aCloneReadInfo);
     107                 : 
     108                 :   // For INDEXKEY cursors.
     109                 :   static
     110                 :   already_AddRefed<IDBCursor>
     111                 :   Create(IDBRequest* aRequest,
     112                 :          IDBTransaction* aTransaction,
     113                 :          IDBIndex* aIndex,
     114                 :          Direction aDirection,
     115                 :          const Key& aRangeKey,
     116                 :          const nsACString& aContinueQuery,
     117                 :          const nsACString& aContinueToQuery,
     118                 :          const Key& aKey,
     119                 :          const Key& aObjectKey);
     120                 : 
     121                 :   // For INDEXOBJECT cursors.
     122                 :   static
     123                 :   already_AddRefed<IDBCursor>
     124                 :   Create(IDBRequest* aRequest,
     125                 :          IDBTransaction* aTransaction,
     126                 :          IDBIndex* aIndex,
     127                 :          Direction aDirection,
     128                 :          const Key& aRangeKey,
     129                 :          const nsACString& aContinueQuery,
     130                 :          const nsACString& aContinueToQuery,
     131                 :          const Key& aKey,
     132                 :          const Key& aObjectKey,
     133                 :          StructuredCloneReadInfo& aCloneReadInfo);
     134                 : 
     135                 :   IDBTransaction* Transaction()
     136                 :   {
     137                 :     return mTransaction;
     138                 :   }
     139                 : 
     140                 :   static nsresult ParseDirection(const nsAString& aDirection,
     141                 :                                  Direction* aResult);
     142                 : 
     143                 : protected:
     144                 :   IDBCursor();
     145                 :   ~IDBCursor();
     146                 : 
     147                 :   static
     148                 :   already_AddRefed<IDBCursor>
     149                 :   CreateCommon(IDBRequest* aRequest,
     150                 :                IDBTransaction* aTransaction,
     151                 :                IDBObjectStore* aObjectStore,
     152                 :                Direction aDirection,
     153                 :                const Key& aRangeKey,
     154                 :                const nsACString& aContinueQuery,
     155                 :                const nsACString& aContinueToQuery);
     156                 : 
     157                 :   nsresult
     158                 :   ContinueInternal(const Key& aKey,
     159                 :                    PRInt32 aCount);
     160                 : 
     161                 :   nsRefPtr<IDBRequest> mRequest;
     162                 :   nsRefPtr<IDBTransaction> mTransaction;
     163                 :   nsRefPtr<IDBObjectStore> mObjectStore;
     164                 :   nsRefPtr<IDBIndex> mIndex;
     165                 : 
     166                 :   JSObject* mScriptOwner;
     167                 : 
     168                 :   Type mType;
     169                 :   Direction mDirection;
     170                 :   nsCString mContinueQuery;
     171                 :   nsCString mContinueToQuery;
     172                 : 
     173                 :   // These are cycle-collected!
     174                 :   jsval mCachedKey;
     175                 :   jsval mCachedPrimaryKey;
     176                 :   jsval mCachedValue;
     177                 : 
     178                 :   Key mRangeKey;
     179                 : 
     180                 :   Key mKey;
     181                 :   Key mObjectKey;
     182                 :   StructuredCloneReadInfo mCloneReadInfo;
     183                 :   Key mContinueToKey;
     184                 : 
     185                 :   bool mHaveCachedKey;
     186                 :   bool mHaveCachedPrimaryKey;
     187                 :   bool mHaveCachedValue;
     188                 :   bool mRooted;
     189                 :   bool mContinueCalled;
     190                 :   bool mHaveValue;
     191                 : };
     192                 : 
     193                 : END_INDEXEDDB_NAMESPACE
     194                 : 
     195                 : #endif // mozilla_dom_indexeddb_idbcursor_h__

Generated by: LCOV version 1.7