private LocalRenderCallInfo GetOrCreateParameterCallback(CefV8Context context, MethodDescriptor methodDescriptor, IV8Callback callback) { LocalRenderCallInfo parameterCallbackInfo = null; if (methodDescriptor.HasCallbackParameter && callback != null) { // Create a second stored callback info which represents the V8 callback function itself // rather than the method that is being invoked now. This allows the callback function // to be passed to and invoked by multiple native methods that accept a callback parameter. parameterCallbackInfo = (LocalRenderCallInfo)_pendingCallbacks.Get(callback.Identifier); if (parameterCallbackInfo == null) { var parameterCallbackMessage = new PluginMessage { MessageId = callback.Identifier, MessageType = PluginMessageType.ParameterCallback, PluginId = string.Empty, MemberName = string.Empty, BrowserId = context.GetBrowserId(), ContextId = GetIdForContext(context, false), FrameId = context.GetFrame().Identifier, V8CallbackId = Guid.Empty }; parameterCallbackInfo = AddLocalCallback(parameterCallbackMessage, callback, null); } } return(parameterCallbackInfo); }
private PluginMessage CreateMessage( CefV8Context context, PluginDescriptor targetPlugin, string memberName, IV8Callback callback) { var message = new PluginMessage { PluginId = targetPlugin.PluginId, MemberName = memberName, BrowserId = context.GetBrowserId(), ContextId = GetIdForContext(context, false), FrameId = context.GetFrame().Identifier, V8CallbackId = callback != null ? callback.Identifier : Guid.Empty }; return(message); }