Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2904)

Unified Diff: chrome/browser/storage/storage_info_fetcher.h

Issue 1607483005: Show data usage on Site Details (MDSettings) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Augment test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/storage/storage_info_fetcher.h
diff --git a/chrome/browser/storage/storage_info_fetcher.h b/chrome/browser/storage/storage_info_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..1f348bd33da2230bd6322fc4f37b81aee0837913
--- /dev/null
+++ b/chrome/browser/storage/storage_info_fetcher.h
@@ -0,0 +1,59 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_
+#define CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_
+
+#include "base/memory/ref_counted.h"
+#include "storage/browser/quota/quota_manager.h"
+
+// Asynchronously fetches the amount of storage used by websites.
+class StorageInfoFetcher :
+ public base::RefCountedThreadSafe<StorageInfoFetcher> {
+ public:
+ // Observer interface for monitoring StorageInfoFetcher.
+ class Observer {
+ public:
+ // Called when the storage has been calculated.
+ virtual void OnGetUsageInfo(const storage::UsageInfoEntries& entries) = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ explicit StorageInfoFetcher(storage::QuotaManager* quota_manager);
+
+ // Asynchronously fetches the StorageInfo.
+ void Run();
+
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
+ private:
+ virtual ~StorageInfoFetcher();
+
+ friend class base::RefCountedThreadSafe<StorageInfoFetcher>;
+
+ // Fetches the usage information.
+ void GetUsageInfo(const storage::GetUsageInfoCallback& callback);
+
+ // Called when usage information is available.
+ void OnGetUsageInfoInternal(const storage::UsageInfoEntries& entries);
+
+ // Reports back to all observers that information is available.
+ void InvokeCallback();
+
+ // All clients observing this class.
+ base::ObserverList<Observer> observers_;
+
+ // The quota manager to use to calculate the storage usage.
+ storage::QuotaManager* quota_manager_;
+
+ // Hosts and their usage.
+ storage::UsageInfoEntries entries_;
+
+ DISALLOW_COPY_AND_ASSIGN(StorageInfoFetcher);
+};
+
+#endif // CHROME_BROWSER_STORAGE_STORAGE_INFO_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698