Closed Bug 1335576 Opened 7 years ago Closed 7 years ago

clean up nsNSSCertHelper.cpp a bit to enable other improvements

Categories

(Core :: Security: PSM, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: keeler, Assigned: keeler)

Details

(Whiteboard: [psm-assigned])

Attachments

(2 files)

nsNSSCertHelper.cpp could use some improvements:
* style-wise, it's all over the place
* it needlessly passes around a pointer to nsINSSComponent in more or less every function (needless because what it really wants is the pipnss string bundle, which doesn't need to be part of nsINSSComponent anyway, particularly for main-thread-only uses, which this happens to be (the vast majority of this file is just to implement nsIX509Cert.ASN1Structure)).

Doing this will simplify some improvements to nsINSSComponent I have planned.

Note that this bug is not intended to address all current issues with nsNSSCertHelper.cpp. For example, in many cases return values are not checked when they should be. This patch will not change any behavior in this regard.
Comment on attachment 8832258 [details]
bug 1335576 - run clang-format on nsNSSCertHelper.cpp

https://reviewboard.mozilla.org/r/108594/#review110634
Attachment #8832258 - Flags: review?(cykesiopka.bmo) → review+
Comment on attachment 8832259 [details]
bug 1335576 - stop passing nsINSSComponent around everywhere in nsNSSCertHelper.cpp

https://reviewboard.mozilla.org/r/108596/#review110636

Much nicer.

::: security/manager/ssl/nsNSSCertHelper.cpp:22
(Diff revision 1)
>  #include "nsNSSCertTrust.h"
>  #include "nsNSSCertValidity.h"
>  #include "nsNSSCertificate.h"
> -#include "nsNSSComponent.h"
>  #include "nsServiceManagerUtils.h"
> +#include "nsString.h"

Nit: Looks like the header file already includes `nsString.h`.

::: security/manager/ssl/nsNSSCertHelper.cpp:81
(Diff revision 1)
>  };
>  
>  static const unsigned int numOids = (sizeof more_oids) / (sizeof more_oids[0]);
>  
>  static nsresult
> -ProcessVersion(SECItem* versionItem,
> +GetPIPNSSBundle(nsIStringBundle** pipnssBundle)

We should include nsIStringBundle.h for this.

::: security/manager/ssl/nsNSSCertHelper.cpp:83
(Diff revision 1)
>  static const unsigned int numOids = (sizeof more_oids) / (sizeof more_oids[0]);
>  
>  static nsresult
> -ProcessVersion(SECItem* versionItem,
> -               nsINSSComponent* nssComponent,
> -               nsIASN1PrintableItem** retItem)
> +GetPIPNSSBundle(nsIStringBundle** pipnssBundle)
> +{
> +  nsCOMPtr<nsIStringBundleService> bundleService(

We should include nsIStringBundleService.h for this.

::: security/manager/ssl/nsNSSCertHelper.cpp:107
(Diff revision 1)
> +    return rv;
> +  }
> +  result.Truncate();
> +  nsXPIDLString xpidlString;
> +  rv = pipnssBundle->GetStringFromName(NS_ConvertASCIItoUTF16(stringName).get(),
> +                                       getter_Copies(xpidlString));

Nit: It looks like we can actually just pass `result` directly here and below, and simplify some of the code.

::: security/manager/ssl/nsNSSCertHelper.cpp:1439
(Diff revision 1)
> -        nssComponent->GetPIPNSSBundleString("CertDumpAffiliationChanged",
> +        GetPIPNSSBundleString("CertDumpAffiliationChanged",
>                                              local);

Nit: Indentation here is off.
Attachment #8832259 - Flags: review?(cykesiopka.bmo) → review+
Comment on attachment 8832259 [details]
bug 1335576 - stop passing nsINSSComponent around everywhere in nsNSSCertHelper.cpp

https://reviewboard.mozilla.org/r/108596/#review110636

Thanks! (I realize this probably wasn't the most fun review...)

> Nit: Looks like the header file already includes `nsString.h`.

Ah - fixed.

> We should include nsIStringBundle.h for this.

Added.

> We should include nsIStringBundleService.h for this.

Looks like nsIStringBundleService is just defined in nsIStringBundle.idl: https://dxr.mozilla.org/mozilla-central/rev/1d025ac534a6333a8170a59a95a8a3673d4028ee/intl/strres/nsIStringBundle.idl#53

> Nit: It looks like we can actually just pass `result` directly here and below, and simplify some of the code.

Good call.

> Nit: Indentation here is off.

Good catch.
Pushed by dkeeler@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2b15133c98cc
run clang-format on nsNSSCertHelper.cpp r=Cykesiopka
https://hg.mozilla.org/integration/autoland/rev/19cd77acf2e0
stop passing nsINSSComponent around everywhere in nsNSSCertHelper.cpp r=Cykesiopka
https://hg.mozilla.org/mozilla-central/rev/2b15133c98cc
https://hg.mozilla.org/mozilla-central/rev/19cd77acf2e0
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: