tree: 4f8ef3a2c47d35f6ca7bd768a698741658557bd5 [path history] [tgz]
  1. test/
  2. BUILD.gn
  3. DEPS
  4. dom_storage_area.cc
  5. dom_storage_area.h
  6. dom_storage_area_unittest.cc
  7. dom_storage_browsertest.cc
  8. dom_storage_context_impl.cc
  9. dom_storage_context_impl.h
  10. dom_storage_context_impl_unittest.cc
  11. dom_storage_context_wrapper.cc
  12. dom_storage_context_wrapper.h
  13. dom_storage_context_wrapper_unittest.cc
  14. dom_storage_database.cc
  15. dom_storage_database.h
  16. dom_storage_database_adapter.h
  17. dom_storage_database_unittest.cc
  18. dom_storage_host.cc
  19. dom_storage_host.h
  20. dom_storage_message_filter.cc
  21. dom_storage_message_filter.h
  22. dom_storage_namespace.cc
  23. dom_storage_namespace.h
  24. dom_storage_task_runner.cc
  25. dom_storage_task_runner.h
  26. local_storage_context_mojo.cc
  27. local_storage_context_mojo.h
  28. local_storage_context_mojo_unittest.cc
  29. local_storage_database.proto
  30. OWNERS
  31. README.md
  32. session_storage_area_impl.cc
  33. session_storage_area_impl.h
  34. session_storage_area_impl_unittest.cc
  35. session_storage_context_mojo.cc
  36. session_storage_context_mojo.h
  37. session_storage_context_mojo_unittest.cc
  38. session_storage_data_map.cc
  39. session_storage_data_map.h
  40. session_storage_data_map_unittest.cc
  41. session_storage_database.cc
  42. session_storage_database.h
  43. session_storage_database_adapter.cc
  44. session_storage_database_adapter.h
  45. session_storage_database_unittest.cc
  46. session_storage_metadata.cc
  47. session_storage_metadata.h
  48. session_storage_metadata_unittest.cc
  49. session_storage_namespace_impl.cc
  50. session_storage_namespace_impl.h
  51. session_storage_namespace_impl_mojo.cc
  52. session_storage_namespace_impl_mojo.h
  53. session_storage_namespace_impl_mojo_unittest.cc
  54. storage_area_impl.cc
  55. storage_area_impl.h
  56. storage_area_impl_unittest.cc
content/browser/dom_storage/README.md

DOM Storage

Under Contruction

Session Storage (Mojo)

Under Contruction

The browser manages the lifetime of session storage namespaces with SessionStorageNamespaceImpl.

The object calls SessionStorageContextMojo::CreateSessionNamespace when it is created, and SessionStorageContextMojo::DeleteSessionNamespace when it's destructed.

This object is primarily held by both the NavigationControllerImpl and in the ContentPlatformSpecificTabData which is used to restore tabs. The services stores recent tab closures for possible browser restore here.

In the future when it's fully mojo-ified, the lifetime will be managed by the mojo SessionStorageNamespace which can be passed to the renderer and the session restore service. There will always need to be an ID though as we save this ID to disk in the session restore service.

High Level Access And Lifetime Flow

  1. Before a renderer tab is opened, a SessionStorageNamespaceImpl object is created, which in turn calls SessionStorageContextMojo::CreateSessionNamespace.
    • This can happen by either navigation or session restore.
  2. The following can happen in any order:
    • Renderer creation, usage, and destruction
      • The session_namespace_id is sent to the renderer, which uses StorageParitionService to access storage.
      • The renderer is destroyed, calling SessionStorageContextMojo::DeleteSessionNamespace.
        • If SetShouldPersist(true) was not called (or called with false), then the data is deleted from disk.
    • SetShouldPersist(true) is called from the session restores service, which means the data should NOT be deleted on disk when the namespace is destroyed. This is called for all tabs that the session restore services wants to persist to disk.
    • The session restore service calls DomStorageContext::StartScavengingUnusedSessionStorage to clean up any namespaces that are on disk but were not used by any recreated tab. This is an ‘after startup task’, and usually happens before SetShouldPesist is called.

Possible Edge Case: Persisted Data vs Stale Disk Data

Namespace is created, persisted, destroyed, and then we scavange unused session storage.

Flow:

  1. SessionStorageContextMojo::CreateSessionNamespace
  2. SetShouldPersist(true)
  3. SessionStorageContextMojo::DeleteSessionNamespace
  4. DomStorageContext::StartScavengingUnusedSessionStorage
  5. The data should still reside on disk after scavenging.

The namespace could accidentally be considered a ‘leftover’ namespace by the scavenging algorithm and deleted from disk.

Navigation Details

When navigating from a previous frame, the previous frame will allocate a new session storage id for the new frame, as well as issue the ‘clone’ call here.

The session_namespace_id for a frame's session storage is stored in the CreateNewWindowParams object in frame.mojom.

If the frame wasn't created from a previous frame, the SessionStorage namespace object is created here and the id is accessed here.

Renderer Connection to Session Storage

Renderers use the session_namespace_id from the CreateNewWindowParams. They access session storage by using StoragePartitionService::OpenSessionStorage, and then SessionStorageNamespace::OpenArea with the session_namespace_id.

They can then bind to a LevelDBWrapper on a per-origin basis.

Session Restore Service Interaction

A reference to the session is stored in the ContentPlatformSpecificTabData which is used to restore recently closed tabs. The services stores recent tab closures for possible browser restore here.

When tabs are inserted, the session storage service saves the id to disk here using the commands (which are saved to disk). The session id is also accessed here for saving in commands in TabClosing and BuildCommandsForTab.