| Index: extensions/renderer/script_context.cc
|
| diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
|
| index c3f04faeada19d37dd1d7d7c1f6bd0455e440186..e5677aadb10597498e0b4d5019bc8cc4d084fd8f 100644
|
| --- a/extensions/renderer/script_context.cc
|
| +++ b/extensions/renderer/script_context.cc
|
| @@ -80,8 +80,7 @@
|
| Feature::Context context_type,
|
| const Extension* effective_extension,
|
| Feature::Context effective_context_type)
|
| - : is_valid_(true),
|
| - v8_context_(v8_context->GetIsolate(), v8_context),
|
| + : v8_context_(v8_context->GetIsolate(), v8_context),
|
| web_frame_(web_frame),
|
| extension_(extension),
|
| context_type_(context_type),
|
| @@ -108,34 +107,17 @@
|
| << " extension id: " << GetExtensionID() << "\n"
|
| << " effective extension id: "
|
| << (effective_extension_.get() ? effective_extension_->id() : "");
|
| - CHECK(!is_valid_) << "ScriptContexts must be invalidated before destruction";
|
| + Invalidate();
|
| }
|
|
|
| void ScriptContext::Invalidate() {
|
| - CHECK(is_valid_);
|
| - is_valid_ = false;
|
| -
|
| - // TODO(kalman): Make ModuleSystem use AddInvalidationObserver.
|
| - // Ownership graph is a bit weird here.
|
| + if (!is_valid())
|
| + return;
|
| if (module_system_)
|
| module_system_->Invalidate();
|
| -
|
| - // Swap |invalidate_observers_| to a local variable to clear it, and to make
|
| - // sure it's not mutated as we iterate.
|
| - std::vector<base::Closure> observers;
|
| - observers.swap(invalidate_observers_);
|
| - for (const base::Closure& observer : observers) {
|
| - observer.Run();
|
| - }
|
| - DCHECK(invalidate_observers_.empty())
|
| - << "Invalidation observers cannot be added during invalidation";
|
| -
|
| + web_frame_ = NULL;
|
| + v8_context_.Reset();
|
| runner_.reset();
|
| - v8_context_.Reset();
|
| -}
|
| -
|
| -void ScriptContext::AddInvalidationObserver(const base::Closure& observer) {
|
| - invalidate_observers_.push_back(observer);
|
| }
|
|
|
| const std::string& ScriptContext::GetExtensionID() const {
|
| @@ -162,7 +144,7 @@
|
| v8::Context::Scope scope(v8_context());
|
|
|
| blink::WebScopedMicrotaskSuppression suppression;
|
| - if (!is_valid_) {
|
| + if (!is_valid()) {
|
| return handle_scope.Escape(
|
| v8::Local<v8::Primitive>(v8::Undefined(isolate())));
|
| }
|
|
|