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

Unified Diff: extensions/renderer/script_context.h

Issue 1074273002: Move the event attach/detach logic on unload from event.js to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: being process of relanding - more test assertions Created 5 years, 8 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/renderer/resources/event.js ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/script_context.h
diff --git a/extensions/renderer/script_context.h b/extensions/renderer/script_context.h
index b6c90f2c46f765723452a0450291768c6fc3ba6f..10901e3efab3f1e874524b889e08d4e20b8c860d 100644
--- a/extensions/renderer/script_context.h
+++ b/extensions/renderer/script_context.h
@@ -6,8 +6,10 @@
#define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
#include <string>
+#include <vector>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/permissions/api_permission_set.h"
@@ -45,9 +47,13 @@ class ScriptContext : public RequestSender::Source {
// ModuleSystem.
void Invalidate();
+ // Registers |observer| to be run when this context is invalidated. Closures
+ // are run immediately when Invalidate() is called, not in a message loop.
+ void AddInvalidationObserver(const base::Closure& observer);
+
// Returns true if this context is still valid, false if it isn't.
// A context becomes invalid via Invalidate().
- bool is_valid() const { return !v8_context_.IsEmpty(); }
+ bool is_valid() const { return is_valid_; }
v8::Handle<v8::Context> v8_context() const {
return v8::Local<v8::Context>::New(isolate_, v8_context_);
@@ -150,13 +156,15 @@ class ScriptContext : public RequestSender::Source {
// extension.
bool HasAPIPermission(APIPermission::ID permission) const;
- protected:
- // The v8 context the bindings are accessible to.
- v8::Global<v8::Context> v8_context_;
-
private:
class Runner;
+ // Whether this context is valid.
+ bool is_valid_;
+
+ // The v8 context the bindings are accessible to.
+ v8::Global<v8::Context> v8_context_;
+
// The WebFrame associated with this context. This can be NULL because this
// object can outlive is destroyed asynchronously.
blink::WebFrame* web_frame_;
@@ -185,6 +193,10 @@ class ScriptContext : public RequestSender::Source {
// The set of capabilities granted to this context by extensions.
APIPermissionSet content_capabilities_;
+ // A list of base::Closure instances as an observer interface for
+ // invalidation.
+ std::vector<base::Closure> invalidate_observers_;
+
v8::Isolate* isolate_;
GURL url_;
« no previous file with comments | « extensions/renderer/resources/event.js ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698