LCOV - code coverage report
Current view: top level - js/xpconnect/src - SandboxPrivate.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 19 42.1 %
Date: 2017-07-14 16:53:18 Functions: 4 15 26.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* vim: set ts=8 sts=4 et sw=4 tw=99: */
       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 __SANDBOXPRIVATE_H__
       8             : #define __SANDBOXPRIVATE_H__
       9             : 
      10             : #include "nsIGlobalObject.h"
      11             : #include "nsIScriptObjectPrincipal.h"
      12             : #include "nsIPrincipal.h"
      13             : #include "nsWeakReference.h"
      14             : #include "nsWrapperCache.h"
      15             : 
      16             : #include "js/RootingAPI.h"
      17             : 
      18             : 
      19             : class SandboxPrivate : public nsIGlobalObject,
      20             :                        public nsIScriptObjectPrincipal,
      21             :                        public nsSupportsWeakReference,
      22             :                        public nsWrapperCache
      23             : {
      24             : public:
      25          25 :     SandboxPrivate(nsIPrincipal* principal, JSObject* global)
      26          25 :         : mPrincipal(principal)
      27             :     {
      28          25 :         SetIsNotDOMBinding();
      29          25 :         SetWrapper(global);
      30          25 :     }
      31             : 
      32             :     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
      33        4782 :     NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(SandboxPrivate,
      34             :                                                            nsIGlobalObject)
      35             : 
      36           0 :     nsIPrincipal* GetPrincipal() override
      37             :     {
      38           0 :         return mPrincipal;
      39             :     }
      40             : 
      41        1482 :     JSObject* GetGlobalJSObject() override
      42             :     {
      43        1482 :         return GetWrapper();
      44             :     }
      45             : 
      46           0 :     void ForgetGlobalObject(JSObject* obj)
      47             :     {
      48           0 :         ClearWrapper(obj);
      49           0 :     }
      50             : 
      51           0 :     virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override
      52             :     {
      53           0 :         MOZ_CRASH("SandboxPrivate doesn't use DOM bindings!");
      54             :     }
      55             : 
      56           0 :     void ObjectMoved(JSObject* obj, const JSObject* old)
      57             :     {
      58           0 :         UpdateWrapper(obj, old);
      59           0 :     }
      60             : 
      61             : private:
      62           0 :     virtual ~SandboxPrivate() { }
      63             : 
      64             :     nsCOMPtr<nsIPrincipal> mPrincipal;
      65             : };
      66             : 
      67             : #endif // __SANDBOXPRIVATE_H__

Generated by: LCOV version 1.13