LCOV - code coverage report
Current view: top level - dom/base - DOMRequest.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 22 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 29 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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_domrequest_h__
       8             : #define mozilla_dom_domrequest_h__
       9             : 
      10             : #include "nsIDOMDOMRequest.h"
      11             : #include "mozilla/Attributes.h"
      12             : #include "mozilla/DOMEventTargetHelper.h"
      13             : #include "mozilla/dom/DOMError.h"
      14             : #include "mozilla/dom/DOMRequestBinding.h"
      15             : 
      16             : #include "nsCOMPtr.h"
      17             : 
      18             : namespace mozilla {
      19             : 
      20             : class ErrorResult;
      21             : 
      22             : namespace dom {
      23             : 
      24             : class AnyCallback;
      25             : class Promise;
      26             : 
      27             : class DOMRequest : public DOMEventTargetHelper,
      28             :                    public nsIDOMDOMRequest
      29             : {
      30             : protected:
      31             :   JS::Heap<JS::Value> mResult;
      32             :   RefPtr<DOMError> mError;
      33             :   RefPtr<Promise> mPromise;
      34             :   bool mDone;
      35             : 
      36             : public:
      37             :   NS_DECL_ISUPPORTS_INHERITED
      38             :   NS_DECL_NSIDOMDOMREQUEST
      39           0 :   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
      40             : 
      41           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
      42             :                                                          DOMEventTargetHelper)
      43             : 
      44             :   // WrapperCache
      45           0 :   nsPIDOMWindowInner* GetParentObject() const
      46             :   {
      47           0 :     return GetOwner();
      48             :   }
      49             : 
      50             :   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
      51             : 
      52             :   // WebIDL Interface
      53           0 :   DOMRequestReadyState ReadyState() const
      54             :   {
      55           0 :     return mDone ? DOMRequestReadyState::Done
      56           0 :                  : DOMRequestReadyState::Pending;
      57             :   }
      58             : 
      59           0 :   void GetResult(JSContext*, JS::MutableHandle<JS::Value> aRetval) const
      60             :   {
      61           0 :     NS_ASSERTION(mDone || mResult.isUndefined(),
      62             :                  "Result should be undefined when pending");
      63           0 :     aRetval.set(mResult);
      64           0 :   }
      65             : 
      66           0 :   DOMError* GetError() const
      67             :   {
      68           0 :     NS_ASSERTION(mDone || !mError,
      69             :                  "Error should be null when pending");
      70           0 :     return mError;
      71             :   }
      72             : 
      73           0 :   IMPL_EVENT_HANDLER(success)
      74           0 :   IMPL_EVENT_HANDLER(error)
      75             : 
      76             :   void
      77             :   Then(JSContext* aCx, AnyCallback* aResolveCallback,
      78             :        AnyCallback* aRejectCallback,
      79             :        JS::MutableHandle<JS::Value> aRetval,
      80             :        mozilla::ErrorResult& aRv);
      81             : 
      82             :   void FireSuccess(JS::Handle<JS::Value> aResult);
      83             :   void FireError(const nsAString& aError);
      84             :   void FireError(nsresult aError);
      85             :   void FireDetailedError(DOMError* aError);
      86             : 
      87             :   explicit DOMRequest(nsPIDOMWindowInner* aWindow);
      88             :   explicit DOMRequest(nsIGlobalObject* aGlobal);
      89             : 
      90             : protected:
      91             :   virtual ~DOMRequest();
      92             : 
      93             :   void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
      94             : 
      95             :   void RootResultVal();
      96             : };
      97             : 
      98           0 : class DOMRequestService final : public nsIDOMRequestService
      99             : {
     100           0 :   ~DOMRequestService() {}
     101             : 
     102             : public:
     103             :   NS_DECL_ISUPPORTS
     104             :   NS_DECL_NSIDOMREQUESTSERVICE
     105             : 
     106             :   // Returns an owning reference! No one should call this but the factory.
     107           0 :   static DOMRequestService* FactoryCreate()
     108             :   {
     109           0 :     DOMRequestService* res = new DOMRequestService;
     110           0 :     NS_ADDREF(res);
     111           0 :     return res;
     112             :   }
     113             : };
     114             : 
     115             : } // namespace dom
     116             : } // namespace mozilla
     117             : 
     118             : #define DOMREQUEST_SERVICE_CONTRACTID "@mozilla.org/dom/dom-request-service;1"
     119             : 
     120             : #endif // mozilla_dom_domrequest_h__

Generated by: LCOV version 1.13