Revert of Move the event attach/detach logic on unload from event.js to (patchset #7 id:130001 of https://codereview.chromium.org/1074273002/)
Reason for revert:
This is breaking ExtensionApiTest.EventsAreUnregistered on Win7 Dedubg bots.
See:
https://build.chromium.org/p/chromium.webkit/builders/Win7%20%28dbg%29/builds/16162
Original issue's description:
> 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]
>
> Committed: https://crrev.com/d99095034d2e88897ae82c8353f3327a3a1d03a5
> Cr-Commit-Position: refs/heads/master@{#324933}
[email protected],[email protected]
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=474718, 475536
Review URL: https://codereview.chromium.org/1083663004
Cr-Commit-Position: refs/heads/master@{#325050}
diff --git a/extensions/renderer/script_context.h b/extensions/renderer/script_context.h
index 10901e3..b6c90f2 100644
--- a/extensions/renderer/script_context.h
+++ b/extensions/renderer/script_context.h
@@ -6,10 +6,8 @@
#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"
@@ -47,13 +45,9 @@
// 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 is_valid_; }
+ bool is_valid() const { return !v8_context_.IsEmpty(); }
v8::Handle<v8::Context> v8_context() const {
return v8::Local<v8::Context>::New(isolate_, v8_context_);
@@ -156,15 +150,13 @@
// extension.
bool HasAPIPermission(APIPermission::ID permission) const;
- private:
- class Runner;
-
- // Whether this context is valid.
- bool is_valid_;
-
+ protected:
// The v8 context the bindings are accessible to.
v8::Global<v8::Context> v8_context_;
+ private:
+ class Runner;
+
// The WebFrame associated with this context. This can be NULL because this
// object can outlive is destroyed asynchronously.
blink::WebFrame* web_frame_;
@@ -193,10 +185,6 @@
// 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_;