tree: d28f66c819cddaa1695197b57636fa5c4dfa6578 [path history] [tgz]
  2. DEPS
  6. cached_storage_area.h
  8. docs/
  10. dom_window_storage.h
  12. dom_window_storage_controller.h
  14. inspector_dom_storage_agent.h
  15. storage.idl
  17. storage_area.h
  19. storage_area_map.h
  22. storage_controller.h
  25. storage_event.h
  26. storage_event.idl
  27. storage_event_init.idl
  29. storage_namespace.h
  31. testing/
  32. window_storage.idl


This directory contains the renderer side implementation of the DOM Storage API. This API is defined in the HTML Spec's section on Web Storage.

The browser side code for this lives in content/browser/dom_storage/.

TODO(dmurph): Delete this paragraph after onion-souping is complete. This file describes only the post-onion-souped version of the code, where features::kOnionSoupDOMStorage is turned on. This is not yet the default.

Class Responsibilities


This implements the partial Window interface in window_storage.idl, and provides bindings for window.localStorage and window.sessionStorage to the web platform. This creates & owns the StorageArea objects.


This implements the WebIDL Storage interface in storage.idl, and provides access to localStorage and sessionStorage. This class holds a shared reference to a CachedStorageArea (which can be shared between multiple StorageAreas), and basically delegates most calls here.

This is also temporarily created & used by InspectorDOMStorageAgent to make modifications to local & session storage.


This is responsible for

  • keeping a local cache of the localStorage or sessionStorage data (which it does using a StorageAreaMap),
  • keeping track of Sources that are using this cached storage area (which are StorageAreas),
  • loading and saving data with a StorageArea mojo interface, and
  • observing changes from that StorageArea interface and communicating these to all Sources, and InspectorEventListeners.


This represents an in-memory cache of a storage area. It holds key-value storage and keeps track of the total size of the bytes stored.


This class is responsible for

  • creating & caching CachedStorageAreas on a per-origin basis,
  • holding weak references to DOMStorageInspectorAgents & telling them when a storage event was dispatched,
  • interacting with the StoragePartitionService and SessionStorageNamespace mojo interfaces to create StorageArea mojo ptrs for the CachedStorageAreas and clone namespaces for SessionStorage.
  • accounting for all storage used in it's cached areas, and
  • cleaning up unused caches areas on demand.

There are two versions of this class - one version is the SessionStorage version, which holds a SessionStorageNamespace mojo ptr and lives on a Page as a Page Supplement. The other version is for LocalStorage, which just uses the StoragePartitionService to open the StorageAreas, and is owned by the StorageController.


This is a singleton that is responsible for keeping track of all StorageNamespaces and provide access to the functionality of it's single LocalStorage StorageNamespace that it owns. It holds weak references to all of the SessionStorage StorageNamespaces so it can account for the total amount of memory used by all of DOMStorage. If this gets too high, it can ask all namespaces to prune all unused CacheStorageAreas.


This is used by the Inspector (DevTools) code to listen to and modify local & session storage. The StorageNamespace class allows these agents to be added & removed by the Inspector system, and all events that are dispatched on that namespace are sent to its InspectorDOMStorageAgents.

This class also creates a temporary StorageArea to query & modify local & session storage.

Class Ownership Structure

StorageArea lives on the window. Instances of this class hold a reference to a CachedStorageArea instance. All StorageArea instances representing the same area use the same CachedStorageArea instance (which is reference counted). Two classes are used to create and manage CachedStorageAreas - the StorageController, and StorageNamespaces.

The StorageNamespace represents a SessionStorage namespace, but can also be used for LocalStorage. It creates & manages CachedStorageAreas per-origin. It keeps a reference to all CachedStorageAreas it creates for memory accounting and object re-use. It also contains weak references to InspectorDOMStorageAgents that it notifies when StorageEvents are dispatched.

SessionStorage StorageNamespace objects live as supplements on the Page, so each Page owns one. The LocalStorage StorageNamespace object lives in the StorageController.

The StorageController is a singleton. It owns the LocalStorage StorageNamespace, and hold weak references to each SessionStorage StorageNamespace.

Finally - InspectorDomStorageAgent will create temporary StorageArea objects when it wants to query or modify DOMStorage.

Object ownership graph Image Source