1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sw=4 et tw=80:
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_WrapperOwner_h__
9 #define mozilla_jsipc_WrapperOwner_h__
11 #include "JavaScriptShared.h"
12 #include "mozilla/ipc/ProtocolUtils.h"
24 class WrapperOwner
: public virtual JavaScriptShared
27 typedef mozilla::ipc::IProtocolManager
<
28 mozilla::ipc::IProtocol
>::ActorDestroyReason
31 explicit WrapperOwner(JSRuntime
* rt
);
34 // Standard internal methods.
35 // (The traps should be in the same order like js/src/jsproxy.h)
36 bool getOwnPropertyDescriptor(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
,
37 JS::MutableHandle
<JSPropertyDescriptor
> desc
);
38 bool defineProperty(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
,
39 JS::MutableHandle
<JSPropertyDescriptor
> desc
);
40 bool ownPropertyKeys(JSContext
* cx
, JS::HandleObject proxy
, JS::AutoIdVector
& props
);
41 bool delete_(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
, bool* bp
);
42 bool preventExtensions(JSContext
* cx
, JS::HandleObject proxy
, bool* succeeded
);
43 bool isExtensible(JSContext
* cx
, JS::HandleObject proxy
, bool* extensible
);
44 bool has(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
, bool* bp
);
45 bool get(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleObject receiver
,
46 JS::HandleId id
, JS::MutableHandleValue vp
);
47 bool set(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleObject receiver
,
48 JS::HandleId id
, bool strict
, JS::MutableHandleValue vp
);
49 bool callOrConstruct(JSContext
* cx
, JS::HandleObject proxy
, const JS::CallArgs
& args
,
52 // SpiderMonkey extensions.
53 bool getPropertyDescriptor(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
,
54 JS::MutableHandle
<JSPropertyDescriptor
> desc
);
55 bool hasOwn(JSContext
* cx
, JS::HandleObject proxy
, JS::HandleId id
, bool* bp
);
56 bool getOwnEnumerablePropertyKeys(JSContext
* cx
, JS::HandleObject proxy
,
57 JS::AutoIdVector
& props
);
58 bool hasInstance(JSContext
* cx
, JS::HandleObject proxy
, JS::MutableHandleValue v
, bool* bp
);
59 bool objectClassIs(JSContext
* cx
, JS::HandleObject obj
, js::ESClassValue classValue
);
60 const char* className(JSContext
* cx
, JS::HandleObject proxy
);
61 bool regexp_toShared(JSContext
* cx
, JS::HandleObject proxy
, js::RegExpGuard
* g
);
63 nsresult
instanceOf(JSObject
* obj
, const nsID
* id
, bool* bp
);
65 bool toString(JSContext
* cx
, JS::HandleObject callee
, JS::CallArgs
& args
);
68 * Check that |obj| is a DOM wrapper whose prototype chain contains
69 * |prototypeID| at depth |depth|.
71 bool domInstanceOf(JSContext
* cx
, JSObject
* obj
, int prototypeID
, int depth
, bool* bp
);
73 bool active() { return !inactive_
; }
75 void drop(JSObject
* obj
);
76 void updatePointer(JSObject
* obj
, const JSObject
* old
);
78 virtual void ActorDestroy(ActorDestroyReason why
);
80 virtual bool toObjectVariant(JSContext
* cx
, JSObject
* obj
, ObjectVariant
* objVarp
);
81 virtual JSObject
* fromObjectVariant(JSContext
* cx
, ObjectVariant objVar
);
82 JSObject
* fromRemoteObjectVariant(JSContext
* cx
, RemoteObject objVar
);
83 JSObject
* fromLocalObjectVariant(JSContext
* cx
, LocalObject objVar
);
86 ObjectId
idOf(JSObject
* obj
);
89 ObjectId
idOfUnchecked(JSObject
* obj
);
91 bool getPropertyKeys(JSContext
* cx
, JS::HandleObject proxy
, uint32_t flags
,
92 JS::AutoIdVector
& props
);
94 // Catastrophic IPC failure.
95 bool ipcfail(JSContext
* cx
);
97 // Check whether a return status is okay, and if not, propagate its error.
98 bool ok(JSContext
* cx
, const ReturnStatus
& status
);
102 /*** Dummy call handlers ***/
104 virtual bool SendDropObject(const ObjectId
& objId
) = 0;
105 virtual bool SendPreventExtensions(const ObjectId
& objId
, ReturnStatus
* rs
,
106 bool* succeeded
) = 0;
107 virtual bool SendGetPropertyDescriptor(const ObjectId
& objId
, const JSIDVariant
& id
,
109 PPropertyDescriptor
* out
) = 0;
110 virtual bool SendGetOwnPropertyDescriptor(const ObjectId
& objId
,
111 const JSIDVariant
& id
,
113 PPropertyDescriptor
* out
) = 0;
114 virtual bool SendDefineProperty(const ObjectId
& objId
, const JSIDVariant
& id
,
115 const PPropertyDescriptor
& flags
,
116 ReturnStatus
* rs
) = 0;
117 virtual bool SendDelete(const ObjectId
& objId
, const JSIDVariant
& id
,
118 ReturnStatus
* rs
, bool* success
) = 0;
120 virtual bool SendHas(const ObjectId
& objId
, const JSIDVariant
& id
,
121 ReturnStatus
* rs
, bool* bp
) = 0;
122 virtual bool SendHasOwn(const ObjectId
& objId
, const JSIDVariant
& id
,
123 ReturnStatus
* rs
, bool* bp
) = 0;
124 virtual bool SendGet(const ObjectId
& objId
, const ObjectVariant
& receiverVar
,
125 const JSIDVariant
& id
,
126 ReturnStatus
* rs
, JSVariant
* result
) = 0;
127 virtual bool SendSet(const ObjectId
& objId
, const ObjectVariant
& receiverVar
,
128 const JSIDVariant
& id
, const bool& strict
,
129 const JSVariant
& value
, ReturnStatus
* rs
, JSVariant
* result
) = 0;
131 virtual bool SendIsExtensible(const ObjectId
& objId
, ReturnStatus
* rs
,
133 virtual bool SendCallOrConstruct(const ObjectId
& objId
, const nsTArray
<JSParam
>& argv
,
134 const bool& construct
, ReturnStatus
* rs
, JSVariant
* result
,
135 nsTArray
<JSParam
>* outparams
) = 0;
136 virtual bool SendHasInstance(const ObjectId
& objId
, const JSVariant
& v
,
137 ReturnStatus
* rs
, bool* bp
) = 0;
138 virtual bool SendObjectClassIs(const ObjectId
& objId
, const uint32_t& classValue
,
140 virtual bool SendClassName(const ObjectId
& objId
, nsString
* result
) = 0;
141 virtual bool SendRegExpToShared(const ObjectId
& objId
, ReturnStatus
* rs
, nsString
* source
,
142 uint32_t* flags
) = 0;
144 virtual bool SendGetPropertyKeys(const ObjectId
& objId
, const uint32_t& flags
,
145 ReturnStatus
* rs
, nsTArray
<JSIDVariant
>* ids
) = 0;
146 virtual bool SendInstanceOf(const ObjectId
& objId
, const JSIID
& iid
,
147 ReturnStatus
* rs
, bool* instanceof
) = 0;
148 virtual bool SendDOMInstanceOf(const ObjectId
& objId
, const int& prototypeID
, const int& depth
,
149 ReturnStatus
* rs
, bool* instanceof
) = 0;
153 IsCPOW(JSObject
* obj
);
156 IsWrappedCPOW(JSObject
* obj
);
159 InstanceOf(JSObject
* obj
, const nsID
* id
, bool* bp
);
162 DOMInstanceOf(JSContext
* cx
, JSObject
* obj
, int prototypeID
, int depth
, bool* bp
);
165 GetWrappedCPOWTag(JSObject
* obj
, nsACString
& out
);
170 #endif // mozilla_jsipc_WrapperOwner_h__