private void OnAddListener(CefBrowser browser, PluginMessage pluginMessage, JavaScriptPlugin handler)
        {
            var info = CreateAndAddCall(browser, pluginMessage, handler, null);

            if (!handler.IsValid)
            {
                RemoveAndCancelCall(info);
                return;
            }

            var handled = handler.AddEventListener(pluginMessage.MemberName, info);

            if (!handled)
            {
                RemoveAndCancelCall(info);
            }
        }
        /// <summary>
        /// Add a local V8 callback to a local event as a listener.
        /// </summary>
        /// <param name="context">
        /// The current V8 context that is adding the listener.
        /// </param>
        /// <param name="targetPlugin">
        /// The local plugin that owns the event.
        /// </param>
        /// <param name="eventName">
        /// The name of the event to attach to.
        /// </param>
        /// <param name="callback">
        /// The callback to V8 to invoke when the event is raised.
        /// </param>
        public void AddEventListener(CefV8Context context, JavaScriptPlugin targetPlugin, string eventName, IV8Callback callback)
        {
            Logger.Info("AddEventListener Local Plugin {0} Event {1}", targetPlugin.Descriptor.PluginId, eventName);

            if (!EnsureOnRendererThread())
            {
                return;
            }

            if (!targetPlugin.IsValid)
            {
                Logger.Warn("AddEventListener Local Plugin {0} is invalid", targetPlugin.Descriptor.PluginId);
                if (callback != null)
                {
                    callback.Invoke(this, context, null, CallInfo.ErrorCodeCallCanceled, CallInfo.ErrorCallCanceled);
                }
                return;
            }

            var addListenerMessage = CreateMessage(context, targetPlugin.Descriptor, eventName, callback);

            addListenerMessage.MessageId   = callback.Identifier;
            addListenerMessage.MessageType = PluginMessageType.AddListener;

            // Add the call info into the pending calls for the browser
            var info = AddLocalCallback(addListenerMessage, callback, null);

            try
            {
                targetPlugin.AddEventListener(eventName, info);
            }
            catch (Exception ex)
            {
                // Remove listener from calls cache
                _pendingCallbacks.Remove(info);
                info.Dispose();
                Logger.Error("AddEventListener Failed Local Plugin {0} Event {1}: {2}", targetPlugin.Descriptor.PluginId, eventName, ex);
            }
        }