LCOV - code coverage report
Current view: top level - dom/bindings - nsScriptError.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 3 33.3 %
Date: 2017-07-14 16:53:18 Functions: 1 10 10.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_nsScriptError_h
       8             : #define mozilla_dom_nsScriptError_h
       9             : 
      10             : #include "mozilla/Atomics.h"
      11             : 
      12             : #include <stdint.h>
      13             : 
      14             : #include "jsapi.h"
      15             : #include "js/RootingAPI.h"
      16             : 
      17             : #include "nsIScriptError.h"
      18             : #include "nsString.h"
      19             : 
      20             : class nsScriptErrorNote final : public nsIScriptErrorNote {
      21             :  public:
      22             :   nsScriptErrorNote();
      23             : 
      24             :   NS_DECL_THREADSAFE_ISUPPORTS
      25             :   NS_DECL_NSISCRIPTERRORNOTE
      26             : 
      27             :   void Init(const nsAString& message, const nsAString& sourceName,
      28             :             uint32_t lineNumber, uint32_t columnNumber);
      29             : 
      30             :  private:
      31             :   virtual ~nsScriptErrorNote();
      32             : 
      33             :   nsString mMessage;
      34             :   nsString mSourceName;
      35             :   nsString mSourceLine;
      36             :   uint32_t mLineNumber;
      37             :   uint32_t mColumnNumber;
      38             : };
      39             : 
      40             : // Definition of nsScriptError..
      41             : class nsScriptErrorBase : public nsIScriptError {
      42             : public:
      43             :   nsScriptErrorBase();
      44             : 
      45             :   NS_DECL_NSICONSOLEMESSAGE
      46             :   NS_DECL_NSISCRIPTERROR
      47             : 
      48             :   void AddNote(nsIScriptErrorNote* note);
      49             : 
      50             : protected:
      51             :   virtual ~nsScriptErrorBase();
      52             : 
      53             :   void
      54             :   InitializeOnMainThread();
      55             : 
      56             :   nsCOMArray<nsIScriptErrorNote> mNotes;
      57             :   nsString mMessage;
      58             :   nsString mMessageName;
      59             :   nsString mSourceName;
      60             :   uint32_t mLineNumber;
      61             :   nsString mSourceLine;
      62             :   uint32_t mColumnNumber;
      63             :   uint32_t mFlags;
      64             :   nsCString mCategory;
      65             :   // mOuterWindowID is set on the main thread from InitializeOnMainThread().
      66             :   uint64_t mOuterWindowID;
      67             :   uint64_t mInnerWindowID;
      68             :   int64_t mTimeStamp;
      69             :   // mInitializedOnMainThread and mIsFromPrivateWindow are set on the main
      70             :   // thread from InitializeOnMainThread().
      71             :   mozilla::Atomic<bool> mInitializedOnMainThread;
      72             :   bool mIsFromPrivateWindow;
      73             : };
      74             : 
      75             : class nsScriptError final : public nsScriptErrorBase {
      76             : public:
      77           2 :   nsScriptError() {}
      78             :   NS_DECL_THREADSAFE_ISUPPORTS
      79             : 
      80             : private:
      81           0 :   virtual ~nsScriptError() {}
      82             : };
      83             : 
      84             : class nsScriptErrorWithStack : public nsScriptErrorBase {
      85             : public:
      86             :   explicit nsScriptErrorWithStack(JS::HandleObject);
      87             : 
      88             :   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      89           0 :   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsScriptErrorWithStack)
      90             : 
      91             :   NS_IMETHOD Init(const nsAString& message,
      92             :                   const nsAString& sourceName,
      93             :                   const nsAString& sourceLine,
      94             :                   uint32_t lineNumber,
      95             :                   uint32_t columnNumber,
      96             :                   uint32_t flags,
      97             :                   const char* category) override;
      98             : 
      99             :   NS_IMETHOD GetStack(JS::MutableHandleValue) override;
     100             :   NS_IMETHOD ToString(nsACString& aResult) override;
     101             : 
     102             : private:
     103             :   virtual ~nsScriptErrorWithStack();
     104             :   // Complete stackframe where the error happened.
     105             :   // Must be SavedFrame object.
     106             :   JS::Heap<JSObject*>  mStack;
     107             : };
     108             : 
     109             : #endif /* mozilla_dom_nsScriptError_h */

Generated by: LCOV version 1.13