xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* vim: set ts=4 et sw=4 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/. */
     7 #ifndef mozilla_XPTInterfaceInfoManager_h_
     8 #define mozilla_XPTInterfaceInfoManager_h_
    10 #include "nsIInterfaceInfoManager.h"
    11 #include "nsIMemoryReporter.h"
    13 #include "mozilla/MemoryReporting.h"
    14 #include "mozilla/Mutex.h"
    15 #include "mozilla/ReentrantMonitor.h"
    16 #include "nsDataHashtable.h"
    18 template<typename T> class nsCOMArray;
    19 class nsIMemoryReporter;
    20 class XPTHeader;
    21 class XPTInterfaceDirectoryEntry;
    22 class xptiInterfaceEntry;
    23 class xptiInterfaceInfo;
    24 class xptiTypelibGuts;
    26 namespace mozilla {
    28 class XPTInterfaceInfoManager MOZ_FINAL
    29     : public nsIInterfaceInfoManager
    30     , public nsIMemoryReporter
    31 {
    32     NS_DECL_THREADSAFE_ISUPPORTS
    33     NS_DECL_NSIINTERFACEINFOMANAGER
    34     NS_DECL_NSIMEMORYREPORTER
    36 public:
    37     // GetSingleton() is infallible
    38     static XPTInterfaceInfoManager* GetSingleton();
    39     static void FreeInterfaceInfoManager();
    41     void GetScriptableInterfaces(nsCOMArray<nsIInterfaceInfo>& aInterfaces);
    43     void RegisterBuffer(char *buf, uint32_t length);
    45     static Mutex& GetResolveLock()
    46     {
    47         return GetSingleton()->mResolveLock;
    48     }
    50     xptiInterfaceEntry* GetInterfaceEntryForIID(const nsIID *iid);
    52     size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
    54 private:
    55     XPTInterfaceInfoManager();
    56     ~XPTInterfaceInfoManager();
    58     void InitMemoryReporter();
    60     void RegisterXPTHeader(XPTHeader* aHeader);
    62     // idx is the index of this interface in the XPTHeader
    63     void VerifyAndAddEntryIfNew(XPTInterfaceDirectoryEntry* iface,
    64                                 uint16_t idx,
    65                                 xptiTypelibGuts* typelib);
    67 private:
    69     class xptiWorkingSet
    70     {
    71     public:
    72         xptiWorkingSet();
    73         ~xptiWorkingSet();
    75         bool IsValid() const;
    77         void InvalidateInterfaceInfos();
    78         void ClearHashTables();
    80         // utility methods...
    82         enum {NOT_FOUND = 0xffffffff};
    84         // Directory stuff...
    86         uint32_t GetDirectoryCount();
    87         nsresult GetCloneOfDirectoryAt(uint32_t i, nsIFile** dir);
    88         nsresult GetDirectoryAt(uint32_t i, nsIFile** dir);
    89         bool     FindDirectory(nsIFile* dir, uint32_t* index);
    90         bool     FindDirectoryOfFile(nsIFile* file, uint32_t* index);
    91         bool     DirectoryAtMatchesPersistentDescriptor(uint32_t i, const char* desc);
    93     private:
    94         uint32_t        mFileCount;
    95         uint32_t        mMaxFileCount;
    97     public:
    98         // XXX make these private with accessors
    99         // mTableMonitor must be held across:
   100         //  * any read from or write to mIIDTable or mNameTable
   101         //  * any writing to the links between an xptiInterfaceEntry
   102         //    and its xptiInterfaceInfo (mEntry/mInfo)
   103         mozilla::ReentrantMonitor mTableReentrantMonitor;
   104         nsDataHashtable<nsIDHashKey, xptiInterfaceEntry*> mIIDTable;
   105         nsDataHashtable<nsDepCharHashKey, xptiInterfaceEntry*> mNameTable;
   106     };
   108     // XXX xptiInterfaceInfo want's to poke at the working set itself
   109     friend class ::xptiInterfaceInfo;
   110     friend class ::xptiInterfaceEntry;
   111     friend class ::xptiTypelibGuts;
   113     xptiWorkingSet               mWorkingSet;
   114     Mutex                        mResolveLock;
   115 };
   117 }
   119 #endif

mercurial