зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1789697 - use nsITransportSecurityInfo directly instead of serializing it in PWindowGlobal::GetSecurityInfo r=nika
nsITransportSecurityInfo can be sent across IPC directly - it doesn't need to be serialized and deserialized to/from a string any longer. Depends on D156607 Differential Revision: https://phabricator.services.mozilla.com/D156718
This commit is contained in:
Родитель
7ff44a2c39
Коммит
9ee70aa7e7
|
@ -76,9 +76,9 @@ child:
|
||||||
uint32_t aFlags) returns (PaintFragment retval);
|
uint32_t aFlags) returns (PaintFragment retval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the serialized security info associated with this window.
|
* Returns the security info associated with this window.
|
||||||
*/
|
*/
|
||||||
async GetSecurityInfo() returns(nsCString? serializedSecInfo);
|
async GetSecurityInfo() returns(nsITransportSecurityInfo securityInfo);
|
||||||
|
|
||||||
async DispatchSecurityPolicyViolation(nsString aViolationEventJSON);
|
async DispatchSecurityPolicyViolation(nsString aViolationEventJSON);
|
||||||
|
|
||||||
|
|
|
@ -444,31 +444,31 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvDrawSnapshot(
|
||||||
|
|
||||||
mozilla::ipc::IPCResult WindowGlobalChild::RecvGetSecurityInfo(
|
mozilla::ipc::IPCResult WindowGlobalChild::RecvGetSecurityInfo(
|
||||||
GetSecurityInfoResolver&& aResolve) {
|
GetSecurityInfoResolver&& aResolve) {
|
||||||
Maybe<nsCString> result;
|
nsCOMPtr<nsITransportSecurityInfo> securityInfo;
|
||||||
|
auto callResolve =
|
||||||
|
MakeScopeExit([aResolve, &securityInfo]() { aResolve(securityInfo); });
|
||||||
|
|
||||||
if (nsCOMPtr<Document> doc = mWindowGlobal->GetDoc()) {
|
nsCOMPtr<Document> doc = mWindowGlobal->GetDoc();
|
||||||
nsCOMPtr<nsISupports> secInfo;
|
if (!doc) {
|
||||||
nsresult rv = NS_OK;
|
return IPC_OK();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsISupports> securityInfoSupports;
|
||||||
// First check if there's a failed channel, in case of a certificate
|
// First check if there's a failed channel, in case of a certificate
|
||||||
// error.
|
// error.
|
||||||
if (nsIChannel* failedChannel = doc->GetFailedChannel()) {
|
if (nsIChannel* failedChannel = doc->GetFailedChannel()) {
|
||||||
rv = failedChannel->GetSecurityInfo(getter_AddRefs(secInfo));
|
nsresult rv =
|
||||||
|
failedChannel->GetSecurityInfo(getter_AddRefs(securityInfoSupports));
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return IPC_OK();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// When there's no failed channel we should have a regular
|
// When there's no failed channel we should have a regular
|
||||||
// security info on the document. In some cases there's no
|
// security info on the document. In some cases there's no
|
||||||
// security info at all, i.e. on HTTP sites.
|
// security info at all, i.e. on HTTP sites.
|
||||||
secInfo = doc->GetSecurityInfo();
|
securityInfoSupports = doc->GetSecurityInfo();
|
||||||
}
|
}
|
||||||
|
securityInfo = do_QueryInterface(securityInfoSupports);
|
||||||
if (NS_SUCCEEDED(rv) && secInfo) {
|
|
||||||
nsCOMPtr<nsISerializable> secInfoSer = do_QueryInterface(secInfo);
|
|
||||||
result.emplace();
|
|
||||||
NS_SerializeToString(secInfoSer, result.ref());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
aResolve(result);
|
|
||||||
return IPC_OK();
|
return IPC_OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -987,19 +987,9 @@ already_AddRefed<Promise> WindowGlobalParent::GetSecurityInfo(
|
||||||
}
|
}
|
||||||
|
|
||||||
SendGetSecurityInfo(
|
SendGetSecurityInfo(
|
||||||
[promise](Maybe<nsCString>&& aResult) {
|
[promise](const nsCOMPtr<nsITransportSecurityInfo>& aSecurityInfo) {
|
||||||
if (aResult) {
|
if (aSecurityInfo) {
|
||||||
nsCOMPtr<nsISupports> infoObj;
|
promise->MaybeResolve(aSecurityInfo);
|
||||||
nsresult rv =
|
|
||||||
NS_DeserializeObject(aResult.value(), getter_AddRefs(infoObj));
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
||||||
promise->MaybeReject(NS_ERROR_FAILURE);
|
|
||||||
}
|
|
||||||
nsCOMPtr<nsITransportSecurityInfo> info = do_QueryInterface(infoObj);
|
|
||||||
if (!info) {
|
|
||||||
promise->MaybeReject(NS_ERROR_FAILURE);
|
|
||||||
}
|
|
||||||
promise->MaybeResolve(info);
|
|
||||||
} else {
|
} else {
|
||||||
promise->MaybeResolveWithUndefined();
|
promise->MaybeResolveWithUndefined();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче