Bug 1182540 - Use channel->ascynOpen2 in dom/html/HTMLTrackElement.cpp (r=sicking)

This commit is contained in:
Christoph Kerschbaumer 2015-07-25 10:29:22 -07:00
parent 4d61c75f16
commit a19920a796
2 changed files with 21 additions and 34 deletions

View File

@ -203,26 +203,6 @@ HTMLTrackElement::LoadResource()
mChannel = nullptr;
}
rv = nsContentUtils::GetSecurityManager()->
CheckLoadURIWithPrincipal(NodePrincipal(), uri,
nsIScriptSecurityManager::STANDARD);
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
int16_t shouldLoad = nsIContentPolicy::ACCEPT;
rv = NS_CheckContentLoadPolicy(nsIContentPolicy::TYPE_INTERNAL_TRACK,
uri,
NodePrincipal(),
static_cast<Element*>(this),
NS_LITERAL_CSTRING("text/vtt"), // mime type
nullptr, // extra
&shouldLoad,
nsContentUtils::GetContentPolicy(),
nsContentUtils::GetSecurityManager());
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
if (NS_CP_REJECTED(shouldLoad)) {
return;
}
// We may already have a TextTrack at this point if GetTrack() has already
// been called. This happens, for instance, if script tries to get the
// TextTrack before its mTrackElement has been bound to the DOM tree.
@ -235,7 +215,7 @@ HTMLTrackElement::LoadResource()
rv = NS_NewChannel(getter_AddRefs(channel),
uri,
static_cast<Element*>(this),
nsILoadInfo::SEC_NORMAL,
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS,
nsIContentPolicy::TYPE_INTERNAL_TRACK,
loadGroup);
@ -247,7 +227,7 @@ HTMLTrackElement::LoadResource()
channel->SetNotificationCallbacks(mListener);
LOG(LogLevel::Debug, ("opening webvtt channel"));
rv = channel->AsyncOpen(mListener, nullptr);
rv = channel->AsyncOpen2(mListener);
NS_ENSURE_TRUE_VOID(NS_SUCCEEDED(rv));
mChannel = channel;

View File

@ -115,7 +115,7 @@ DoContentSecurityChecks(nsIURI* aURI, nsILoadInfo* aLoadInfo)
{
nsContentPolicyType contentPolicyType = aLoadInfo->GetContentPolicyType();
nsCString mimeTypeGuess;
nsCOMPtr<nsISupports> requestingContext = nullptr;
nsCOMPtr<nsINode> requestingContext = nullptr;
switch(contentPolicyType) {
case nsIContentPolicy::TYPE_OTHER:
@ -132,30 +132,37 @@ DoContentSecurityChecks(nsIURI* aURI, nsILoadInfo* aLoadInfo)
// alias nsIContentPolicy::TYPE_DATAREQUEST:
case nsIContentPolicy::TYPE_OBJECT_SUBREQUEST:
case nsIContentPolicy::TYPE_DTD:
case nsIContentPolicy::TYPE_FONT:
case nsIContentPolicy::TYPE_FONT: {
MOZ_ASSERT(false, "contentPolicyType not supported yet");
break;
}
case nsIContentPolicy::TYPE_MEDIA:
mimeTypeGuess = EmptyCString();
requestingContext = aLoadInfo->LoadingNode();
#ifdef DEBUG
{
nsCOMPtr<mozilla::dom::Element> element = do_QueryInterface(requestingContext);
NS_ASSERTION(element != nullptr,
"type_media requires requestingContext of type Element");
case nsIContentPolicy::TYPE_MEDIA: {
nsContentPolicyType internalContentPolicyType =
aLoadInfo->InternalContentPolicyType();
if (internalContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_TRACK) {
mimeTypeGuess = NS_LITERAL_CSTRING("text/vtt");
}
#endif
else {
mimeTypeGuess = EmptyCString();
}
requestingContext = aLoadInfo->LoadingNode();
MOZ_ASSERT(!requestingContext ||
requestingContext->NodeType() == nsIDOMNode::ELEMENT_NODE,
"type_media requires requestingContext of type Element");
break;
}
case nsIContentPolicy::TYPE_WEBSOCKET:
case nsIContentPolicy::TYPE_CSP_REPORT:
case nsIContentPolicy::TYPE_XSLT:
case nsIContentPolicy::TYPE_BEACON:
case nsIContentPolicy::TYPE_FETCH:
case nsIContentPolicy::TYPE_IMAGESET:
case nsIContentPolicy::TYPE_IMAGESET: {
MOZ_ASSERT(false, "contentPolicyType not supported yet");
break;
}
default:
// nsIContentPolicy::TYPE_INVALID