Bug 1374930. P2 - add an entry only after FinishDecoderSetup() succeeds.
MozReview-Commit-ID: 6MKRhVIZ4Z6
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4680,17 +4680,23 @@ nsresult HTMLMediaElement::InitializeDec
return NS_ERROR_OUT_OF_MEMORY;
}
if (mChannelLoader) {
mChannelLoader->Done();
mChannelLoader = nullptr;
}
- return FinishDecoderSetup(decoder, resource, aListener);
+ nsresult rv = FinishDecoderSetup(decoder, resource, aListener);
+ if (NS_SUCCEEDED(rv)) {
+ AddMediaElementToURITable();
+ NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
+ "Media element should have single table entry if decode initialized");
+ }
+ return rv;
}
nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
MediaResource* aStream,
nsIStreamListener** aListener)
{
ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING);
@@ -4746,36 +4752,31 @@ nsresult HTMLMediaElement::FinishDecoder
mAbstractMainThread, this, &HTMLMediaElement::CannotDecryptWaitingForKey);
}
if (mChannelLoader) {
mChannelLoader->Done();
mChannelLoader = nullptr;
}
- AddMediaElementToURITable();
-
// We may want to suspend the new stream now.
// This will also do an AddRemoveSelfReference.
NotifyOwnerDocumentActivityChanged();
if (!mPaused) {
SetPlayedOrSeeked(true);
if (!mPausedForInactiveDocumentOrChannel) {
rv = mDecoder->Play();
}
}
if (NS_FAILED(rv)) {
ShutdownDecoder();
}
- NS_ASSERTION(NS_SUCCEEDED(rv) == (MediaElementTableCount(this, mLoadingSrc) == 1),
- "Media element should have single table entry if decode initialized");
-
return rv;
}
class HTMLMediaElement::StreamListener : public MediaStreamListener,
public WatchTarget
{
public:
StreamListener(HTMLMediaElement* aElement, const char* aName) :