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

Unified Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 7826037: Adding support to retrieve remaining and total space on disk/file shelf. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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/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() {
}

Powered by Google App Engine
This is Rietveld 408576698