Index: chrome/browser/extensions/extension_file_browser_private_api.cc |
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc |
index 2cd65da083177b01e0b0484afcc2b369ffd44fc7..269ae6ef408cf79225a7211b8f4c0ba9b117b031 100644 |
--- a/chrome/browser/extensions/extension_file_browser_private_api.cc |
+++ b/chrome/browser/extensions/extension_file_browser_private_api.cc |
@@ -1277,6 +1277,73 @@ bool GetMountPointsFunction::RunImpl() { |
return true; |
} |
+GetSizeStatsFunction::GetSizeStatsFunction() { |
+} |
+ |
+GetSizeStatsFunction::~GetSizeStatsFunction() { |
+} |
+ |
+#ifdef OS_CHROMEOS |
+void GetSizeStatsFunction::GetSizeStatsCallback(const char* mount_path, |
+ bool success, size_t total_size_kb, size_t remaining_size_kb) { |
+ if (!success) { |
+ SendResponse(false); |
+ return; |
+ } |
+ |
+ base::DictionaryValue* sizes = new base::DictionaryValue(); |
+ result_.reset(sizes); |
+ |
+ sizes->SetInteger("totalSizeKB", total_size_kb); |
+ sizes->SetInteger("remainingSizeKB", remaining_size_kb); |
+ |
+ SendResponse(true); |
+ |
+ Release(); // Balances the AddRef taken in GetLocalPathsOnUIThread. |
+} |
+#endif |
+ |
+bool GetSizeStatsFunction::RunImpl() { |
+ if (args_->GetSize() != 1) { |
+ return false; |
+ } |
+ |
+ std::string mount_url; |
+ if (!args_->GetString(0, &mount_url)) { |
zel
2011/09/02 21:37:34
nit: no {}
tonibarzic
2011/09/02 21:59:01
Done.
|
+ return false; |
+ } |
+ |
+ UrlList mount_paths; |
+ mount_paths.push_back(GURL(mount_url)); |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableMethod(this, |
+ &GetSizeStatsFunction::GetLocalPathsOnFileThread, |
+ mount_paths, reinterpret_cast<void*>(NULL))); |
+ return true; |
+} |
+ |
+void GetSizeStatsFunction::GetLocalPathsResponseOnUIThread( |
+ const FilePathList& files, void* context) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ if (files.size() != 1) { |
+ SendResponse(false); |
+ return; |
+ } |
+ |
+#ifdef OS_CHROMEOS |
+ chromeos::CrosLibrary::Get()->GetMountLibrary()->GetSizeStats( |
+ files[0].value().c_str(), this /*MountLibrary::CallbackDelegate*/); |
+ AddRef(); // Balanced by the Release in GetSizeStatsCallback. |
+ return; |
+#endif |
+ |
+ // If we are not on ChromeOs, respond false. |
+ SendResponse(false); |
+} |
+ |
FormatDeviceFunction::FormatDeviceFunction() { |
} |