LCOV - code coverage report
Current view: top level - js/xpconnect/wrappers - WrapperFactory.h (source / functions) Hit Total Coverage
Test: output.info Lines: 8 8 100.0 %
Date: 2017-07-14 16:53:18 Functions: 3 3 100.0 %
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 _xpc_WRAPPERFACTORY_H
       8             : #define _xpc_WRAPPERFACTORY_H
       9             : 
      10             : #include "jswrapper.h"
      11             : 
      12             : namespace xpc {
      13             : 
      14             : class WrapperFactory {
      15             :   public:
      16             :     enum { WAIVE_XRAY_WRAPPER_FLAG = js::Wrapper::LAST_USED_FLAG << 1,
      17             :            IS_XRAY_WRAPPER_FLAG    = WAIVE_XRAY_WRAPPER_FLAG << 1 };
      18             : 
      19             :     // Return true if any of any of the nested wrappers have the flag set.
      20       12405 :     static bool HasWrapperFlag(JSObject* wrapper, unsigned flag) {
      21       12405 :         unsigned flags = 0;
      22       12405 :         js::UncheckedUnwrap(wrapper, true, &flags);
      23       12405 :         return !!(flags & flag);
      24             :     }
      25             : 
      26       11160 :     static bool IsXrayWrapper(JSObject* wrapper) {
      27       11160 :         return HasWrapperFlag(wrapper, IS_XRAY_WRAPPER_FLAG);
      28             :     }
      29             : 
      30        1245 :     static bool HasWaiveXrayFlag(JSObject* wrapper) {
      31        1245 :         return HasWrapperFlag(wrapper, WAIVE_XRAY_WRAPPER_FLAG);
      32             :     }
      33             : 
      34             :     static bool IsCOW(JSObject* wrapper);
      35             : 
      36             :     static JSObject* GetXrayWaiver(JS::HandleObject obj);
      37             :     static JSObject* CreateXrayWaiver(JSContext* cx, JS::HandleObject obj);
      38             :     static JSObject* WaiveXray(JSContext* cx, JSObject* obj);
      39             : 
      40             :     // Computes whether we should allow the creation of an Xray waiver from
      41             :     // |target| to |origin|.
      42             :     static bool AllowWaiver(JSCompartment* target, JSCompartment* origin);
      43             : 
      44             :     // Convenience method for the above, operating on a wrapper.
      45             :     static bool AllowWaiver(JSObject* wrapper);
      46             : 
      47             :     // Prepare a given object for wrapping in a new compartment.
      48             :     static void PrepareForWrapping(JSContext* cx,
      49             :                                    JS::HandleObject scope,
      50             :                                    JS::HandleObject obj,
      51             :                                    JS::HandleObject objectPassedToWrap,
      52             :                                    JS::MutableHandleObject retObj);
      53             : 
      54             :     // Rewrap an object that is about to cross compartment boundaries.
      55             :     static JSObject* Rewrap(JSContext* cx,
      56             :                             JS::HandleObject existing,
      57             :                             JS::HandleObject obj);
      58             : 
      59             :     // Wrap wrapped object into a waiver wrapper and then re-wrap it.
      60             :     static bool WaiveXrayAndWrap(JSContext* cx, JS::MutableHandleValue vp);
      61             :     static bool WaiveXrayAndWrap(JSContext* cx, JS::MutableHandleObject object);
      62             : };
      63             : 
      64             : extern const js::Wrapper XrayWaiver;
      65             : 
      66             : } // namespace xpc
      67             : 
      68             : #endif /* _xpc_WRAPPERFACTORY_H */

Generated by: LCOV version 1.13