tree: 91bd8a437c8279f7e33656b0c6b29898ffcbdb5b [path history] [tgz]
  1. BUILD.gn
  2. client_usage_tracker.cc
  3. client_usage_tracker.h
  4. COMMON_METADATA
  5. DIR_METADATA
  6. OWNERS
  7. quota_availability.h
  8. quota_callbacks.h
  9. quota_client_type.cc
  10. quota_client_type.h
  11. quota_database.cc
  12. quota_database.h
  13. quota_database_migrations.cc
  14. quota_database_migrations.h
  15. quota_database_migrations_unittest.cc
  16. quota_database_unittest.cc
  17. quota_device_info_helper.cc
  18. quota_device_info_helper.h
  19. quota_features.cc
  20. quota_features.h
  21. quota_internals.mojom
  22. quota_macros.h
  23. quota_manager.cc
  24. quota_manager.h
  25. quota_manager_impl.cc
  26. quota_manager_impl.h
  27. quota_manager_observer.mojom
  28. quota_manager_proxy.cc
  29. quota_manager_proxy.h
  30. quota_manager_proxy_unittest.cc
  31. quota_manager_unittest.cc
  32. quota_override_handle.cc
  33. quota_override_handle.h
  34. quota_settings.cc
  35. quota_settings.h
  36. quota_settings_unittest.cc
  37. quota_task.cc
  38. quota_task.h
  39. quota_temporary_storage_evictor.cc
  40. quota_temporary_storage_evictor.h
  41. quota_temporary_storage_evictor_unittest.cc
  42. README.md
  43. special_storage_policy.cc
  44. special_storage_policy.h
  45. storage_directory.cc
  46. storage_directory.h
  47. storage_directory_unittest.cc
  48. storage_directory_util.cc
  49. storage_directory_util.h
  50. storage_policy_observer.cc
  51. storage_policy_observer.h
  52. storage_policy_observer_unittest.cc
  53. usage_tracker.cc
  54. usage_tracker.h
  55. usage_tracker_unittest.cc
storage/browser/quota/README.md

Overview

The quota system's primary role is to set and enforce limits on disk usage at both the browser level, and at the origin level (see ./quota_settings.cc for these limit values). The quota system manages disk usage only for certain web platform storage APIs.

In order for a storage backend to integrate with the quota system, it must implement the QuotaClient interface.

Most work on the quota system is currently done on the browser process' IO thread. There are plans for quota to be moved to the Storage Service, which will run on its own process on desktop platforms.

Key Components

Interface

The quota system's interface is comprised of the following classes:

QuotaManagerImpl

The “heart” of the quota system. This class lives on the browser process' IO thread, but is primarily accessed through QuotaManagerProxy, which handles thread hops. In the future, QuotaManagerProxy will turn into mojom::QuotaManager, and the quota system will be accessed exclusively via mojo.

QuotaClient

This interface must be implemented by any storage backend that wants to integrate with the quota system. This is probably the most used interface from outside of the quota system.

PaddingKey

Helpers for computing quota usage for opaque resources. Features that store opaque resources (e.g. Cache Storage) should use these helpers to avoid leaking cross-origin information via the quota usage they report.

SpecialStoragePolicy

Hook that allows browser features (currently Extensions and Chrome Apps) to change an origin's quota.

Implementation

The quota system's implementation is made up of the following components:

UsageTracker, ClientUsageTracker

QuotaManagerImpl helpers that distribute tasks (e.g. measure an origin's quota usage) across QuotaClient instances, and cache results as needed.

QuotaDatabase

Stores persistent information in a per-StoragePartition SQLite database. Currently stores a few bits of implementation details, and will likely be expanded to cover Storage Buckets. The currently stored information is a usage count, last-modified-time, and last-accessed-time for each origin (used to implement LRU eviction on storage pressure, and Clear Site Data with a time filter), and quota granted via the deprecated API navigator.webkitPersistentStorage.requestQuota(1000, ...).

QuotaTemporaryStorageEvictor

Handles eviction and records stats about eviction rounds.

QuotaTask

Implementation detail of QuotaManagerImpl.

Glossary

Storage Pressure

A device is said to be under storage pressure when it is close to capacity. Storage pressure is used to signal a couple of behaviors in the quota system:

  • Eviction
  • The QuotaChange event
  • Triggering storage pressure UI (implementation specific)

Eviction

This is the process by which the quota system cleans up app‘s data as disk usage gets close to the disk’s capacity.

Resources