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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/storage/storage_info_fetcher.h"
6
7 #include "content/public/browser/browser_thread.h"
8
9 using content::BrowserThread;
10
11 StorageInfoFetcher::StorageInfoFetcher(storage::QuotaManager* quota_manager)
12 : quota_manager_(quota_manager) {
13 }
14
15 StorageInfoFetcher::~StorageInfoFetcher() {
16 }
17
18 void StorageInfoFetcher::Run() {
19 // QuotaManager must be called on IO thread, but the callback must then be
20 // called on the UI thread.
21 BrowserThread::PostTask(
22 BrowserThread::IO, FROM_HERE,
23 base::Bind(&StorageInfoFetcher::GetUsageInfo, this,
24 base::Bind(&StorageInfoFetcher::OnGetUsageInfoInternal, this)));
25 }
26
27 void StorageInfoFetcher::AddObserver(Observer* observer) {
28 observers_.AddObserver(observer);
29 }
30
31 void StorageInfoFetcher::RemoveObserver(Observer* observer) {
32 observers_.RemoveObserver(observer);
33 }
34
35 void StorageInfoFetcher::GetUsageInfo(
36 const storage::GetUsageInfoCallback& callback) {
37 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
38 quota_manager_->GetUsageInfo(callback);
39 }
40
41 void StorageInfoFetcher::OnGetUsageInfoInternal(
42 const storage::UsageInfoEntries& entries) {
43 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
44
45 entries_.insert(entries_.begin(), entries.begin(), entries.end());
46 BrowserThread::PostTask(
47 BrowserThread::UI, FROM_HERE,
48 base::Bind(&StorageInfoFetcher::InvokeCallback, this));
49 }
50
51 void StorageInfoFetcher::InvokeCallback() {
52 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
53
54 FOR_EACH_OBSERVER(Observer, observers_, OnGetUsageInfo(entries_));
55 }
OLDNEW
« 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