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

Side by Side 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 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/content_settings/storage_info_fetcher.h"
6
7 using content::BrowserThread;
8
9 StorageInfoFetcher::StorageInfoFetcher(storage::QuotaManager* quota_manager)
10 : quota_manager_(quota_manager) {
11 }
12
13 StorageInfoFetcher::~StorageInfoFetcher() {
14 }
15
16 void StorageInfoFetcher::Run() {
17 AddRef(); // Balanced in OnGetUsageInfoInternal.
michaelpg 2016/01/19 20:47:54 nit: 2 spaces before comment
Finnur 2016/01/22 15:07:35 Done.
18 // QuotaManager must be called on IO thread, but the callback must then be
19 // called on the UI thread.
20 BrowserThread::PostTask(
21 BrowserThread::IO, FROM_HERE,
22 base::Bind(&StorageInfoFetcher::GetUsageInfo, this));
23 }
24
25 void StorageInfoFetcher::GetUsageInfo() {
26 quota_manager_->GetUsageInfo(
27 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.
28 }
29
30 void StorageInfoFetcher::OnGetUsageInfoInternal(
31 const storage::UsageInfoEntries& entries) {
32 entries_.insert(entries_.begin(), entries.begin(), entries.end());
33 BrowserThread::PostTask(
34 BrowserThread::UI, FROM_HERE,
35 base::Bind(&StorageInfoFetcher::InvokeCallback, this));
36 }
37
38 void StorageInfoFetcher::InvokeCallback() {
39 OnGetUsageInfo(entries_);
40
41 // This will result in this class getting deleted.
42 Release();
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698