LCOV - code coverage report
Current view: top level - dom/base - nsScriptNameSpaceManager.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 7 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       6             :  *
       7             :  *
       8             :  * This Original Code has been modified by IBM Corporation.
       9             :  * Modifications made by IBM described herein are
      10             :  * Copyright (c) International Business Machines
      11             :  * Corporation, 2000
      12             :  *
      13             :  * Modifications to Mozilla code or documentation
      14             :  * identified per MPL Section 3.3
      15             :  *
      16             :  * Date         Modified by     Description of modification
      17             :  * 03/27/2000   IBM Corp.       Added PR_CALLBACK for Optlink
      18             :  *                               use in OS2
      19             :  */
      20             : 
      21             : #ifndef nsScriptNameSpaceManager_h__
      22             : #define nsScriptNameSpaceManager_h__
      23             : 
      24             : #include "mozilla/MemoryReporting.h"
      25             : #include "nsBaseHashtable.h"
      26             : #include "nsIMemoryReporter.h"
      27             : #include "nsIScriptNameSpaceManager.h"
      28             : #include "nsString.h"
      29             : #include "nsID.h"
      30             : #include "PLDHashTable.h"
      31             : #include "nsDOMClassInfo.h"
      32             : #include "nsIObserver.h"
      33             : #include "nsWeakReference.h"
      34             : #include "xpcpublic.h"
      35             : 
      36             : struct nsGlobalNameStruct
      37             : {
      38             :   enum nametype {
      39             :     eTypeNotInitialized,
      40             :     eTypeProperty,
      41             :     eTypeExternalConstructor,
      42             :     eTypeClassConstructor,
      43             :     eTypeClassProto,
      44             :   } mType;
      45             : 
      46             :   bool mChromeOnly : 1;
      47             :   bool mAllowXBL : 1;
      48             : 
      49             :   union {
      50             :     int32_t mDOMClassInfoID; // eTypeClassConstructor
      51             :     nsIID mIID; // eTypeClassProto
      52             :     nsCID mCID; // All other types
      53             :   };
      54             : };
      55             : 
      56             : class GlobalNameMapEntry : public PLDHashEntryHdr
      57             : {
      58             : public:
      59             :   // Our hash table ops don't care about the order of these members.
      60             :   nsString mKey;
      61             :   nsGlobalNameStruct mGlobalName;
      62             : 
      63           0 :   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
      64             :     // Measurement of the following members may be added later if DMD finds it
      65             :     // is worthwhile:
      66             :     // - mGlobalName
      67           0 :     return mKey.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
      68             :   }
      69             : };
      70             : 
      71             : class nsICategoryManager;
      72             : 
      73             : class nsScriptNameSpaceManager : public nsIObserver,
      74             :                                  public nsSupportsWeakReference,
      75             :                                  public nsIMemoryReporter
      76             : {
      77             : public:
      78             :   NS_DECL_ISUPPORTS
      79             :   NS_DECL_NSIOBSERVER
      80             :   NS_DECL_NSIMEMORYREPORTER
      81             : 
      82             :   nsScriptNameSpaceManager();
      83             : 
      84             :   nsresult Init();
      85             : 
      86             :   // Returns a nsGlobalNameStruct for aName, or null if one is not
      87             :   // found. The returned nsGlobalNameStruct is only guaranteed to be
      88             :   // valid until the next call to any of the methods in this class.
      89             :   // It also returns a pointer to the string buffer of the classname
      90             :   // in the nsGlobalNameStruct.
      91             :   const nsGlobalNameStruct* LookupName(const nsAString& aName,
      92             :                                        const char16_t **aClassName = nullptr);
      93             : 
      94             :   nsresult RegisterClassName(const char *aClassName,
      95             :                              int32_t aDOMClassInfoID,
      96             :                              bool aPrivileged,
      97             :                              bool aXBLAllowed,
      98             :                              const char16_t **aResult);
      99             : 
     100             :   nsresult RegisterClassProto(const char *aClassName,
     101             :                               const nsIID *aConstructorProtoIID,
     102             :                               bool *aFoundOld);
     103             : 
     104           0 :   class NameIterator : public PLDHashTable::Iterator
     105             :   {
     106             :   public:
     107             :     typedef PLDHashTable::Iterator Base;
     108           0 :     explicit NameIterator(PLDHashTable* aTable) : Base(aTable) {}
     109             :     NameIterator(NameIterator&& aOther) : Base(mozilla::Move(aOther.mTable)) {}
     110             : 
     111           0 :     const GlobalNameMapEntry* Get() const
     112             :     {
     113           0 :       return static_cast<const GlobalNameMapEntry*>(Base::Get());
     114             :     }
     115             : 
     116             :   private:
     117             :     NameIterator() = delete;
     118             :     NameIterator(const NameIterator&) = delete;
     119             :     NameIterator& operator=(const NameIterator&) = delete;
     120             :     NameIterator& operator=(const NameIterator&&) = delete;
     121             :   };
     122             : 
     123           0 :   NameIterator GlobalNameIter()    { return NameIterator(&mGlobalNames); }
     124             : 
     125             :   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
     126             : 
     127             : private:
     128             :   virtual ~nsScriptNameSpaceManager();
     129             : 
     130             :   // Adds a new entry to the hash and returns the nsGlobalNameStruct
     131             :   // that aKey will be mapped to. If mType in the returned
     132             :   // nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
     133             :   // already existed.
     134             :   nsGlobalNameStruct *AddToHash(const char *aKey,
     135             :                                 const char16_t **aClassName = nullptr);
     136             : 
     137             :   // Removes an existing entry from the hash.
     138             :   void RemoveFromHash(const nsAString *aKey);
     139             : 
     140             :   nsresult FillHash(nsICategoryManager *aCategoryManager,
     141             :                     const char *aCategory);
     142             : 
     143             :   /**
     144             :    * Add a new category entry into the hash table.
     145             :    * Only some categories can be added (see the beginning of the definition).
     146             :    * The other ones will be ignored.
     147             :    *
     148             :    * @aCategoryManager Instance of the category manager service.
     149             :    * @aCategory        Category where the entry comes from.
     150             :    * @aEntry           The entry that should be added.
     151             :    */
     152             :   nsresult AddCategoryEntryToHash(nsICategoryManager* aCategoryManager,
     153             :                                   const char* aCategory,
     154             :                                   nsISupports* aEntry);
     155             : 
     156             :   /**
     157             :    * Remove an existing category entry from the hash table.
     158             :    * Only some categories can be removed (see the beginning of the definition).
     159             :    * The other ones will be ignored.
     160             :    *
     161             :    * @aCategory        Category where the entry will be removed from.
     162             :    * @aEntry           The entry that should be removed.
     163             :    */
     164             :   nsresult RemoveCategoryEntryFromHash(nsICategoryManager* aCategoryManager,
     165             :                                        const char* aCategory,
     166             :                                        nsISupports* aEntry);
     167             : 
     168             :   // common helper for AddCategoryEntryToHash and RemoveCategoryEntryFromHash
     169             :   nsresult OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
     170             :                                     const char* aCategory,
     171             :                                     nsISupports* aEntry,
     172             :                                     bool aRemove);
     173             : 
     174             :   PLDHashTable mGlobalNames;
     175             : };
     176             : 
     177             : #endif /* nsScriptNameSpaceManager_h__ */

Generated by: LCOV version 1.13