Open-Source Wikis

/

Gecko

/

Systems

/

Storage and IndexedDB

mozilla/gecko-dev

Storage and IndexedDB

Storage in Firefox spans several subsystems: a SQLite wrapper, IndexedDB, the Cache API, localStorage/sessionStorage, the Origin Private File System, the unified quota manager, and Places (the bookmarks/history database).

Layers

graph TD
    Web[Web APIs<br/>indexedDB, caches, localStorage,<br/>FileSystem (OPFS), getDirectory] --> Quota[QuotaManager]
    Quota --> IDB[indexedDB engine]
    Quota --> CacheAPI[Cache API]
    Quota --> LS[localStorage / sessionStorage]
    Quota --> OPFS[Origin Private File System]
    IDB --> Storage[storage/ wrapper]
    Storage --> SQLite[SQLite]
    LS --> SQLite
    Cookies[Cookies] --> SQLite
    Places[Places (bookmarks/history)] --> SQLite

SQLite wrapper

storage/ wraps the vendored SQLite library with mozIStorageConnection, providing async statements, async results, and a connection pool.

IndexedDB

dom/indexedDB/ implements IndexedDB end-to-end. Each origin gets its own SQLite database under the profile's storage/ directory. The implementation is heavily multi-process — storage operations route through the parent or socket process via PIPC actors.

Cache API and Service Workers

dom/cache/ implements the Cache and CacheStorage interfaces backed by SQLite + a content-addressable file store.

Quota manager

dom/quota/ is the single source of truth for storage usage per origin. It enforces eviction, calculates total/used, and is the single API every web-storage subsystem registers with.

localStorage / sessionStorage

dom/localstorage/ holds the modern localStorage implementation (a process-shared IPC actor with SQLite backing). dom/storage/ holds session storage.

Cookies

Cookies are persisted in cookies.sqlite. See Networking.

Places

toolkit/components/places/ is the bookmarks + history database, also SQLite-backed. The schema is in Database.cpp. URL queries use the places:// URI scheme and the History and Bookmarks JS APIs.

Profile layout

Inside the user's profile directory:

profile/
├── places.sqlite           # bookmarks + history
├── cookies.sqlite          # cookies
├── permissions.sqlite      # permissions
├── content-prefs.sqlite    # content prefs (zoom level, etc.)
├── webappsstore.sqlite     # localStorage (legacy)
├── storage/
│   ├── default/<origin>/   # quota-managed per-origin storage
│   ├── permanent/
│   └── temporary/
├── prefs.js
├── ...

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Storage and IndexedDB – Gecko wiki | Factory