Index: chrome/renderer/extensions/automation_internal_custom_bindings.cc |
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
index 844fd87dd09790dbc38ce9615333ee5698240fdd..3a620c89d4946091ff07a0c49c8899ca0bcbd6ed 100644 |
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc |
@@ -136,8 +136,14 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( |
AutomationInternalCustomBindings::~AutomationInternalCustomBindings() { |
if (message_filter_) |
David Tseng
2015/11/03 18:37:44
Perhaps this class needs to override Invalidate (a
dmazzoni
2015/11/06 22:49:58
Good catch. Done, that seems to work.
|
message_filter_->Detach(); |
- STLDeleteContainerPairSecondPointers(tree_id_to_tree_cache_map_.begin(), |
- tree_id_to_tree_cache_map_.end()); |
+ |
+ // Delete the TreeCaches quickly by first clearing their delegates so |
+ // we don't get a callback for every node being deleted. |
+ for (auto iter : tree_id_to_tree_cache_map_) { |
+ TreeCache* cache = iter.second; |
+ cache->tree.SetDelegate(nullptr); |
+ delete cache; |
+ } |
} |
void AutomationInternalCustomBindings::OnMessageReceived( |
@@ -628,6 +634,9 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent( |
if (!is_active_profile_) |
return; |
+ if (!GetIsolate() || !context()) |
David Tseng
2015/11/03 18:37:44
Do you need to do this if teardown occurs in Inval
dmazzoni
2015/11/06 22:49:58
Probably not.
|
+ return; |
+ |
auto iter = axtree_to_tree_cache_map_.find(tree); |
if (iter == axtree_to_tree_cache_map_.end()) |
return; |