/** * Initialize the tracker. */ nsresult DiscardTracker::Initialize() { nsresult rv; // Set up the list. Head<->Sentinel<->Tail sHead.curr = sTail.curr = sSentinel.curr = nsnull; sHead.prev = sTail.next = nsnull; sHead.next = sTail.prev = &sSentinel; sSentinel.prev = &sHead; sSentinel.next = &sTail; // Load the timeout ReloadTimeout(); // Create and start the timer nsCOMPtr<nsITimer> t = do_CreateInstance("@mozilla.org/timer;1"); NS_ENSURE_TRUE(t, NS_ERROR_OUT_OF_MEMORY); t.forget(&sTimer); rv = TimerOn(); NS_ENSURE_SUCCESS(rv, rv); // Mark us as initialized sInitialized = PR_TRUE; return NS_OK; }
/** * Initialize the tracker. */ nsresult DiscardTracker::Initialize() { // Watch the timeout pref for changes. Preferences::RegisterCallback(DiscardTimeoutChangedCallback, sDiscardTimeoutPref); // Create the timer. sTimer = do_CreateInstance("@mozilla.org/timer;1"); // Create a lock for safegarding the 64-bit sCurrentDecodedImageBytes sAllocationLock = PR_NewLock(); // Create a lock for the node list. MOZ_ASSERT(!sNodeListMutex); sNodeListMutex = new Mutex("image::DiscardTracker"); // Mark us as initialized sInitialized = true; // Read the timeout pref and start the timer. ReloadTimeout(); return NS_OK; }
/** * Initialize the tracker. */ nsresult DiscardTracker::Initialize() { MOZ_ASSERT(NS_IsMainThread()); // Watch the timeout pref for changes. Preferences::RegisterCallback(DiscardTimeoutChangedCallback, sDiscardTimeoutPref); Preferences::AddUintVarCache(&sMaxDecodedImageKB, "image.mem.max_decoded_image_kb", 50 * 1024); // Create the timer. sTimer = do_CreateInstance("@mozilla.org/timer;1"); // Create a lock for safegarding the 64-bit sCurrentDecodedImageBytes sAllocationLock = PR_NewLock(); // Mark us as initialized sInitialized = true; // Read the timeout pref and start the timer. ReloadTimeout(); return NS_OK; }
/** * Initialize the tracker. */ nsresult DiscardTracker::Initialize() { // Watch the timeout pref for changes. Preferences::RegisterCallback(DiscardTimeoutChangedCallback, sDiscardTimeoutPref); Preferences::AddUintVarCache(&sMaxDecodedImageKB, "image.mem.max_decoded_image_kb", 50 * 1024); // Create the timer. sTimer = do_CreateInstance("@mozilla.org/timer;1"); // Mark us as initialized sInitialized = true; // Read the timeout pref and start the timer. ReloadTimeout(); return NS_OK; }