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(); |
+} |