LCOV - code coverage report
Current view: directory - dom/base - DOMRequest.h (source / functions) Found Hit Coverage
Test: app.info Lines: 16 1 6.2 %
Date: 2012-06-02 Functions: 20 1 5.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                 : /* 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 "nsIDOMDOMError.h"
      12                 : #include "nsDOMEventTargetHelper.h"
      13                 : #include "nsContentUtils.h"
      14                 : 
      15                 : #include "nsCOMPtr.h"
      16                 : 
      17                 : namespace mozilla {
      18                 : namespace dom {
      19                 : 
      20                 : class DOMRequest : public nsDOMEventTargetHelper,
      21                 :                    public nsIDOMDOMRequest
      22                 : {
      23                 :   bool mDone;
      24                 :   jsval mResult;
      25                 :   nsCOMPtr<nsIDOMDOMError> mError;
      26                 :   bool mRooted;
      27                 : 
      28                 :   NS_DECL_EVENT_HANDLER(success)
      29                 :   NS_DECL_EVENT_HANDLER(error)
      30                 : 
      31                 : public:
      32                 :   NS_DECL_ISUPPORTS_INHERITED
      33                 :   NS_DECL_NSIDOMDOMREQUEST
      34               0 :   NS_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper::)
      35                 : 
      36            1464 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
      37                 :                                                          nsDOMEventTargetHelper)
      38                 : 
      39                 :   void FireSuccess(jsval aResult);
      40                 :   void FireError(const nsAString& aError);
      41                 : 
      42                 :   DOMRequest(nsIDOMWindow* aWindow);
      43                 : 
      44               0 :   virtual ~DOMRequest()
      45               0 :   {
      46               0 :     UnrootResultVal();
      47               0 :   }
      48                 : 
      49                 : private:
      50                 :   void FireEvent(const nsAString& aType);
      51                 : 
      52               0 :   void RootResultVal()
      53                 :   {
      54               0 :     if (!mRooted) {
      55               0 :       NS_HOLD_JS_OBJECTS(this, DOMRequest);
      56               0 :       mRooted = true;
      57                 :     }
      58               0 :   }
      59                 : 
      60               0 :   void UnrootResultVal()
      61                 :   {
      62               0 :     if (mRooted) {
      63               0 :       NS_DROP_JS_OBJECTS(this, DOMRequest);
      64               0 :       mRooted = false;
      65                 :     }
      66               0 :   }
      67                 : };
      68                 : 
      69                 : class DOMRequestService : public nsIDOMRequestService
      70                 : {
      71                 : public:
      72                 :   NS_DECL_ISUPPORTS
      73                 :   NS_DECL_NSIDOMREQUESTSERVICE
      74                 : 
      75                 :   // Returns an owning reference! No one should call this but the factory.
      76                 :   static DOMRequestService* FactoryCreate()
      77                 :   {
      78                 :     DOMRequestService* res = new DOMRequestService;
      79                 :     NS_ADDREF(res);
      80                 :     return res;
      81                 :   }
      82                 : };
      83                 : 
      84                 : } // namespace dom
      85                 : } // namespace mozilla
      86                 : 
      87                 : #define DOMREQUEST_SERVICE_CONTRACTID "@mozilla.org/dom/dom-request-service;1"
      88                 : 
      89                 : #endif // mozilla_dom_domrequest_h__

Generated by: LCOV version 1.7