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

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

Issue 200116: Fix bug where content scripts can get GC'd if they don't attach (Closed)
Patch Set: remove extra braces Created 11 years, 3 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: chrome/renderer/extensions/bindings_utils.h
diff --git a/chrome/renderer/extensions/bindings_utils.h b/chrome/renderer/extensions/bindings_utils.h
index 7354c7282cab5cb060f634a91d94518b7af169c2..b0b3f086375ba5aebee6c7fe88d6d25f558288c3 100644
--- a/chrome/renderer/extensions/bindings_utils.h
+++ b/chrome/renderer/extensions/bindings_utils.h
@@ -68,12 +68,17 @@ struct ContextInfo {
// a valid pointer, and is used for comparisons only. Do not dereference.
RenderView* render_view;
+ // A count of the number of events that are listening in this context. When
+ // this is zero, |context| will be a weak handle.
+ int num_connected_events;
+
ContextInfo(v8::Persistent<v8::Context> context,
const std::string& extension_id,
v8::Persistent<v8::Context> parent_context,
RenderView* render_view)
: context(context), extension_id(extension_id),
- parent_context(parent_context), render_view(render_view) {}
+ parent_context(parent_context), render_view(render_view),
+ num_connected_events(0) {}
};
typedef std::list< linked_ptr<ContextInfo> > ContextList;
@@ -86,6 +91,9 @@ ContextList GetContextsForExtension(const std::string& extension_id);
// Returns the ContextInfo item that has the given context.
ContextList::iterator FindContext(v8::Handle<v8::Context> context);
+// Returns the ContextInfo for the current v8 context.
+ContextInfo* GetInfoForCurrentContext();
+
// Contains info relevant to a pending API request.
struct PendingRequest {
public :
« no previous file with comments | « no previous file | chrome/renderer/extensions/bindings_utils.cc » ('j') | chrome/renderer/extensions/event_bindings.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698