Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* Implementation of xptiWorkingSet. */
8 #include "mozilla/XPTInterfaceInfoManager.h"
10 #include "xptiprivate.h"
11 #include "nsString.h"
13 using namespace mozilla;
15 #define XPTI_STRUCT_ARENA_BLOCK_SIZE (1024 * 16)
16 #define XPTI_HASHTABLE_SIZE 2048
18 XPTInterfaceInfoManager::xptiWorkingSet::xptiWorkingSet()
19 : mTableReentrantMonitor("xptiWorkingSet::mTableReentrantMonitor")
20 , mIIDTable(XPTI_HASHTABLE_SIZE)
21 , mNameTable(XPTI_HASHTABLE_SIZE)
22 {
23 MOZ_COUNT_CTOR(xptiWorkingSet);
25 gXPTIStructArena = XPT_NewArena(XPTI_STRUCT_ARENA_BLOCK_SIZE, sizeof(double),
26 "xptiWorkingSet structs");
27 }
29 static PLDHashOperator
30 xpti_Invalidator(const char* keyname, xptiInterfaceEntry* entry, void* arg)
31 {
32 entry->LockedInvalidateInterfaceInfo();
33 return PL_DHASH_NEXT;
34 }
36 void
37 XPTInterfaceInfoManager::xptiWorkingSet::InvalidateInterfaceInfos()
38 {
39 ReentrantMonitorAutoEnter monitor(mTableReentrantMonitor);
40 mNameTable.EnumerateRead(xpti_Invalidator, nullptr);
41 }
43 XPTInterfaceInfoManager::xptiWorkingSet::~xptiWorkingSet()
44 {
45 MOZ_COUNT_DTOR(xptiWorkingSet);
47 // Only destroy the arena if we're doing leak stats. Why waste shutdown
48 // time touching pages if we don't have to?
49 #ifdef NS_FREE_PERMANENT_DATA
50 XPT_DestroyArena(gXPTIStructArena);
51 #endif
52 }
54 XPTArena* gXPTIStructArena;