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

Unified Diff: chrome/renderer/extensions/object_backed_native_handler.h

Issue 12693008: Prevent ObjectBackedNativeHandler from calling itself once invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | « chrome/chrome_tests.gypi ('k') | chrome/renderer/extensions/object_backed_native_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/object_backed_native_handler.h
diff --git a/chrome/renderer/extensions/object_backed_native_handler.h b/chrome/renderer/extensions/object_backed_native_handler.h
index 16ebe55e545bbb3e88c318395e84a1d854786143..76d2b950697d67f295328ee9fe99e470709b4793 100644
--- a/chrome/renderer/extensions/object_backed_native_handler.h
+++ b/chrome/renderer/extensions/object_backed_native_handler.h
@@ -40,18 +40,32 @@ class ObjectBackedNativeHandler : public NativeHandler {
const HandlerFunction& handler_function);
void RouteStaticFunction(const std::string& name,
- const HandlerFunc handler_func);
+ const HandlerFunc& handler_func);
v8::Handle<v8::Context> v8_context() { return v8_context_.get(); }
virtual void Invalidate() OVERRIDE;
private:
-
+ // Callback for RouteFunction which routes the V8 call to the correct
+ // base::Bound callback.
static v8::Handle<v8::Value> Router(const v8::Arguments& args);
- struct RouterData;
- std::vector<linked_ptr<RouterData> > router_data_;
+ // When RouteFunction is called we create a v8::Object to hold the data we
+ // need when handling it in Router() - this is the base::Bound function to
+ // route to.
+ //
+ // We need a v8::Object because it's possible for v8 to outlive the
+ // base::Bound function; the lifetime of an ObjectBackedNativeHandler is the
+ // lifetime of webkit's involvement with it, not the life of the v8 context.
+ // A scenario when v8 will outlive us is if a frame holds onto the
+ // contentWindow of an iframe after it's removed.
+ //
+ // So, we use v8::Objects here to hold that data, effectively refcounting
+ // the data. When |this| is destroyed we remove the base::Bound function from
+ // the object to indicate that it shoudn't be called.
+ typedef std::vector<v8::Persistent<v8::Object> > RouterData;
+ RouterData router_data_;
// TODO(kalman): Just pass around a ChromeV8Context. It already has a
// persistent handle to this context.
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/renderer/extensions/object_backed_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698