tree: 57c1e9827a9988376484184dc065f0eab3b04a22 [path history] [tgz]
  1. DIR_METADATA
  2. OWNERS
  3. README.md
  4. client_usage_tracker.cc
  5. client_usage_tracker.h
  6. mojo_quota_client_wrapper.cc
  7. mojo_quota_client_wrapper.h
  8. quota_callbacks.h
  9. quota_client.h
  10. quota_client_type.cc
  11. quota_client_type.h
  12. quota_database.cc
  13. quota_database.h
  14. quota_database_unittest.cc
  15. quota_device_info_helper.cc
  16. quota_device_info_helper.h
  17. quota_features.cc
  18. quota_features.h
  19. quota_macros.h
  20. quota_manager.cc
  21. quota_manager.h
  22. quota_manager_impl.cc
  23. quota_manager_impl.h
  24. quota_manager_proxy.cc
  25. quota_manager_proxy.h
  26. quota_manager_unittest.cc
  27. quota_override_handle.cc
  28. quota_override_handle.h
  29. quota_settings.cc
  30. quota_settings.h
  31. quota_settings_unittest.cc
  32. quota_task.cc
  33. quota_task.h
  34. quota_temporary_storage_evictor.cc
  35. quota_temporary_storage_evictor.h
  36. quota_temporary_storage_evictor_unittest.cc
  37. special_storage_policy.cc
  38. special_storage_policy.h
  39. storage_policy_observer.cc
  40. storage_policy_observer.h
  41. usage_tracker.cc
  42. usage_tracker.h
  43. 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 (AppCache, 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-profile 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 webkitStorageInfo.requestQuota(PERSISTENT,...).

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