Bug 784131 - nsObjectLoadingcontent: Minor cleanup around mPendingInstantiateEvent. r=josh

This commit is contained in:
John Schoenick 2013-03-12 16:13:46 -07:00
parent 413b2e3042
commit 661df28246
2 changed files with 9 additions and 10 deletions

View File

@ -128,7 +128,8 @@ nsAsyncInstantiateEvent::Run()
nsObjectLoadingContent *objLC = nsObjectLoadingContent *objLC =
static_cast<nsObjectLoadingContent *>(mContent.get()); static_cast<nsObjectLoadingContent *>(mContent.get());
// do nothing if we've been revoked // If objLC is no longer tracking this event, we've been canceled or
// superceded
if (objLC->mPendingInstantiateEvent != this) { if (objLC->mPendingInstantiateEvent != this) {
return NS_OK; return NS_OK;
} }
@ -2369,27 +2370,25 @@ nsObjectLoadingContent::SyncStartPluginInstance()
NS_IMETHODIMP NS_IMETHODIMP
nsObjectLoadingContent::AsyncStartPluginInstance() nsObjectLoadingContent::AsyncStartPluginInstance()
{ {
// OK to have an instance already. // OK to have an instance already or a pending spawn.
if (mInstanceOwner) { if (mInstanceOwner || mPendingInstantiateEvent) {
return NS_OK; return NS_OK;
} }
nsCOMPtr<nsIContent> thisContent = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this)); nsCOMPtr<nsIContent> thisContent =
do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
nsIDocument* doc = thisContent->OwnerDoc(); nsIDocument* doc = thisContent->OwnerDoc();
if (doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) { if (doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) {
return NS_OK; return NS_OK;
} }
// We always start plugins on a runnable.
// We don't want a script blocker on the stack during instantiation.
nsCOMPtr<nsIRunnable> event = new nsAsyncInstantiateEvent(this); nsCOMPtr<nsIRunnable> event = new nsAsyncInstantiateEvent(this);
if (!event) { if (!event) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
nsresult rv = NS_DispatchToCurrentThread(event); nsresult rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Remember this event. This is a weak reference that will be cleared // Track pending events
// when the event runs.
mPendingInstantiateEvent = event; mPendingInstantiateEvent = event;
} }

View File

@ -449,8 +449,8 @@ class nsObjectLoadingContent : public nsImageLoadingContent
// Frame loader, for content documents we load. // Frame loader, for content documents we load.
nsRefPtr<nsFrameLoader> mFrameLoader; nsRefPtr<nsFrameLoader> mFrameLoader;
// A pending nsAsyncInstantiateEvent (may be null). This is a weak ref. // Track if we have a pending AsyncInstantiateEvent
nsIRunnable *mPendingInstantiateEvent; nsCOMPtr<nsIRunnable> mPendingInstantiateEvent;
// The content type of our current load target, updated by // The content type of our current load target, updated by
// UpdateObjectParameters(). Takes the channel's type into account once // UpdateObjectParameters(). Takes the channel's type into account once