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

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: Created 7 years, 6 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 22e0b582c174f2e6010f670324d216b720b1b783..a4bc9ec31acbd721f20a0507f8baedd0b04b9f34 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 {
Hongbo Min 2013/07/01 10:23:41 Is it possible to return a const reference to Stor
Haojian Wu 2013/07/01 15:16:42 I think so. So you prefer to reference rather than
Hongbo Min 2013/07/02 00:57:58 Yes.
Haojian Wu 2013/07/05 03:01:34 Done.
+ return &info_;
+}
+
void StorageInfoProvider::StartQueryInfoImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
// Register a callback to notify UI thread that StorageMonitor finishes the
@@ -63,11 +67,13 @@ 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();
+
+ // Query the amount of available capacity on blocking pool.
+ content::BrowserThread::PostBlockingPoolTaskAndReply(FROM_HERE,
base::Bind(&StorageInfoProvider::QueryAvailableCapacityOnBlockingPool,
- this));
+ this),
+ base::Bind(&StorageInfoProvider::OnQueryCompleted, this));
}
void StorageInfoProvider::QueryAvailableCapacityOnBlockingPool() {
@@ -78,16 +84,14 @@ void StorageInfoProvider::QueryAvailableCapacityOnBlockingPool() {
(*it)->available_capacity = static_cast<double>(amount);
}
- // Notify UI thread that the querying operation is already completed.
- BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&StorageInfoProvider::OnQueryCompleted, this, true));
+ success_ = true;
}
std::vector<chrome::StorageInfo> StorageInfoProvider::GetAllStorages() const {
return StorageMonitor::GetInstance()->GetAllAvailableStorages();
}
-bool StorageInfoProvider::QueryInfo(StorageInfo* info) {
+void StorageInfoProvider::QueryInfo() {
std::vector<chrome::StorageInfo> storage_list = GetAllStorages();
StorageInfo results;
std::vector<chrome::StorageInfo>::const_iterator it = storage_list.begin();
@@ -96,9 +100,8 @@ bool StorageInfoProvider::QueryInfo(StorageInfo* info) {
systeminfo::BuildStorageUnitInfo(*it, unit.get());
results.push_back(unit);
}
+ StorageInfo* info = &info_;
info->swap(results);
-
- return true;
}
void StorageInfoProvider::AddObserver(StorageFreeSpaceObserver* obs) {

Powered by Google App Engine
This is Rietveld 408576698