diff options
author | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 09:57:09 +0000 |
---|---|---|
committer | tzik@chromium.org <tzik@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-22 09:57:09 +0000 |
commit | ecda2cff476ab84e0b4a6efdd60b2380504d6bb0 (patch) | |
tree | eafe21c55bb18ee96afa05790898ebea382fe64a /webkit | |
parent | d268858ca988c02346e3f0b2ebc43b81f2eb4d72 (diff) | |
download | chromium_src-ecda2cff476ab84e0b4a6efdd60b2380504d6bb0.zip chromium_src-ecda2cff476ab84e0b4a6efdd60b2380504d6bb0.tar.gz chromium_src-ecda2cff476ab84e0b4a6efdd60b2380504d6bb0.tar.bz2 |
Add detailed change event for SpecialStoragePolicy.
This change includes:
- Split single Changed event to Granted, Revoked and Cleared events.
- Add affected origin and changed policy as event parameters.
BUG=220029
TEST=ExtensionSetTest.*, *Quota*, ExtensionSpecialStoragePolicyTest.*
Review URL: https://chromiumcodereview.appspot.com/14238005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195478 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/quota/mock_special_storage_policy.h | 4 | ||||
-rw-r--r-- | webkit/quota/quota_manager_unittest.cc | 2 | ||||
-rw-r--r-- | webkit/quota/special_storage_policy.cc | 14 | ||||
-rw-r--r-- | webkit/quota/special_storage_policy.h | 17 | ||||
-rw-r--r-- | webkit/quota/usage_tracker.cc | 14 | ||||
-rw-r--r-- | webkit/quota/usage_tracker.h | 7 |
6 files changed, 48 insertions, 10 deletions
diff --git a/webkit/quota/mock_special_storage_policy.h b/webkit/quota/mock_special_storage_policy.h index 3a7fcb9..517c582 100644 --- a/webkit/quota/mock_special_storage_policy.h +++ b/webkit/quota/mock_special_storage_policy.h @@ -57,8 +57,8 @@ class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { all_unlimited_ = false; } - void NotifyChanged() { - SpecialStoragePolicy::NotifyObservers(); + void NotifyCleared() { + SpecialStoragePolicy::NotifyCleared(); } protected: diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc index 94efa8b..9d5df47 100644 --- a/webkit/quota/quota_manager_unittest.cc +++ b/webkit/quota/quota_manager_unittest.cc @@ -906,7 +906,7 @@ TEST_F(QuotaManagerTest, GetTemporaryUsageAndQuota_Unlimited) { // Revoke the unlimited rights and make sure the change is noticed. mock_special_storage_policy()->Reset(); - mock_special_storage_policy()->NotifyChanged(); + mock_special_storage_policy()->NotifyCleared(); GetGlobalUsage(kTemp); MessageLoop::current()->RunUntilIdle(); diff --git a/webkit/quota/special_storage_policy.cc b/webkit/quota/special_storage_policy.cc index 8481239..95898a0 100644 --- a/webkit/quota/special_storage_policy.cc +++ b/webkit/quota/special_storage_policy.cc @@ -20,9 +20,19 @@ void SpecialStoragePolicy::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } -void SpecialStoragePolicy::NotifyObservers() { +void SpecialStoragePolicy::NotifyGranted(const GURL& origin, int change_flags) { scoped_refptr<SpecialStoragePolicy> protect(this); - FOR_EACH_OBSERVER(Observer, observers_, OnSpecialStoragePolicyChanged()); + FOR_EACH_OBSERVER(Observer, observers_, OnGranted(origin, change_flags)); +} + +void SpecialStoragePolicy::NotifyRevoked(const GURL& origin, int change_flags) { + scoped_refptr<SpecialStoragePolicy> protect(this); + FOR_EACH_OBSERVER(Observer, observers_, OnRevoked(origin, change_flags)); +} + +void SpecialStoragePolicy::NotifyCleared() { + scoped_refptr<SpecialStoragePolicy> protect(this); + FOR_EACH_OBSERVER(Observer, observers_, OnCleared()); } } // namespace quota diff --git a/webkit/quota/special_storage_policy.h b/webkit/quota/special_storage_policy.h index a7ceed1..89e38a7 100644 --- a/webkit/quota/special_storage_policy.h +++ b/webkit/quota/special_storage_policy.h @@ -24,9 +24,18 @@ namespace quota { class WEBKIT_STORAGE_EXPORT SpecialStoragePolicy : public base::RefCountedThreadSafe<SpecialStoragePolicy> { public: - class Observer { + typedef int StoragePolicy; + enum ChangeFlags { + STORAGE_PROTECTED = 1 << 0, + STORAGE_UNLIMITED = 1 << 1, + }; + + class WEBKIT_STORAGE_EXPORT Observer { public: - virtual void OnSpecialStoragePolicyChanged() = 0; + virtual void OnGranted(const GURL& origin, int change_flags) = 0; + virtual void OnRevoked(const GURL& origin, int change_flags) = 0; + virtual void OnCleared() = 0; + protected: virtual ~Observer(); }; @@ -62,7 +71,9 @@ class WEBKIT_STORAGE_EXPORT SpecialStoragePolicy protected: friend class base::RefCountedThreadSafe<SpecialStoragePolicy>; virtual ~SpecialStoragePolicy(); - void NotifyObservers(); + void NotifyGranted(const GURL& origin, int change_flags); + void NotifyRevoked(const GURL& origin, int change_flags); + void NotifyCleared(); ObserverList<Observer> observers_; }; diff --git a/webkit/quota/usage_tracker.cc b/webkit/quota/usage_tracker.cc index 4d8bb27..96ee3b5 100644 --- a/webkit/quota/usage_tracker.cc +++ b/webkit/quota/usage_tracker.cc @@ -511,7 +511,19 @@ int64 ClientUsageTracker::GetCachedGlobalUnlimitedUsage() { return global_unlimited_usage_; } -void ClientUsageTracker::OnSpecialStoragePolicyChanged() { +void ClientUsageTracker::OnGranted(const GURL& origin, + int change_flags) { + DCHECK(CalledOnValidThread()); + global_unlimited_usage_is_valid_ = false; +} + +void ClientUsageTracker::OnRevoked(const GURL& origin, + int change_flags) { + DCHECK(CalledOnValidThread()); + global_unlimited_usage_is_valid_ = false; +} + +void ClientUsageTracker::OnCleared() { DCHECK(CalledOnValidThread()); global_unlimited_usage_is_valid_ = false; } diff --git a/webkit/quota/usage_tracker.h b/webkit/quota/usage_tracker.h index fc73466..2fe6a71 100644 --- a/webkit/quota/usage_tracker.h +++ b/webkit/quota/usage_tracker.h @@ -113,7 +113,12 @@ class ClientUsageTracker : public SpecialStoragePolicy::Observer, int64 GetCachedHostUsage(const std::string& host) const; int64 GetCachedGlobalUnlimitedUsage(); - virtual void OnSpecialStoragePolicyChanged() OVERRIDE; + + // SpecialStoragePolicy::Observer overrides + virtual void OnGranted(const GURL& origin, int change_flags) OVERRIDE; + virtual void OnRevoked(const GURL& origin, int change_flags) OVERRIDE; + virtual void OnCleared() OVERRIDE; + void NoopHostUsageCallback(int64 usage); bool IsStorageUnlimited(const GURL& origin) const; |