/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** * Base class for RemoteObjectProxy. Implements the pieces of the handler that * don't depend on properties/methods of the specific WebIDL interface that this * proxy implements.
*/ class RemoteObjectProxyBase : public js::BaseProxyHandler, public MaybeCrossOriginObjectMixins { protected: explicit constexpr RemoteObjectProxyBase(prototypes::ID aPrototypeID)
: BaseProxyHandler(&sCrossOriginProxyFamily, false),
mPrototypeID(aPrototypeID) {}
public: bool finalizeInBackground(const JS::Value& priv) const final { returnfalse; }
// Cross origin objects like RemoteWindowProxy should not participate in // private fields. virtualbool throwOnPrivateField() const override { returntrue; }
bool isCallable(JSObject* aObj) const final { returnfalse; } bool isConstructor(JSObject* aObj) const final { returnfalse; }
/** * Returns true if aProxy is a cross-process proxy that represents * an object implementing the WebIDL interface for aProtoID. aProxy * should be a proxy object.
*/ staticinlinebool IsRemoteObjectProxy(JSObject* aProxy,
prototypes::ID aProtoID) { const js::BaseProxyHandler* handler = js::GetProxyHandler(aProxy); return handler->family() == &sCrossOriginProxyFamily && static_cast<const RemoteObjectProxyBase*>(handler)->mPrototypeID ==
aProtoID;
}
/** * Returns true if aProxy is a cross-process proxy, no matter which * interface it represents. aProxy should be a proxy object.
*/ staticinlinebool IsRemoteObjectProxy(JSObject* aProxy) { const js::BaseProxyHandler* handler = js::GetProxyHandler(aProxy); return handler->family() == &sCrossOriginProxyFamily;
}
protected: /** * Gets an existing cached proxy object, or creates a new one and caches it. * aProxy will be null on failure. aNewObjectCreated is set to true if a new * object was created, callers probably need to addref the native in that * case. aNewObjectCreated can be true even if aProxy is null, if something * failed after creating the object. * * If aTransplantTo is non-null, failure is assumed to be unrecoverable, so * this will crash.
*/ void GetOrCreateProxyObject(JSContext* aCx, void* aNative, const JSClass* aClasp,
JS::Handle<JSObject*> aTransplantTo,
JS::MutableHandle<JSObject*> aProxy, bool& aNewObjectCreated) const;
/** * Proxy handler for proxy objects that represent an object implementing a * WebIDL interface that has cross-origin accessible properties/methods, and * which lives in a different process. The WebIDL code generator will create * arrays of cross-origin accessible properties/methods that can be used as * arguments to this template. * * The properties and methods can be cached on a holder JSObject, stored in a * reserved slot on the proxy object. * * The proxy objects that use a handler derived from this one are stored in a * hash map in the JS compartment's private (@see * xpc::CompartmentPrivate::GetRemoteProxyMap).
*/ template <class Native, const CrossOriginProperties& P> class RemoteObjectProxy : public RemoteObjectProxyBase { public: void finalize(JS::GCContext* aGcx, JSObject* aProxy) const final { auto native = static_cast<Native*>(GetNative(aProxy));
RefPtr<Native> self(dont_AddRef(native));
}
/** * Returns true if aObj is a cross-process proxy object that * represents an object implementing the WebIDL interface for * aProtoID.
*/ inlinebool IsRemoteObjectProxy(JSObject* aObj, prototypes::ID aProtoID) { if (!js::IsProxy(aObj)) { returnfalse;
} return RemoteObjectProxyBase::IsRemoteObjectProxy(aObj, aProtoID);
}
/** * Returns true if aObj is a cross-process proxy object, no matter * which WebIDL interface it corresponds to.
*/ inlinebool IsRemoteObjectProxy(JSObject* aObj) { if (!js::IsProxy(aObj)) { returnfalse;
} return RemoteObjectProxyBase::IsRemoteObjectProxy(aObj);
}
/** * Return the browsing context for this remote outer window proxy. * Only call this function on remote outer window proxies.
*/
BrowsingContext* GetBrowsingContext(JSObject* aProxy);
} // namespace mozilla::dom
#endif/* mozilla_dom_RemoteObjectProxy_h */
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.