#include "extensions/renderer/bindings/event_emitter.h"
#include <algorithm>
#include <utility>
#include "extensions/common/mojom/event_dispatcher.mojom.h"
#include "extensions/renderer/bindings/api_binding_util.h"
#include "extensions/renderer/bindings/api_event_listeners.h"
#include "extensions/renderer/bindings/exception_handler.h"
#include "gin/data_object_builder.h"
#include "gin/object_template_builder.h"
#include "gin/per_context_data.h"
namespace extensions {
namespace {
constexpr const char kEmitterKey[] = …;
constexpr const char kArgumentsKey[] = …;
constexpr const char kFilterKey[] = …;
constexpr const char kEventEmitterTypeName[] = …;
}
gin::WrapperInfo EventEmitter::kWrapperInfo = …;
EventEmitter::EventEmitter(bool supports_filters,
std::unique_ptr<APIEventListeners> listeners,
ExceptionHandler* exception_handler)
: … { … }
EventEmitter::~EventEmitter() = default;
gin::ObjectTemplateBuilder EventEmitter::GetObjectTemplateBuilder(
v8::Isolate* isolate) { … }
const char* EventEmitter::GetTypeName() { … }
void EventEmitter::Fire(v8::Local<v8::Context> context,
v8::LocalVector<v8::Value>* args,
mojom::EventFilteringInfoPtr filter,
JSRunner::ResultCallback callback) { … }
v8::Local<v8::Value> EventEmitter::FireSync(
v8::Local<v8::Context> context,
v8::LocalVector<v8::Value>* args,
mojom::EventFilteringInfoPtr filter) { … }
void EventEmitter::Invalidate(v8::Local<v8::Context> context) { … }
size_t EventEmitter::GetNumListeners() const { … }
int EventEmitter::PushFilter(mojom::EventFilteringInfoPtr filter) { … }
mojom::EventFilteringInfoPtr EventEmitter::PopFilter(int filter_id) { … }
void EventEmitter::AddListener(gin::Arguments* arguments) { … }
void EventEmitter::RemoveListener(gin::Arguments* arguments) { … }
bool EventEmitter::HasListener(v8::Local<v8::Function> listener) { … }
bool EventEmitter::HasListeners() { … }
void EventEmitter::Dispatch(gin::Arguments* arguments) { … }
v8::Local<v8::Value> EventEmitter::DispatchSync(
v8::Local<v8::Context> context,
v8::LocalVector<v8::Value>* args,
mojom::EventFilteringInfoPtr filter) { … }
void EventEmitter::DispatchAsync(v8::Local<v8::Context> context,
v8::LocalVector<v8::Value>* args,
mojom::EventFilteringInfoPtr filter,
JSRunner::ResultCallback callback) { … }
void EventEmitter::DispatchAsyncHelper(
const v8::FunctionCallbackInfo<v8::Value>& info) { … }
}