Index: content/renderer/browser_plugin/browser_plugin.cc |
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
index 078422229c75ac2edbabc088de9d66ed9f1cd53b..38d4bff33ebfc23b5bfb916e833d42ab16750b66 100644 |
--- a/content/renderer/browser_plugin/browser_plugin.cc |
+++ b/content/renderer/browser_plugin/browser_plugin.cc |
@@ -300,14 +300,12 @@ bool BrowserPlugin::initialize(WebPluginContainer* container) { |
BrowserPluginManager::Get()->AddBrowserPlugin( |
browser_plugin_instance_id_, this); |
- // This is a way to notify observers of our attributes that this plugin is |
- // available in render tree. |
- // TODO(lazyboy): This should be done through the delegate instead. Perhaps |
- // by firing an event from there. |
- UpdateDOMAttribute( |
- "internalinstanceid", |
- base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_))); |
- |
+ // Defer attach call so that if there's any pending browser plugin |
+ // destruction, then it can progress first. |
+ base::MessageLoop::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&BrowserPlugin::UpdateInternalInstanceId, |
+ weak_ptr_factory_.GetWeakPtr())); |
return true; |
} |
@@ -333,6 +331,16 @@ void BrowserPlugin::EnableCompositing(bool enable) { |
} |
} |
+void BrowserPlugin::UpdateInternalInstanceId() { |
+ // This is a way to notify observers of our attributes that this plugin is |
+ // available in render tree. |
+ // TODO(lazyboy): This should be done through the delegate instead. Perhaps |
+ // by firing an event from there. |
+ UpdateDOMAttribute( |
+ "internalinstanceid", |
+ base::UTF8ToUTF16(base::IntToString(browser_plugin_instance_id_))); |
+} |
+ |
void BrowserPlugin::destroy() { |
if (container_) { |
// The BrowserPlugin's WebPluginContainer is deleted immediately after this |