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

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

Issue 1607483005: Show data usage on Site Details (MDSettings) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix update problem 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
« no previous file with comments | « chrome/browser/storage/storage_info_fetcher.h ('k') | chrome/browser/ui/webui/settings/md_settings_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/storage/storage_info_fetcher.cc
diff --git a/chrome/browser/storage/storage_info_fetcher.cc b/chrome/browser/storage/storage_info_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..adc1d7d33e2e381d8a76c0fce4b4582de9d4eadd
--- /dev/null
+++ b/chrome/browser/storage/storage_info_fetcher.cc
@@ -0,0 +1,55 @@
+// 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.
+
+#include "chrome/browser/storage/storage_info_fetcher.h"
+
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+StorageInfoFetcher::StorageInfoFetcher(storage::QuotaManager* quota_manager)
+ : quota_manager_(quota_manager) {
+}
+
+StorageInfoFetcher::~StorageInfoFetcher() {
+}
+
+void StorageInfoFetcher::Run() {
+ // QuotaManager must be called on IO thread, but the callback must then be
+ // called on the UI thread.
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&StorageInfoFetcher::GetUsageInfo, this,
+ base::Bind(&StorageInfoFetcher::OnGetUsageInfoInternal, this)));
+}
+
+void StorageInfoFetcher::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void StorageInfoFetcher::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+void StorageInfoFetcher::GetUsageInfo(
+ const storage::GetUsageInfoCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ quota_manager_->GetUsageInfo(callback);
+}
+
+void StorageInfoFetcher::OnGetUsageInfoInternal(
+ const storage::UsageInfoEntries& entries) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ entries_.insert(entries_.begin(), entries.begin(), entries.end());
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&StorageInfoFetcher::InvokeCallback, this));
+}
+
+void StorageInfoFetcher::InvokeCallback() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnGetUsageInfo(entries_));
+}
« no previous file with comments | « chrome/browser/storage/storage_info_fetcher.h ('k') | chrome/browser/ui/webui/settings/md_settings_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698