Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: extensions/renderer/bindings/api_binding.cc

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/event_router.cc ('k') | extensions/renderer/bindings/api_binding_js_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/bindings/api_binding.cc
diff --git a/extensions/renderer/bindings/api_binding.cc b/extensions/renderer/bindings/api_binding.cc
index b1d0169cd934f1893eff6c00c8c9835714f87eb0..e0a52740836a888799be97837d89af986923747c 100644
--- a/extensions/renderer/bindings/api_binding.cc
+++ b/extensions/renderer/bindings/api_binding.cc
@@ -108,6 +108,7 @@ struct APIBinding::EventData {
std::string full_name,
bool supports_filters,
bool supports_rules,
+ bool supports_lazy_listeners,
int max_listeners,
bool notify_on_change,
std::vector<std::string> actions,
@@ -117,6 +118,7 @@ struct APIBinding::EventData {
full_name(std::move(full_name)),
supports_filters(supports_filters),
supports_rules(supports_rules),
+ supports_lazy_listeners(supports_lazy_listeners),
max_listeners(max_listeners),
notify_on_change(notify_on_change),
actions(std::move(actions)),
@@ -135,6 +137,9 @@ struct APIBinding::EventData {
// Whether the event supports rules.
bool supports_rules;
+ // Whether the event supports lazy listeners.
+ bool supports_lazy_listeners;
+
// The maximum number of listeners this event supports.
int max_listeners;
@@ -285,6 +290,7 @@ APIBinding::APIBinding(const std::string& api_name,
const base::DictionaryValue* options = nullptr;
bool supports_rules = false;
bool notify_on_change = true;
+ bool supports_lazy_listeners = true;
int max_listeners = binding::kNoListenerMax;
if (event_dict->GetDictionary("options", &options)) {
bool temp_supports_filters = false;
@@ -317,12 +323,18 @@ APIBinding::APIBinding(const std::string& api_name,
bool unmanaged = false;
if (options->GetBoolean("unmanaged", &unmanaged))
notify_on_change = !unmanaged;
+ if (options->GetBoolean("supportsLazyListeners",
+ &supports_lazy_listeners)) {
+ DCHECK(!supports_lazy_listeners)
+ << "Don't specify supportsLazyListeners: true; it's the default.";
+ }
}
events_.push_back(base::MakeUnique<EventData>(
std::move(name), std::move(full_name), supports_filters,
- supports_rules, max_listeners, notify_on_change,
- std::move(rule_actions), std::move(rule_conditions), this));
+ supports_rules, supports_lazy_listeners, max_listeners,
+ notify_on_change, std::move(rule_actions), std::move(rule_conditions),
+ this));
}
}
}
@@ -521,7 +533,8 @@ void APIBinding::GetEventObject(
} else {
retval = event_data->binding->event_handler_->CreateEventInstance(
event_data->full_name, event_data->supports_filters,
- event_data->max_listeners, event_data->notify_on_change, context);
+ event_data->supports_lazy_listeners, event_data->max_listeners,
+ event_data->notify_on_change, context);
}
info.GetReturnValue().Set(retval);
}
« no previous file with comments | « extensions/browser/event_router.cc ('k') | extensions/renderer/bindings/api_binding_js_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698