OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ |
| 6 #define CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "storage/browser/quota/quota_manager.h" |
| 10 |
| 11 // Asynchronously fetches the amount of storage used by websites. |
| 12 class StorageInfoFetcher : |
| 13 public base::RefCountedThreadSafe<StorageInfoFetcher> { |
| 14 public: |
| 15 // Observer interface for monitoring StorageInfoFetcher. |
| 16 class Observer { |
| 17 public: |
| 18 // Called when the storage has been calculated. |
| 19 virtual void OnGetUsageInfo(const storage::UsageInfoEntries& entries) = 0; |
| 20 |
| 21 protected: |
| 22 virtual ~Observer() {} |
| 23 }; |
| 24 |
| 25 explicit StorageInfoFetcher(storage::QuotaManager* quota_manager); |
| 26 |
| 27 // Asynchronously fetches the StorageInfo. |
| 28 void Run(); |
| 29 |
| 30 void AddObserver(Observer* observer); |
| 31 void RemoveObserver(Observer* observer); |
| 32 |
| 33 private: |
| 34 virtual ~StorageInfoFetcher(); |
| 35 |
| 36 friend class base::RefCountedThreadSafe<StorageInfoFetcher>; |
| 37 |
| 38 // Fetches the usage information. |
| 39 void GetUsageInfo(const storage::GetUsageInfoCallback& callback); |
| 40 |
| 41 // Called when usage information is available. |
| 42 void OnGetUsageInfoInternal(const storage::UsageInfoEntries& entries); |
| 43 |
| 44 // Reports back to all observers that information is available. |
| 45 void InvokeCallback(); |
| 46 |
| 47 // All clients observing this class. |
| 48 base::ObserverList<Observer> observers_; |
| 49 |
| 50 // The quota manager to use to calculate the storage usage. |
| 51 storage::QuotaManager* quota_manager_; |
| 52 |
| 53 // Hosts and their usage. |
| 54 storage::UsageInfoEntries entries_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(StorageInfoFetcher); |
| 57 }; |
| 58 |
| 59 #endif // CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_ |
OLD | NEW |