mozilla-b2g/gaia — pull request #1866 by benfrancis (2012-06-21 22:45:39+00:00)
Title: Adding full favicon support for browser history

OK, this is surprisingly complicated for what it is, so let me summarise:
* The browser caches favicons offline as binary blobs in IndexedDB
* Each favicon is stored just once, in a favicon object store (keyed by favicon URI), so that we're not storing duplicate binary blobs for every single URL we visit which has the same icon
* Favicons are cached for one day so that we don't obsessively reload the same icon over and over again over the network, but so that it can be updated relatively quickly if a site changes its icon
* If a page finishes loading and no iconchanged event was received, the browser tries to load an icon from /favicon.ico at the root of the host (the de-facto standard)
* The browser tracks failed favicon loads and won't try and load a failed icon from the same URL twice on a single day
* When the history is rendered, a default favicon image is displayed if the page has no favicon

This is largely inspired by the way the favicon service works in Firefox.