LCOV - code coverage report
Current view: top level - security/manager/ssl - nsCertTree.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 3 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* This Source Code Form is subject to the terms of the Mozilla Public
       2             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       3             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       4             : 
       5             : #ifndef _NS_CERTTREE_H_
       6             : #define _NS_CERTTREE_H_
       7             : 
       8             : #include "nsCOMPtr.h"
       9             : #include "nsIServiceManager.h"
      10             : #include "nsICertTree.h"
      11             : #include "nsITreeView.h"
      12             : #include "nsITreeBoxObject.h"
      13             : #include "nsITreeSelection.h"
      14             : #include "nsIMutableArray.h"
      15             : #include "nsNSSComponent.h"
      16             : #include "nsTArray.h"
      17             : #include "PLDHashTable.h"
      18             : #include "nsIX509CertDB.h"
      19             : #include "nsCertOverrideService.h"
      20             : #include "mozilla/Attributes.h"
      21             : 
      22             : typedef struct treeArrayElStr treeArrayEl;
      23             : 
      24           0 : struct CompareCacheHashEntry {
      25             :   enum { max_criterions = 3 };
      26             :   CompareCacheHashEntry();
      27             : 
      28             :   void *key; // no ownership
      29             :   bool mCritInit[max_criterions];
      30             :   nsXPIDLString mCrit[max_criterions];
      31             : };
      32             : 
      33             : struct CompareCacheHashEntryPtr : PLDHashEntryHdr {
      34             :   CompareCacheHashEntryPtr();
      35             :   ~CompareCacheHashEntryPtr();
      36             :   CompareCacheHashEntry *entry;
      37             : };
      38             : 
      39             : class nsCertAddonInfo final : public nsISupports
      40             : {
      41             : private:
      42           0 :   ~nsCertAddonInfo() {}
      43             : 
      44             : public:
      45             :   NS_DECL_ISUPPORTS
      46             : 
      47           0 :   nsCertAddonInfo() : mUsageCount(0) {}
      48             : 
      49             :   RefPtr<nsIX509Cert> mCert;
      50             :   // how many display entries reference this?
      51             :   // (and therefore depend on the underlying cert)
      52             :   int32_t mUsageCount;
      53             : };
      54             : 
      55             : class nsCertTreeDispInfo : public nsICertTreeItem
      56             : {
      57             : protected:
      58             :   virtual ~nsCertTreeDispInfo();
      59             : 
      60             : public:
      61             :   NS_DECL_ISUPPORTS
      62             :   NS_DECL_NSICERTTREEITEM
      63             : 
      64             :   nsCertTreeDispInfo();
      65             :   nsCertTreeDispInfo(nsCertTreeDispInfo &other);
      66             : 
      67             :   RefPtr<nsCertAddonInfo> mAddonInfo;
      68             :   enum {
      69             :     direct_db, host_port_override
      70             :   } mTypeOfEntry;
      71             :   nsCString mAsciiHost;
      72             :   int32_t mPort;
      73             :   nsCertOverride::OverrideBits mOverrideBits;
      74             :   bool mIsTemporary;
      75             :   nsCOMPtr<nsIX509Cert> mCert;
      76             : };
      77             : 
      78             : class nsCertTree : public nsICertTree
      79             : {
      80             : public:
      81             :   NS_DECL_ISUPPORTS
      82             :   NS_DECL_NSICERTTREE
      83             :   NS_DECL_NSITREEVIEW
      84             : 
      85             :   nsCertTree();
      86             : 
      87             :   enum sortCriterion { sort_IssuerOrg, sort_Org, sort_Token,
      88             :     sort_CommonName, sort_IssuedDateDescending, sort_Email, sort_None };
      89             : 
      90             : protected:
      91             :   virtual ~nsCertTree();
      92             : 
      93             :   void ClearCompareHash();
      94             :   void RemoveCacheEntry(void *key);
      95             : 
      96             :   typedef int (*nsCertCompareFunc)(void *, nsIX509Cert *a, nsIX509Cert *b);
      97             : 
      98             :   static CompareCacheHashEntry *getCacheEntry(void *cache, void *aCert);
      99             :   static void CmpInitCriterion(nsIX509Cert *cert, CompareCacheHashEntry *entry,
     100             :                                sortCriterion crit, int32_t level);
     101             :   static int32_t CmpByCrit(nsIX509Cert *a, CompareCacheHashEntry *ace,
     102             :                            nsIX509Cert *b, CompareCacheHashEntry *bce,
     103             :                            sortCriterion crit, int32_t level);
     104             :   static int32_t CmpBy(void *cache, nsIX509Cert *a, nsIX509Cert *b,
     105             :                        sortCriterion c0, sortCriterion c1, sortCriterion c2);
     106             :   static int32_t CmpCACert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     107             :   static int32_t CmpWebSiteCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     108             :   static int32_t CmpUserCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     109             :   static int32_t CmpEmailCert(void *cache, nsIX509Cert *a, nsIX509Cert *b);
     110             :   nsCertCompareFunc GetCompareFuncFromCertType(uint32_t aType);
     111             :   int32_t CountOrganizations();
     112             : 
     113             :   nsresult GetCertsByType(uint32_t aType, nsCertCompareFunc aCertCmpFn,
     114             :                           void *aCertCmpFnArg);
     115             : 
     116             :   nsresult GetCertsByTypeFromCache(nsIX509CertList *aCache, uint32_t aType,
     117             :                                    nsCertCompareFunc aCertCmpFn, void *aCertCmpFnArg);
     118             : private:
     119             :   static const uint32_t kInitialCacheLength = 64;
     120             : 
     121             :   nsTArray< RefPtr<nsCertTreeDispInfo> > mDispInfo;
     122             :   nsCOMPtr<nsITreeBoxObject>  mTree;
     123             :   nsCOMPtr<nsITreeSelection>  mSelection;
     124             :   treeArrayEl                *mTreeArray;
     125             :   int32_t                         mNumOrgs;
     126             :   int32_t                         mNumRows;
     127             :   PLDHashTable mCompareCache;
     128             :   nsCOMPtr<nsINSSComponent> mNSSComponent;
     129             :   nsCOMPtr<nsICertOverrideService> mOverrideService;
     130             :   RefPtr<nsCertOverrideService> mOriginalOverrideService;
     131             : 
     132             :   treeArrayEl *GetThreadDescAtIndex(int32_t _index);
     133             :   already_AddRefed<nsIX509Cert>
     134             :     GetCertAtIndex(int32_t _index, int32_t *outAbsoluteCertOffset = nullptr);
     135             :   already_AddRefed<nsCertTreeDispInfo>
     136             :     GetDispInfoAtIndex(int32_t index, int32_t *outAbsoluteCertOffset = nullptr);
     137             :   void FreeCertArray();
     138             :   nsresult UpdateUIContents();
     139             : 
     140             :   nsresult GetCertsByTypeFromCertList(CERTCertList *aCertList,
     141             :                                       uint32_t aType,
     142             :                                       nsCertCompareFunc  aCertCmpFn,
     143             :                                       void              *aCertCmpFnArg);
     144             : 
     145             :   nsCOMPtr<nsIMutableArray> mCellText;
     146             : 
     147             : #ifdef DEBUG_CERT_TREE
     148             :   /* for debugging purposes */
     149             :   void dumpMap();
     150             : #endif
     151             : };
     152             : 
     153             : #endif /* _NS_CERTTREE_H_ */
     154             : 

Generated by: LCOV version 1.13