Reland: Move the event attach/detach logic on unload from event.js to event_bindings.cc.
Original patch: https://codereview.chromium.org/1074273002.
Move the event attach/detach logic on unload from event.js to
event_bindings.cc.
This removes one of the reasons to call into JavaScript on context unload,
which can crash. It's also more robust; it's confusing trying to maintain a
data structure in JavaScript which reflects C++ state, which contributes to
bugs like crbug.com/474718.
Also clean up and formalise the script context invalidation system: CHECK
rather than guarding against multiple invalidations, only invalidate script
context related member variables, add an invalidation observer interface.
BUG=474718, 475536
[email protected]
Review URL: https://codereview.chromium.org/1057003005
Cr-Commit-Position: refs/heads/master@{#325156}
diff --git a/extensions/renderer/object_backed_native_handler.h b/extensions/renderer/object_backed_native_handler.h
index 7fe4b1f..843e13b 100644
--- a/extensions/renderer/object_backed_native_handler.h
+++ b/extensions/renderer/object_backed_native_handler.h
@@ -38,6 +38,10 @@
// Installs a new 'route' from |name| to |handler_function|. This means that
// NewInstance()s of this ObjectBackedNativeHandler will have a property
// |name| which will be handled by |handler_function|.
+ //
+ // Routed functions are destroyed along with the destruction of this class,
+ // and are never called back into, therefore it's safe for |handler_function|
+ // to bind to base::Unretained.
void RouteFunction(const std::string& name,
const HandlerFunction& handler_function);