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

Unified Diff: chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc

Issue 18290002: [SystemInfo API] Finish TODOs in SystemInfoProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dev_rewrite_storage_info_api
Patch Set: Fix hongbo's comments Created 7 years, 5 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/extensions/api/system_info_storage/storage_info_provider.cc
diff --git a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
index 581e02f509b9c360f2cdeeaf22fb103babe3dc53..cf7eb161a3cb13609ae4b436a1e2a8db2930f526 100644
--- a/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
+++ b/chrome/browser/extensions/api/system_info_storage/storage_info_provider.cc
@@ -50,7 +50,11 @@ StorageInfoProvider::StorageInfoProvider()
StorageInfoProvider::~StorageInfoProvider() {
}
-void StorageInfoProvider::StartQueryInfoImpl() {
+const StorageInfo& StorageInfoProvider::storage_info() const {
+ return info_;
+}
+
+void StorageInfoProvider::StartQueryInfoPostInitialization() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Register a callback to notify UI thread that StorageMonitor finishes the
// storage metadata retrieval on FILE thread. See the comments of
@@ -61,16 +65,17 @@ void StorageInfoProvider::StartQueryInfoImpl() {
void StorageInfoProvider::QueryInfoImplOnUIThread() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // At this point, we can call StorageMonitor::GetAllAvailableStorages to
- // get the correct results.
- QueryInfo(&info_);
- // The amount of available capacity should be queried on blocking pool.
- PostQueryTaskToBlockingPool(FROM_HERE,
+
+ // QueryInfo can be called on UI thread since in the implementation we use
+ // StorageMonitor::GetAllAvailableStorages to get the correct results.
Hongbo Min 2013/07/05 05:01:34 nit: GetAllAvailableStorages->GetAllStorages
Haojian Wu 2013/07/06 05:31:37 Here GetAllStorage is a StorageInfoProvider method
Hongbo Min 2013/07/06 14:26:35 I see now. Thanks.
+ QueryInfo();
+
+ StartQueryInfoImpl(
base::Bind(&StorageInfoProvider::QueryAvailableCapacityOnBlockingPool,
- this));
+ this));
}
-void StorageInfoProvider::QueryAvailableCapacityOnBlockingPool() {
+bool StorageInfoProvider::QueryAvailableCapacityOnBlockingPool() {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
for (StorageInfo::iterator it = info_.begin(); it != info_.end(); ++it) {
int64 amount = GetStorageFreeSpaceFromTransientId((*it)->id);
@@ -78,16 +83,14 @@ void StorageInfoProvider::QueryAvailableCapacityOnBlockingPool() {
(*it)->available_capacity = static_cast<double>(amount);
}
- // Notify UI thread that the querying operation has completed.
- BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&StorageInfoProvider::OnQueryCompleted, this, true));
+ return true;
}
std::vector<chrome::StorageInfo> StorageInfoProvider::GetAllStorages() const {
return StorageMonitor::GetInstance()->GetAllAvailableStorages();
}
-bool StorageInfoProvider::QueryInfo(StorageInfo* info) {
+bool StorageInfoProvider::QueryInfo() {
std::vector<chrome::StorageInfo> storage_list = GetAllStorages();
StorageInfo results;
std::vector<chrome::StorageInfo>::const_iterator it = storage_list.begin();
@@ -96,8 +99,8 @@ bool StorageInfoProvider::QueryInfo(StorageInfo* info) {
systeminfo::BuildStorageUnitInfo(*it, unit.get());
results.push_back(unit);
}
+ StorageInfo* info = &info_;
Hongbo Min 2013/07/05 05:01:34 Directly use info_.swap(results) instead.
Haojian Wu 2013/07/06 05:31:37 Done.
info->swap(results);
-
return true;
}

Powered by Google App Engine
This is Rietveld 408576698