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

Unified Diff: extensions/renderer/module_system.cc

Issue 1083663004: Revert of 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: 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/module_system.h ('k') | extensions/renderer/module_system_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/module_system.cc
diff --git a/extensions/renderer/module_system.cc b/extensions/renderer/module_system.cc
index 6a120749f4107499b322fc42f998c9f83528a703..6194b8ed4c4be059a5f298055d91df3b00bc4cab 100644
--- a/extensions/renderer/module_system.cc
+++ b/extensions/renderer/module_system.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -152,10 +151,12 @@
}
}
-ModuleSystem::~ModuleSystem() {
-}
+ModuleSystem::~ModuleSystem() { Invalidate(); }
void ModuleSystem::Invalidate() {
+ if (!is_valid())
+ return;
+
// Clear the module system properties from the global context. It's polite,
// and we use this as a signal in lazy handlers that we no longer exist.
{
@@ -167,11 +168,12 @@
v8::String::NewFromUtf8(GetIsolate(), kModuleSystem));
}
- // Invalidate all active and clobbered NativeHandlers we own.
- for (const auto& handler : native_handler_map_)
- handler.second->Invalidate();
- for (const auto& clobbered_handler : clobbered_native_handlers_)
- clobbered_handler->Invalidate();
+ // Invalidate all of the successfully required handlers we own.
+ for (NativeHandlerMap::iterator it = native_handler_map_.begin();
+ it != native_handler_map_.end();
+ ++it) {
+ it->second->Invalidate();
+ }
ObjectBackedNativeHandler::Invalidate();
}
@@ -299,13 +301,11 @@
void ModuleSystem::RegisterNativeHandler(
const std::string& name,
scoped_ptr<NativeHandler> native_handler) {
- ClobberExistingNativeHandler(name);
native_handler_map_[name] =
linked_ptr<NativeHandler>(native_handler.release());
}
void ModuleSystem::OverrideNativeHandlerForTest(const std::string& name) {
- ClobberExistingNativeHandler(name);
overridden_native_handlers_.insert(name);
}
@@ -685,12 +685,4 @@
resolver_local->Resolve(value);
}
-void ModuleSystem::ClobberExistingNativeHandler(const std::string& name) {
- NativeHandlerMap::iterator existing_handler = native_handler_map_.find(name);
- if (existing_handler != native_handler_map_.end()) {
- clobbered_native_handlers_.push_back(existing_handler->second);
- native_handler_map_.erase(existing_handler);
- }
-}
-
} // namespace extensions
« no previous file with comments | « extensions/renderer/module_system.h ('k') | extensions/renderer/module_system_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698