LCOV - code coverage report
Current view: top level - dom/indexedDB - IDBRequest.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 26 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 24 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_idbrequest_h__
       8             : #define mozilla_dom_idbrequest_h__
       9             : 
      10             : #include "js/RootingAPI.h"
      11             : #include "mozilla/Attributes.h"
      12             : #include "mozilla/EventForwards.h"
      13             : #include "mozilla/dom/IDBRequestBinding.h"
      14             : #include "mozilla/dom/IDBWrapperCache.h"
      15             : #include "nsAutoPtr.h"
      16             : #include "nsCycleCollectionParticipant.h"
      17             : 
      18             : #define PRIVATE_IDBREQUEST_IID \
      19             :   {0xe68901e5, 0x1d50, 0x4ee9, {0xaf, 0x49, 0x90, 0x99, 0x4a, 0xff, 0xc8, 0x39}}
      20             : 
      21             : class nsPIDOMWindowInner;
      22             : 
      23             : namespace mozilla {
      24             : 
      25             : class ErrorResult;
      26             : 
      27             : namespace dom {
      28             : 
      29             : class DOMError;
      30             : class IDBCursor;
      31             : class IDBDatabase;
      32             : class IDBFactory;
      33             : class IDBIndex;
      34             : class IDBObjectStore;
      35             : class IDBTransaction;
      36             : template <typename> struct Nullable;
      37             : class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
      38             : 
      39             : class IDBRequest
      40             :   : public IDBWrapperCache
      41             : {
      42             : protected:
      43             :   // mSourceAsObjectStore and mSourceAsIndex are exclusive and one must always
      44             :   // be set. mSourceAsCursor is sometimes set also.
      45             :   RefPtr<IDBObjectStore> mSourceAsObjectStore;
      46             :   RefPtr<IDBIndex> mSourceAsIndex;
      47             :   RefPtr<IDBCursor> mSourceAsCursor;
      48             : 
      49             :   RefPtr<IDBTransaction> mTransaction;
      50             : 
      51             :   JS::Heap<JS::Value> mResultVal;
      52             :   RefPtr<DOMError> mError;
      53             : 
      54             :   nsString mFilename;
      55             :   uint64_t mLoggingSerialNumber;
      56             :   nsresult mErrorCode;
      57             :   uint32_t mLineNo;
      58             :   uint32_t mColumn;
      59             :   bool mHaveResultOrErrorCode;
      60             : 
      61             : public:
      62             :   class ResultCallback;
      63             : 
      64             :   static already_AddRefed<IDBRequest>
      65             :   Create(JSContext* aCx, IDBDatabase* aDatabase, IDBTransaction* aTransaction);
      66             : 
      67             :   static already_AddRefed<IDBRequest>
      68             :   Create(JSContext* aCx,
      69             :          IDBObjectStore* aSource,
      70             :          IDBDatabase* aDatabase,
      71             :          IDBTransaction* aTransaction);
      72             : 
      73             :   static already_AddRefed<IDBRequest>
      74             :   Create(JSContext* aCx,
      75             :          IDBIndex* aSource,
      76             :          IDBDatabase* aDatabase,
      77             :          IDBTransaction* aTransaction);
      78             : 
      79             :   static void
      80             :   CaptureCaller(JSContext* aCx, nsAString& aFilename, uint32_t* aLineNo,
      81             :                 uint32_t* aColumn);
      82             : 
      83             :   static uint64_t
      84             :   NextSerialNumber();
      85             : 
      86             :   // nsIDOMEventTarget
      87             :   virtual nsresult
      88             :   GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
      89             : 
      90             :   void
      91             :   GetSource(Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const;
      92             : 
      93             :   void
      94             :   Reset();
      95             : 
      96             :   void
      97             :   SetResultCallback(ResultCallback* aCallback);
      98             : 
      99             :   void
     100             :   SetError(nsresult aRv);
     101             : 
     102             :   nsresult
     103             :   GetErrorCode() const
     104             : #ifdef DEBUG
     105             :   ;
     106             : #else
     107             :   {
     108             :     return mErrorCode;
     109             :   }
     110             : #endif
     111             : 
     112             :   DOMError*
     113             :   GetErrorAfterResult() const
     114             : #ifdef DEBUG
     115             :   ;
     116             : #else
     117             :   {
     118             :     return mError;
     119             :   }
     120             : #endif
     121             : 
     122             :   DOMError*
     123             :   GetError(ErrorResult& aRv);
     124             : 
     125             :   void
     126             :   GetCallerLocation(nsAString& aFilename, uint32_t* aLineNo,
     127             :                     uint32_t* aColumn) const;
     128             : 
     129             :   bool
     130           0 :   IsPending() const
     131             :   {
     132           0 :     return !mHaveResultOrErrorCode;
     133             :   }
     134             : 
     135             :   uint64_t
     136           0 :   LoggingSerialNumber() const
     137             :   {
     138           0 :     AssertIsOnOwningThread();
     139             : 
     140           0 :     return mLoggingSerialNumber;
     141             :   }
     142             : 
     143             :   void
     144             :   SetLoggingSerialNumber(uint64_t aLoggingSerialNumber);
     145             : 
     146             :   nsPIDOMWindowInner*
     147           0 :   GetParentObject() const
     148             :   {
     149           0 :     return GetOwner();
     150             :   }
     151             : 
     152             :   void
     153             :   GetResult(JS::MutableHandle<JS::Value> aResult, ErrorResult& aRv) const;
     154             : 
     155             :   void
     156           0 :   GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
     157             :             ErrorResult& aRv) const
     158             :   {
     159           0 :     GetResult(aResult, aRv);
     160           0 :   }
     161             : 
     162             :   IDBTransaction*
     163           0 :   GetTransaction() const
     164             :   {
     165           0 :     AssertIsOnOwningThread();
     166             : 
     167           0 :     return mTransaction;
     168             :   }
     169             : 
     170             :   IDBRequestReadyState
     171             :   ReadyState() const;
     172             : 
     173             :   void
     174             :   SetSource(IDBCursor* aSource);
     175             : 
     176           0 :   IMPL_EVENT_HANDLER(success);
     177           0 :   IMPL_EVENT_HANDLER(error);
     178             : 
     179             :   void
     180           0 :   AssertIsOnOwningThread() const
     181             :   {
     182           0 :     NS_ASSERT_OWNINGTHREAD(IDBRequest);
     183           0 :   }
     184             : 
     185             :   NS_DECL_ISUPPORTS_INHERITED
     186           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
     187             :                                                          IDBWrapperCache)
     188             : 
     189             :   // nsWrapperCache
     190             :   virtual JSObject*
     191             :   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     192             : 
     193             : protected:
     194             :   explicit IDBRequest(IDBDatabase* aDatabase);
     195             :   explicit IDBRequest(nsPIDOMWindowInner* aOwner);
     196             :   ~IDBRequest();
     197             : 
     198             :   void
     199             :   InitMembers();
     200             : 
     201             :   void
     202             :   ConstructResult();
     203             : };
     204             : 
     205             : class NS_NO_VTABLE IDBRequest::ResultCallback
     206             : {
     207             : public:
     208             :   virtual nsresult
     209             :   GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult) = 0;
     210             : 
     211             : protected:
     212           0 :   ResultCallback()
     213           0 :   { }
     214             : };
     215             : 
     216             : class IDBOpenDBRequest final
     217             :   : public IDBRequest
     218             : {
     219             :   class WorkerHolder;
     220             : 
     221             :   // Only touched on the owning thread.
     222             :   RefPtr<IDBFactory> mFactory;
     223             : 
     224             :   nsAutoPtr<WorkerHolder> mWorkerHolder;
     225             : 
     226             :   const bool mFileHandleDisabled;
     227             :   bool mIncreasedActiveDatabaseCount;
     228             : 
     229             : public:
     230             :   static already_AddRefed<IDBOpenDBRequest>
     231             :   CreateForWindow(JSContext* aCx,
     232             :                   IDBFactory* aFactory,
     233             :                   nsPIDOMWindowInner* aOwner,
     234             :                   JS::Handle<JSObject*> aScriptOwner);
     235             : 
     236             :   static already_AddRefed<IDBOpenDBRequest>
     237             :   CreateForJS(JSContext* aCx,
     238             :               IDBFactory* aFactory,
     239             :               JS::Handle<JSObject*> aScriptOwner);
     240             : 
     241             :   bool
     242           0 :   IsFileHandleDisabled() const
     243             :   {
     244           0 :     return mFileHandleDisabled;
     245             :   }
     246             : 
     247             :   void
     248             :   SetTransaction(IDBTransaction* aTransaction);
     249             : 
     250             :   void
     251             :   DispatchNonTransactionError(nsresult aErrorCode);
     252             : 
     253             :   void
     254             :   NoteComplete();
     255             : 
     256             :   // nsIDOMEventTarget
     257             :   virtual nsresult
     258             :   PostHandleEvent(EventChainPostVisitor& aVisitor) override;
     259             : 
     260             :   IDBFactory*
     261             :   Factory() const
     262             :   {
     263             :     return mFactory;
     264             :   }
     265             : 
     266           0 :   IMPL_EVENT_HANDLER(blocked);
     267           0 :   IMPL_EVENT_HANDLER(upgradeneeded);
     268             : 
     269             :   NS_DECL_ISUPPORTS_INHERITED
     270           0 :   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBOpenDBRequest, IDBRequest)
     271             : 
     272             :   // nsWrapperCache
     273             :   virtual JSObject*
     274             :   WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
     275             : 
     276             : private:
     277             :   IDBOpenDBRequest(IDBFactory* aFactory,
     278             :                    nsPIDOMWindowInner* aOwner,
     279             :                    bool aFileHandleDisabled);
     280             : 
     281             :   ~IDBOpenDBRequest();
     282             : 
     283             :   void
     284             :   IncreaseActiveDatabaseCount();
     285             : 
     286             :   void
     287             :   MaybeDecreaseActiveDatabaseCount();
     288             : };
     289             : 
     290             : } // namespace dom
     291             : } // namespace mozilla
     292             : 
     293             : #endif // mozilla_dom_idbrequest_h__

Generated by: LCOV version 1.13