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

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

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: . 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
Index: extensions/renderer/bindings/api_binding.cc
diff --git a/extensions/renderer/bindings/api_binding.cc b/extensions/renderer/bindings/api_binding.cc
index e69eccab892f4b353b29b5c5192d380ccfb0b138..0c487ec1c42e61785d88c2e1f0fffcca256e0374 100644
--- a/extensions/renderer/bindings/api_binding.cc
+++ b/extensions/renderer/bindings/api_binding.cc
@@ -107,6 +107,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,
@@ -116,6 +117,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)),
@@ -134,6 +136,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;
@@ -282,6 +287,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;
@@ -314,12 +320,20 @@ APIBinding::APIBinding(const std::string& api_name,
bool unmanaged = false;
if (options->GetBoolean("unmanaged", &unmanaged))
notify_on_change = !unmanaged;
+ bool temp_supports_lazy_listeners = false;
jbroman 2017/07/10 15:33:02 nit: Why is it so bad that we have to prevent "sup
lazyboy 2017/07/14 00:04:42 I like it this way though: API schema owners need
Devlin 2017/07/14 15:37:54 I think jbroman@ was just saying that it seems exc
lazyboy 2017/07/17 23:38:50 Sure, I thought it was to consider removing the re
+ if (options->GetBoolean("supportsLazyListeners",
+ &temp_supports_lazy_listeners)) {
+ DCHECK(!temp_supports_lazy_listeners)
+ << "Don't specify supportsLazyListeners: true; it's the default.";
+ supports_lazy_listeners = false;
+ }
}
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));
}
}
}
@@ -501,7 +515,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);
}

Powered by Google App Engine
This is Rietveld 408576698