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

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: Update 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..0d72d7241e06a1c0a2449eda35f3f8da5b2f7dc3 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,6 +50,10 @@ StorageInfoProvider::StorageInfoProvider()
StorageInfoProvider::~StorageInfoProvider() {
}
+const StorageInfo& StorageInfoProvider::storage_info() const {
+ return info_;
+}
+
void StorageInfoProvider::StartQueryInfoImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Register a callback to notify UI thread that StorageMonitor finishes the
@@ -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
Jeffrey Yasskin 2013/07/08 19:09:49 s/can/must/, I think? This explains why my sugges
Haojian Wu 2013/07/09 13:45:04 Rename Done. I'm not sure whether I get you key p
Greg Billock 2013/07/09 16:44:52 Here's my thought on this: SystemInfoProvider sho
Jeffrey Yasskin 2013/07/09 18:19:59 The above method would post QueryInfo() before Pre
Haojian Wu 2013/07/10 01:33:27 In this way, we still need to virtual InitializePr
Jeffrey Yasskin 2013/07/10 01:57:42 Yes, exactly.
Haojian Wu 2013/07/10 03:11:37 Done.
+ // StorageMonitor::GetAllAvailableStorages to get the correct results.
+ QueryInfo();
+
+ PostQueryTaskToBlockingPool(
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();
Greg Billock 2013/07/08 18:05:06 These two type names are confusing. Could we call
Haojian Wu 2013/07/09 13:45:04 Done.
StorageInfo results;
std::vector<chrome::StorageInfo>::const_iterator it = storage_list.begin();
@@ -96,8 +99,7 @@ bool StorageInfoProvider::QueryInfo(StorageInfo* info) {
systeminfo::BuildStorageUnitInfo(*it, unit.get());
results.push_back(unit);
}
- info->swap(results);
-
+ info_.swap(results);
Greg Billock 2013/07/08 18:05:06 Why not add these directly into info_ ? Is there a
Haojian Wu 2013/07/09 13:45:04 Done. My original thought is that we should keep m
return true;
}

Powered by Google App Engine
This is Rietveld 408576698