js/ipc/JavaScriptParent.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=4 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/. */
     8 #ifndef mozilla_jsipc_JavaScriptParent__
     9 #define mozilla_jsipc_JavaScriptParent__
    11 #include "JavaScriptShared.h"
    12 #include "mozilla/jsipc/PJavaScriptParent.h"
    13 #include "js/Class.h"
    15 #ifdef XP_WIN
    16 #undef GetClassName
    17 #undef GetClassInfo
    18 #endif
    20 namespace mozilla {
    21 namespace jsipc {
    23 class JavaScriptParent
    24   : public PJavaScriptParent,
    25     public JavaScriptShared
    26 {
    27   public:
    28     JavaScriptParent();
    30     bool init();
    32   public:
    33     // Fundamental proxy traps. These are required.
    34     // (The traps should be in the same order like js/src/jsproxy.h)
    35     bool preventExtensions(JSContext *cx, JS::HandleObject proxy);
    36     bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
    37                                JS::MutableHandle<JSPropertyDescriptor> desc);
    38     bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
    39                                   JS::MutableHandle<JSPropertyDescriptor> desc);
    40     bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id,
    41                         JS::MutableHandle<JSPropertyDescriptor> desc);
    42     bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
    43     bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
    44     bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
    46     // Derived proxy traps. Implementing these is useful for perfomance.
    47     bool has(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
    48     bool hasOwn(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp);
    49     bool get(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
    50              JS::HandleId id, JS::MutableHandleValue vp);
    51     bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver,
    52              JS::HandleId id, bool strict, JS::MutableHandleValue vp);
    53     bool keys(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props);
    54     // We use "iterate" provided by the base class here.
    56     // SpiderMonkey Extensions.
    57     bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible);
    58     bool call(JSContext *cx, JS::HandleObject proxy, const JS::CallArgs &args);
    59     bool objectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue);
    60     const char* className(JSContext *cx, JS::HandleObject proxy);
    62     virtual void ActorDestroy(ActorDestroyReason why);
    64     void decref();
    65     void incref();
    67     bool active() { return !inactive_; }
    69     void drop(JSObject *obj);
    71     static bool IsCPOW(JSObject *obj);
    73     static nsresult InstanceOf(JSObject *obj, const nsID *id, bool *bp);
    74     nsresult instanceOf(JSObject *obj, const nsID *id, bool *bp);
    76     /*
    77      * Check that |obj| is a DOM wrapper whose prototype chain contains
    78      * |prototypeID| at depth |depth|.
    79      */
    80     static bool DOMInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
    81     bool domInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp);
    83     mozilla::ipc::IProtocol*
    84     CloneProtocol(Channel* aChannel, ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
    86   protected:
    87     JSObject *unwrap(JSContext *cx, ObjectId objId);
    89   private:
    90     bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp);
    91     bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags,
    92                           JS::AutoIdVector &props);
    93     ObjectId idOf(JSObject *obj);
    95     // Catastrophic IPC failure.
    96     bool ipcfail(JSContext *cx);
    98     // Check whether a return status is okay, and if not, propagate its error.
    99     bool ok(JSContext *cx, const ReturnStatus &status);
   101   private:
   102     uintptr_t refcount_;
   103     bool inactive_;
   104 };
   106 } // jsipc
   107 } // mozilla
   109 #endif // mozilla_jsipc_JavaScriptWrapper_h__

mercurial