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

Unified Diff: chrome/browser/content_settings/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: 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/content_settings/storage_info_fetcher.cc
diff --git a/chrome/browser/content_settings/storage_info_fetcher.cc b/chrome/browser/content_settings/storage_info_fetcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..10ef0c8a5ea6eaca9c44a4fef1701a596f4081de
--- /dev/null
+++ b/chrome/browser/content_settings/storage_info_fetcher.cc
@@ -0,0 +1,43 @@
+// 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/content_settings/storage_info_fetcher.h"
+
+using content::BrowserThread;
+
+StorageInfoFetcher::StorageInfoFetcher(storage::QuotaManager* quota_manager)
+ : quota_manager_(quota_manager) {
+}
+
+StorageInfoFetcher::~StorageInfoFetcher() {
+}
+
+void StorageInfoFetcher::Run() {
+ AddRef(); // Balanced in OnGetUsageInfoInternal.
michaelpg 2016/01/19 20:47:54 nit: 2 spaces before comment
Finnur 2016/01/22 15:07:35 Done.
+ // 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));
+}
+
+void StorageInfoFetcher::GetUsageInfo() {
+ quota_manager_->GetUsageInfo(
+ base::Bind(&StorageInfoFetcher::OnGetUsageInfoInternal, this));
michaelpg 2016/01/19 20:47:54 does Bind have to be called on the IO thread? if n
Finnur 2016/01/22 15:07:35 Done.
+}
+
+void StorageInfoFetcher::OnGetUsageInfoInternal(
+ const storage::UsageInfoEntries& entries) {
+ entries_.insert(entries_.begin(), entries.begin(), entries.end());
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&StorageInfoFetcher::InvokeCallback, this));
+}
+
+void StorageInfoFetcher::InvokeCallback() {
+ OnGetUsageInfo(entries_);
+
+ // This will result in this class getting deleted.
+ Release();
+}

Powered by Google App Engine
This is Rietveld 408576698