Chromium Code Reviews
DescriptionExtensionStorageMonitor: use smaller, self-registering StorageObservers
Before this change, StorageEventObserver was a single observer that tried to
install a single observation per origin. However, this was problematic:
- Two hosted apps can have the same storage origin.
ExtensionsLoadMultipleTest.Test, for example, sets up a case where this
occurs. The second registration would overwrite the state for the first, and
it's possible that a dangling pointer would result (if the first registration
had should_uma = true, and the second registration had should_uma = false).
Also, disabling the second extension would leave the first extension
unobserved.
- The deregistration code, RemoveStorageObserverForFilter, didn't correctly
uninstall the kStorageTypeTemporary filter, causing bug 716426.
To fix this StorageEventObserver is broken up into two classes:
- SingleExtensionStorageObserver, which monitors the storage usage of
one extension. This class registers/deregisters itself as an observer
on creation/destruction (RAII pattern).
- ExtensionStorageMonitorIOHelper, which keeps a container of
SingleExtensionStorageObservers, one per extension.
Using RAII allows us to rip out the RemoveStorageObserverForFilter codepath
entirely from StorageMonitor and QuotaManager.
BUG=716426
TEST=ExtensionStorageMonitorTest
Review-Url: https://codereview.chromium.org/2923663002
Cr-Commit-Position: refs/heads/master@{#479546}
Committed: https://chromium.googlesource.com/chromium/src/+/e3873dfc2212de0b9b0784315b30b38ce0f46fbc
Patch Set 1 #Patch Set 2 : Rename. #Patch Set 3 : Tweak for diff alignment. #Patch Set 4 : Tweak for patch alignment. #Patch Set 5 : Fix unittests. #Patch Set 6 : std::move #Patch Set 7 : override #Patch Set 8 : Add two browsertests that fail prior to this change. #Patch Set 9 : Remove over-aggressive CHECK() on erase. #Patch Set 10 : Fiddling. #
Total comments: 21
Patch Set 11 : constexpr #Patch Set 12 : Accidentally a word #Patch Set 13 : Use 'a'.repeat #
Total comments: 2
Patch Set 14 : Remove lame comment. #Messages
Total messages: 53 (45 generated)
|