static JSDHashOperator WrappedNativeShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32_t number, void *arg) { ShutdownData* data = (ShutdownData*) arg; XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value; if (wrapper->IsValid()) { wrapper->SystemIsBeingShutDown(); data->wrapperCount++; } return JS_DHASH_REMOVE; }
WrappedNativeShutdownEnumerator(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number, void *arg) { ShutdownData* data = (ShutdownData*) arg; XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value; if(wrapper->IsValid()) { if(wrapper->HasProto() && !wrapper->HasSharedProto()) data->nonSharedProtoCount++; wrapper->SystemIsBeingShutDown(data->cx); data->wrapperCount++; } return JS_DHASH_REMOVE; }
//static void XPCWrappedNativeScope::SystemIsBeingShutDown() { int liveScopeCount = 0; XPCWrappedNativeScope* cur; // First move all the scopes to the dying list. cur = gScopes; while (cur) { XPCWrappedNativeScope* next = cur->mNext; cur->mNext = gDyingScopes; gDyingScopes = cur; cur = next; liveScopeCount++; } gScopes = nullptr; // We're forcibly killing scopes, rather than allowing them to go away // when they're ready. As such, we need to do some cleanup before they // can safely be destroyed. for (cur = gDyingScopes; cur; cur = cur->mNext) { // Give the Components object a chance to try to clean up. if (cur->mComponents) cur->mComponents->SystemIsBeingShutDown(); // Walk the protos first. Wrapper shutdown can leave dangling // proto pointers in the proto map. for (auto i = cur->mWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) { auto entry = static_cast<ClassInfo2WrappedNativeProtoMap::Entry*>(i.Get()); entry->value->SystemIsBeingShutDown(); i.Remove(); } for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) { auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get()); XPCWrappedNative* wrapper = entry->value; if (wrapper->IsValid()) { wrapper->SystemIsBeingShutDown(); } i.Remove(); } } // Now it is safe to kill all the scopes. KillDyingScopes(); }