LCOV - code coverage report
Current view: top level - js/ipc - WrapperOwner.h (source / functions) Hit Total Coverage
Test: output.info Lines: 1 2 50.0 %
Date: 2017-07-14 16:53:18 Functions: 1 2 50.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 sw=4 et tw=80:
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       7             : 
       8             : #ifndef mozilla_jsipc_WrapperOwner_h__
       9             : #define mozilla_jsipc_WrapperOwner_h__
      10             : 
      11             : #include "JavaScriptShared.h"
      12             : #include "mozilla/ipc/ProtocolUtils.h"
      13             : #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
      14             : #include "js/Class.h"
      15             : #include "js/Proxy.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace jsipc {
      19             : 
      20           0 : class WrapperOwner : public virtual JavaScriptShared
      21             : {
      22             :   public:
      23             :     typedef mozilla::ipc::IProtocol::ActorDestroyReason
      24             :            ActorDestroyReason;
      25             : 
      26             :     WrapperOwner();
      27             :     bool init();
      28             : 
      29             :     // Standard internal methods.
      30             :     // (The traps should be in the same order like js/Proxy.h)
      31             :     bool getOwnPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
      32             :                                   JS::MutableHandle<JS::PropertyDescriptor> desc);
      33             :     bool defineProperty(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
      34             :                         JS::Handle<JS::PropertyDescriptor> desc,
      35             :                         JS::ObjectOpResult& result);
      36             :     bool ownPropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::AutoIdVector& props);
      37             :     bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
      38             :                  JS::ObjectOpResult& result);
      39             :     bool preventExtensions(JSContext* cx, JS::HandleObject proxy, JS::ObjectOpResult& result);
      40             :     bool isExtensible(JSContext* cx, JS::HandleObject proxy, bool* extensible);
      41             :     bool has(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, bool* bp);
      42             :     bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver,
      43             :              JS::HandleId id, JS::MutableHandleValue vp);
      44             :     bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue v,
      45             :              JS::HandleValue receiver, JS::ObjectOpResult& result);
      46             :     bool callOrConstruct(JSContext* cx, JS::HandleObject proxy, const JS::CallArgs& args,
      47             :                          bool construct);
      48             : 
      49             :     // SpiderMonkey extensions.
      50             :     bool getPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id,
      51             :                                JS::MutableHandle<JS::PropertyDescriptor> desc);
      52             :     bool hasOwn(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, bool* bp);
      53             :     bool getOwnEnumerablePropertyKeys(JSContext* cx, JS::HandleObject proxy,
      54             :                                       JS::AutoIdVector& props);
      55             :     bool hasInstance(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool* bp);
      56             :     bool getBuiltinClass(JSContext* cx, JS::HandleObject proxy, js::ESClass* cls);
      57             :     bool isArray(JSContext* cx, JS::HandleObject proxy, JS::IsArrayAnswer* answer);
      58             :     const char* className(JSContext* cx, JS::HandleObject proxy);
      59             :     bool getPrototype(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleObject protop);
      60             :     bool getPrototypeIfOrdinary(JSContext* cx, JS::HandleObject proxy, bool* isOrdinary,
      61             :                                 JS::MutableHandleObject protop);
      62             : 
      63             :     js::RegExpShared* regexp_toShared(JSContext* cx, JS::HandleObject proxy);
      64             : 
      65             :     nsresult instanceOf(JSObject* obj, const nsID* id, bool* bp);
      66             : 
      67             :     bool toString(JSContext* cx, JS::HandleObject callee, JS::CallArgs& args);
      68             :     bool DOMQI(JSContext* cx, JS::HandleObject callee, JS::CallArgs& args);
      69             : 
      70             :     /*
      71             :      * Check that |obj| is a DOM wrapper whose prototype chain contains
      72             :      * |prototypeID| at depth |depth|.
      73             :      */
      74             :     bool domInstanceOf(JSContext* cx, JSObject* obj, int prototypeID, int depth, bool* bp);
      75             : 
      76           3 :     bool active() { return !inactive_; }
      77             : 
      78             :     virtual bool allowMessage(JSContext* cx) = 0;
      79             : 
      80             :     void drop(JSObject* obj);
      81             :     void updatePointer(JSObject* obj, const JSObject* old);
      82             : 
      83             :     virtual void ActorDestroy(ActorDestroyReason why);
      84             : 
      85             :     virtual bool toObjectVariant(JSContext* cx, JSObject* obj, ObjectVariant* objVarp);
      86             :     virtual JSObject* fromObjectVariant(JSContext* cx, const ObjectVariant& objVar);
      87             :     JSObject* fromRemoteObjectVariant(JSContext* cx, const RemoteObject& objVar);
      88             :     JSObject* fromLocalObjectVariant(JSContext* cx, const LocalObject& objVar);
      89             : 
      90             :   protected:
      91             :     ObjectId idOf(JSObject* obj);
      92             : 
      93             :   private:
      94             :     ObjectId idOfUnchecked(JSObject* obj);
      95             : 
      96             :     bool getPropertyKeys(JSContext* cx, JS::HandleObject proxy, uint32_t flags,
      97             :                          JS::AutoIdVector& props);
      98             : 
      99             :     // Catastrophic IPC failure.
     100             :     bool ipcfail(JSContext* cx);
     101             : 
     102             :     // Check whether a return status is okay, and if not, propagate its error.
     103             :     //
     104             :     // If 'status' might be a ReturnObjectOpResult, which is only possible for
     105             :     // a subset of the operations below, 'result' must be passed.
     106             :     bool ok(JSContext* cx, const ReturnStatus& status, JS::ObjectOpResult& result);
     107             :     bool ok(JSContext* cx, const ReturnStatus& status);
     108             : 
     109             :     bool inactive_;
     110             : 
     111             :     /*** Dummy call handlers ***/
     112             :   public:
     113             :     virtual bool SendDropObject(const ObjectId& objId) = 0;
     114             :     virtual bool SendPreventExtensions(const ObjectId& objId, ReturnStatus* rs) = 0;
     115             :     virtual bool SendGetPropertyDescriptor(const ObjectId& objId, const JSIDVariant& id,
     116             :                                            ReturnStatus* rs,
     117             :                                            PPropertyDescriptor* out) = 0;
     118             :     virtual bool SendGetOwnPropertyDescriptor(const ObjectId& objId,
     119             :                                               const JSIDVariant& id,
     120             :                                               ReturnStatus* rs,
     121             :                                               PPropertyDescriptor* out) = 0;
     122             :     virtual bool SendDefineProperty(const ObjectId& objId, const JSIDVariant& id,
     123             :                                     const PPropertyDescriptor& flags,
     124             :                                     ReturnStatus* rs) = 0;
     125             :     virtual bool SendDelete(const ObjectId& objId, const JSIDVariant& id,
     126             :                             ReturnStatus* rs) = 0;
     127             : 
     128             :     virtual bool SendHas(const ObjectId& objId, const JSIDVariant& id,
     129             :                          ReturnStatus* rs, bool* bp) = 0;
     130             :     virtual bool SendHasOwn(const ObjectId& objId, const JSIDVariant& id,
     131             :                             ReturnStatus* rs, bool* bp) = 0;
     132             :     virtual bool SendGet(const ObjectId& objId, const JSVariant& receiverVar,
     133             :                          const JSIDVariant& id,
     134             :                          ReturnStatus* rs, JSVariant* result) = 0;
     135             :     virtual bool SendSet(const ObjectId& objId, const JSIDVariant& id, const JSVariant& value,
     136             :                          const JSVariant& receiverVar, ReturnStatus* rs) = 0;
     137             : 
     138             :     virtual bool SendIsExtensible(const ObjectId& objId, ReturnStatus* rs,
     139             :                                   bool* result) = 0;
     140             :     virtual bool SendCallOrConstruct(const ObjectId& objId, const nsTArray<JSParam>& argv,
     141             :                                      const bool& construct, ReturnStatus* rs, JSVariant* result,
     142             :                                      nsTArray<JSParam>* outparams) = 0;
     143             :     virtual bool SendHasInstance(const ObjectId& objId, const JSVariant& v,
     144             :                                  ReturnStatus* rs, bool* bp) = 0;
     145             :     virtual bool SendGetBuiltinClass(const ObjectId& objId, ReturnStatus* rs,
     146             :                                      uint32_t* classValue) = 0;
     147             :     virtual bool SendIsArray(const ObjectId& objId, ReturnStatus* rs,
     148             :                              uint32_t* answer) = 0;
     149             :     virtual bool SendClassName(const ObjectId& objId, nsCString* result) = 0;
     150             :     virtual bool SendGetPrototype(const ObjectId& objId, ReturnStatus* rs, ObjectOrNullVariant* result) = 0;
     151             :     virtual bool SendGetPrototypeIfOrdinary(const ObjectId& objId, ReturnStatus* rs, bool* isOrdinary,
     152             :                                             ObjectOrNullVariant* result) = 0;
     153             :     virtual bool SendRegExpToShared(const ObjectId& objId, ReturnStatus* rs, nsString* source,
     154             :                                     uint32_t* flags) = 0;
     155             : 
     156             :     virtual bool SendGetPropertyKeys(const ObjectId& objId, const uint32_t& flags,
     157             :                                      ReturnStatus* rs, nsTArray<JSIDVariant>* ids) = 0;
     158             :     virtual bool SendInstanceOf(const ObjectId& objId, const JSIID& iid,
     159             :                                 ReturnStatus* rs, bool* instanceof) = 0;
     160             :     virtual bool SendDOMInstanceOf(const ObjectId& objId, const int& prototypeID, const int& depth,
     161             :                                    ReturnStatus* rs, bool* instanceof) = 0;
     162             : };
     163             : 
     164             : } // namespace jsipc
     165             : } // namespace mozilla
     166             : 
     167             : #endif // mozilla_jsipc_WrapperOwner_h__

Generated by: LCOV version 1.13