OLD | NEW |
---|---|
(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 } | |
OLD | NEW |