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

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

Issue 22548009: [SystemInfo API] Implement storage.getAvailableCapacity API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@impl_get_available_capacity_api2
Patch Set: Update Created 7 years, 2 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_storage/storage_info_provider.cc
diff --git a/chrome/browser/extensions/api/system_storage/storage_info_provider.cc b/chrome/browser/extensions/api/system_storage/storage_info_provider.cc
index 0c1abf196565ef5a3cc053bc5cad2299b15f250a..5cdc4692aae672bd5535f09a2bac83d68c1f6d8c 100644
--- a/chrome/browser/extensions/api/system_storage/storage_info_provider.cc
+++ b/chrome/browser/extensions/api/system_storage/storage_info_provider.cc
@@ -87,6 +87,28 @@ void StorageInfoProvider::GetAllStoragesIntoInfoList() {
}
}
+double StorageInfoProvider::GetStorageFreeSpaceFromTransientIdOnFileThread(
+ const std::string& transient_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ std::vector<StorageInfo> storage_list =
+ StorageMonitor::GetInstance()->GetAllAvailableStorages();
+
+ std::string device_id =
+ StorageMonitor::GetInstance()->GetDeviceIdForTransientId(
+ transient_id);
+
+ // Lookup the matched storage info by |device_id|.
+ for (std::vector<StorageInfo>::const_iterator it =
+ storage_list.begin();
+ it != storage_list.end(); ++it) {
+ if (device_id == it->device_id())
+ return static_cast<double>(base::SysInfo::AmountOfFreeDiskSpace(
+ base::FilePath(it->location())));
+ }
+
+ return -1;
+}
+
// static
StorageInfoProvider* StorageInfoProvider::Get() {
if (provider_.Get().get() == NULL)

Powered by Google App Engine
This is Rietveld 408576698