зеркало из 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
|
|
@ -444,31 +444,31 @@ mozilla::ipc::IPCResult WindowGlobalChild::RecvDrawSnapshot(
|
|||
|
||||
mozilla::ipc::IPCResult WindowGlobalChild::RecvGetSecurityInfo(
|
||||
GetSecurityInfoResolver&& aResolve) {
|
||||
Maybe<nsCString> result;
|
||||
nsCOMPtr<nsITransportSecurityInfo> securityInfo;
|
||||
auto callResolve =
|
||||
MakeScopeExit([aResolve, &securityInfo]() { aResolve(securityInfo); });
|
||||
|
||||
if (nsCOMPtr<Document> doc = mWindowGlobal->GetDoc()) {
|
||||
nsCOMPtr<nsISupports> secInfo;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// First check if there's a failed channel, in case of a certificate
|
||||
// error.
|
||||
if (nsIChannel* failedChannel = doc->GetFailedChannel()) {
|
||||
rv = failedChannel->GetSecurityInfo(getter_AddRefs(secInfo));
|
||||
} else {
|
||||
// When there's no failed channel we should have a regular
|
||||
// security info on the document. In some cases there's no
|
||||
// security info at all, i.e. on HTTP sites.
|
||||
secInfo = doc->GetSecurityInfo();
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv) && secInfo) {
|
||||
nsCOMPtr<nsISerializable> secInfoSer = do_QueryInterface(secInfo);
|
||||
result.emplace();
|
||||
NS_SerializeToString(secInfoSer, result.ref());
|
||||
}
|
||||
nsCOMPtr<Document> doc = mWindowGlobal->GetDoc();
|
||||
if (!doc) {
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
aResolve(result);
|
||||
nsCOMPtr<nsISupports> securityInfoSupports;
|
||||
// First check if there's a failed channel, in case of a certificate
|
||||
// error.
|
||||
if (nsIChannel* failedChannel = doc->GetFailedChannel()) {
|
||||
nsresult rv =
|
||||
failedChannel->GetSecurityInfo(getter_AddRefs(securityInfoSupports));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return IPC_OK();
|
||||
}
|
||||
} else {
|
||||
// When there's no failed channel we should have a regular
|
||||
// security info on the document. In some cases there's no
|
||||
// security info at all, i.e. on HTTP sites.
|
||||
securityInfoSupports = doc->GetSecurityInfo();
|
||||
}
|
||||
securityInfo = do_QueryInterface(securityInfoSupports);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -987,19 +987,9 @@ already_AddRefed<Promise> WindowGlobalParent::GetSecurityInfo(
|
|||
}
|
||||
|
||||
SendGetSecurityInfo(
|
||||
[promise](Maybe<nsCString>&& aResult) {
|
||||
if (aResult) {
|
||||
nsCOMPtr<nsISupports> infoObj;
|
||||
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);
|
||||
[promise](const nsCOMPtr<nsITransportSecurityInfo>& aSecurityInfo) {
|
||||
if (aSecurityInfo) {
|
||||
promise->MaybeResolve(aSecurityInfo);
|
||||
} else {
|
||||
promise->MaybeResolveWithUndefined();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче