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 b8e04cd6eb
commit f313ae0f52
2 changed files with 9 additions and 10 deletions

View File

@ -128,7 +128,8 @@ nsAsyncInstantiateEvent::Run()
nsObjectLoadingContent *objLC =
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) {
return NS_OK;
}
@ -2369,27 +2370,25 @@ nsObjectLoadingContent::SyncStartPluginInstance()
NS_IMETHODIMP
nsObjectLoadingContent::AsyncStartPluginInstance()
{
// OK to have an instance already.
if (mInstanceOwner) {
// OK to have an instance already or a pending spawn.
if (mInstanceOwner || mPendingInstantiateEvent) {
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();
if (doc->IsStaticDocument() || doc->IsBeingUsedAsImage()) {
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);
if (!event) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult rv = NS_DispatchToCurrentThread(event);
if (NS_SUCCEEDED(rv)) {
// Remember this event. This is a weak reference that will be cleared
// when the event runs.
// Track pending events
mPendingInstantiateEvent = event;
}

View File

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