LCOV - code coverage report
Current view: top level - dom/indexedDB - IDBCursor.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 5 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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             : #ifndef mozilla_dom_idbcursor_h__
       8             : #define mozilla_dom_idbcursor_h__
       9             : 
      10             : #include "IndexedDatabase.h"
      11             : #include "js/RootingAPI.h"
      12             : #include "mozilla/Attributes.h"
      13             : #include "mozilla/dom/IDBCursorBinding.h"
      14             : #include "mozilla/dom/indexedDB/Key.h"
      15             : #include "nsCycleCollectionParticipant.h"
      16             : #include "nsWrapperCache.h"
      17             : 
      18             : class nsPIDOMWindowInner;
      19             : 
      20             : namespace mozilla {
      21             : 
      22             : class ErrorResult;
      23             : 
      24             : namespace dom {
      25             : 
      26             : class IDBIndex;
      27             : class IDBObjectStore;
      28             : class IDBRequest;
      29             : class IDBTransaction;
      30             : class OwningIDBObjectStoreOrIDBIndex;
      31             : 
      32             : namespace indexedDB {
      33             : class BackgroundCursorChild;
      34             : }
      35             : 
      36             : class IDBCursor final
      37             :   : public nsISupports
      38             :   , public nsWrapperCache
      39             : {
      40             : public:
      41             :   typedef indexedDB::Key Key;
      42             :   typedef indexedDB::StructuredCloneReadInfo StructuredCloneReadInfo;
      43             : 
      44             :   enum Direction
      45             :   {
      46             :     NEXT = 0,
      47             :     NEXT_UNIQUE,
      48             :     PREV,
      49             :     PREV_UNIQUE,
      50             : 
      51             :     // Only needed for IPC serialization helper, should never be used in code.
      52             :     DIRECTION_INVALID
      53             :   };
      54             : 
      55             : private:
      56             :   enum Type
      57             :   {
      58             :     Type_ObjectStore,
      59             :     Type_ObjectStoreKey,
      60             :     Type_Index,
      61             :     Type_IndexKey,
      62             :   };
      63             : 
      64             :   indexedDB::BackgroundCursorChild* mBackgroundActor;
      65             : 
      66             :   RefPtr<IDBRequest> mRequest;
      67             :   RefPtr<IDBObjectStore> mSourceObjectStore;
      68             :   RefPtr<IDBIndex> mSourceIndex;
      69             : 
      70             :   // mSourceObjectStore or mSourceIndex will hold this alive.
      71             :   IDBTransaction* mTransaction;
      72             : 
      73             :   JS::Heap<JSObject*> mScriptOwner;
      74             : 
      75             :   // These are cycle-collected!
      76             :   JS::Heap<JS::Value> mCachedKey;
      77             :   JS::Heap<JS::Value> mCachedPrimaryKey;
      78             :   JS::Heap<JS::Value> mCachedValue;
      79             : 
      80             :   Key mKey;
      81             :   Key mSortKey;
      82             :   Key mPrimaryKey;
      83             :   StructuredCloneReadInfo mCloneInfo;
      84             : 
      85             :   const Type mType;
      86             :   const Direction mDirection;
      87             : 
      88             :   bool mHaveCachedKey : 1;
      89             :   bool mHaveCachedPrimaryKey : 1;
      90             :   bool mHaveCachedValue : 1;
      91             :   bool mRooted : 1;
      92             :   bool mContinueCalled : 1;
      93             :   bool mHaveValue : 1;
      94             : 
      95             : public:
      96             :   static already_AddRefed<IDBCursor>
      97             :   Create(indexedDB::BackgroundCursorChild* aBackgroundActor,
      98             :          const Key& aKey,
      99             :          StructuredCloneReadInfo&& aCloneInfo);
     100             : 
     101             :   static already_AddRefed<IDBCursor>
     102             :   Create(indexedDB::BackgroundCursorChild* aBackgroundActor,
     103             :          const Key& aKey);
     104             : 
     105             :   static already_AddRefed<IDBCursor>
     106             :   Create(indexedDB::BackgroundCursorChild* aBackgroundActor,
     107             :          const Key& aKey,
     108             :          const Key& aSortKey,
     109             :          const Key& aPrimaryKey,
     110             :          StructuredCloneReadInfo&& aCloneInfo);
     111             : 
     112             :   static already_AddRefed<IDBCursor>
     113             :   Create(indexedDB::BackgroundCursorChild* aBackgroundActor,
     114             :          const Key& aKey,
     115             :          const Key& aSortKey,
     116             :          const Key& aPrimaryKey);
     117             : 
     118             :   static Direction
     119             :   ConvertDirection(IDBCursorDirection aDirection);
     120             : 
     121             :   void
     122             :   AssertIsOnOwningThread() const
     123             : #ifdef DEBUG
     124             :   ;
     125             : #else
     126             :   { }
     127             : #endif
     128             : 
     129             :   nsPIDOMWindowInner*
     130             :   GetParentObject() const;
     131             : 
     132             :   void
     133             :   GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const;
     134             : 
     135             :   IDBCursorDirection
     136             :   GetDirection() const;
     137             : 
     138             :   void
     139             :   GetKey(JSContext* aCx,
     140             :          JS::MutableHandle<JS::Value> aResult,
     141             :          ErrorResult& aRv);
     142             : 
     143             :   void
     144             :   GetPrimaryKey(JSContext* aCx,
     145             :                 JS::MutableHandle<JS::Value> aResult,
     146             :                 ErrorResult& aRv);
     147             : 
     148             :   void
     149             :   GetValue(JSContext* aCx,
     150             :            JS::MutableHandle<JS::Value> aResult,
     151             :            ErrorResult& aRv);
     152             : 
     153             :   void
     154             :   Continue(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
     155             : 
     156             :   void
     157             :   ContinuePrimaryKey(JSContext* aCx,
     158             :                      JS::Handle<JS::Value> aKey,
     159             :                      JS::Handle<JS::Value> aPrimaryKey,
     160             :                      ErrorResult& aRv);
     161             : 
     162             :   void
     163             :   Advance(uint32_t aCount, ErrorResult& aRv);
     164             : 
     165             :   already_AddRefed<IDBRequest>
     166             :   Update(JSContext* aCx, JS::Handle<JS::Value> aValue, ErrorResult& aRv);
     167             : 
     168             :   already_AddRefed<IDBRequest>
     169             :   Delete(JSContext* aCx, ErrorResult& aRv);
     170             : 
     171             :   void
     172             :   Reset();
     173             : 
     174             :   void
     175             :   Reset(Key&& aKey, StructuredCloneReadInfo&& aValue);
     176             : 
     177             :   void
     178             :   Reset(Key&& aKey);
     179             : 
     180             :   void
     181             :   Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey, StructuredCloneReadInfo&& aValue);
     182             : 
     183             :   void
     184             :   Reset(Key&& aKey, Key&& aSortKey, Key&& aPrimaryKey);
     185             : 
     186             :   void
     187           0 :   ClearBackgroundActor()
     188             :   {
     189           0 :     AssertIsOnOwningThread();
     190             : 
     191           0 :     mBackgroundActor = nullptr;
     192           0 :   }
     193             : 
     194             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     195           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
     196             : 
     197             :   // nsWrapperCache
     198             :   virtual JSObject*
     199             :   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     200             : 
     201             : private:
     202             :   IDBCursor(Type aType,
     203             :             indexedDB::BackgroundCursorChild* aBackgroundActor,
     204             :             const Key& aKey);
     205             : 
     206             :   ~IDBCursor();
     207             : 
     208             : #ifdef ENABLE_INTL_API
     209             :   // Checks if this is a locale aware cursor (ie. the index's sortKey is unset)
     210             :   bool
     211             :   IsLocaleAware() const;
     212             : #endif
     213             : 
     214             :   void
     215             :   DropJSObjects();
     216             : 
     217             :   bool
     218             :   IsSourceDeleted() const;
     219             : };
     220             : 
     221             : } // namespace dom
     222             : } // namespace mozilla
     223             : 
     224             : #endif // mozilla_dom_idbcursor_h__

Generated by: LCOV version 1.13