Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1198435) for build bustage a=backout
Browse files Browse the repository at this point in the history
Backed out changeset 0bfe8c7362cb (bug 1198435)
Backed out changeset df2dea566188 (bug 1198435)
  • Loading branch information
KWierso committed Sep 14, 2015
1 parent 546bd33 commit 36aa754
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 41 deletions.
59 changes: 19 additions & 40 deletions dom/html/HTMLMediaElement.cpp
Expand Up @@ -667,7 +667,6 @@ void HTMLMediaElement::AbortExistingLoads()
EndSrcMediaStreamPlayback();
}

RemoveMediaElementFromURITable();
mLoadingSrc = nullptr;
mMediaSource = nullptr;

Expand Down Expand Up @@ -877,7 +876,6 @@ void HTMLMediaElement::SelectResource()
NS_ASSERTION(!mIsLoadingFromSourceChildren,
"Should think we're not loading from source children by default");

RemoveMediaElementFromURITable();
mLoadingSrc = uri;
mMediaSource = mSrcMediaSource;
UpdatePreloadAction();
Expand Down Expand Up @@ -1016,7 +1014,6 @@ void HTMLMediaElement::LoadFromSourceChildren()
continue;
}

RemoveMediaElementFromURITable();
mLoadingSrc = uri;
mMediaSource = childSrc->GetSrcMediaSource();
NS_ASSERTION(mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING,
Expand Down Expand Up @@ -1961,43 +1958,26 @@ typedef nsTHashtable<MediaElementSetForURI> MediaElementURITable;
static MediaElementURITable* gElementTable;

#ifdef DEBUG
static bool
URISafeEquals(nsIURI* a1, nsIURI* a2)
{
if (!a1 || !a2) {
// Consider two empty URIs *not* equal!
return false;
}
bool equal = false;
nsresult rv = a1->Equals(a2, &equal);
return NS_SUCCEEDED(rv) && equal;
}
// Returns the number of times aElement appears in the media element table
// for aURI. If this returns other than 0 or 1, there's a bug somewhere!
static unsigned
MediaElementTableCount(HTMLMediaElement* aElement, nsIURI* aURI)
{
if (!gElementTable || !aElement) {
if (!gElementTable || !aElement || !aURI) {
return 0;
}
uint32_t uriCount = 0;
uint32_t otherCount = 0;
for (auto it = gElementTable->ConstIter(); !it.Done(); it.Next()) {
MediaElementSetForURI* entry = it.Get();
uint32_t count = 0;
for (const auto& elem : entry->mElements) {
if (elem == aElement) {
count++;
}
}
if (URISafeEquals(aURI, entry->GetKey())) {
uriCount = count;
} else {
otherCount += count;
MediaElementSetForURI* entry = gElementTable->GetEntry(aURI);
if (!entry) {
return 0;
}
uint32_t count = 0;
for (uint32_t i = 0; i < entry->mElements.Length(); ++i) {
HTMLMediaElement* elem = entry->mElements[i];
if (elem == aElement) {
count++;
}
}
NS_ASSERTION(otherCount == 0, "Should not have entries for unknown URIs");
return uriCount;
return count;
}
#endif

Expand All @@ -2019,13 +1999,15 @@ HTMLMediaElement::AddMediaElementToURITable()
void
HTMLMediaElement::RemoveMediaElementFromURITable()
{
if (!mDecoder || !mLoadingSrc || !gElementTable) {
NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
"Before remove, should have a single entry for element in element table");
NS_ASSERTION(mDecoder, "Don't call this without decoder!");
NS_ASSERTION(mLoadingSrc, "Can't have decoder without source!");
if (!gElementTable)
return;
}
MediaElementSetForURI* entry = gElementTable->GetEntry(mLoadingSrc);
if (!entry) {
if (!entry)
return;
}
entry->mElements.RemoveElement(this);
if (entry->mElements.IsEmpty()) {
gElementTable->RemoveEntry(mLoadingSrc);
Expand All @@ -2041,13 +2023,11 @@ HTMLMediaElement::RemoveMediaElementFromURITable()
HTMLMediaElement*
HTMLMediaElement::LookupMediaElementURITable(nsIURI* aURI)
{
if (!gElementTable) {
if (!gElementTable)
return nullptr;
}
MediaElementSetForURI* entry = gElementTable->GetEntry(aURI);
if (!entry) {
if (!entry)
return nullptr;
}
for (uint32_t i = 0; i < entry->mElements.Length(); ++i) {
HTMLMediaElement* elem = entry->mElements[i];
bool equal;
Expand Down Expand Up @@ -3326,7 +3306,6 @@ void HTMLMediaElement::DecodeError()
if (mDecoder) {
ShutdownDecoder();
}
RemoveMediaElementFromURITable();
mLoadingSrc = nullptr;
mMediaSource = nullptr;
if (mIsLoadingFromSourceChildren) {
Expand Down
2 changes: 1 addition & 1 deletion dom/html/HTMLMediaElement.h
Expand Up @@ -770,7 +770,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
*/
void AddMediaElementToURITable();
/**
* Call this before modifying mLoadingSrc.
* Call this before clearing mLoadingSrc.
*/
void RemoveMediaElementFromURITable();
/**
Expand Down

0 comments on commit 36aa754

Please sign in to comment.