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

Unified Diff: chrome/browser/chromeos/cros/mount_library.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: a Created 9 years, 3 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/chromeos/cros/mount_library.cc
diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc
index 7d256c0759a01cbd534d144c3fceb33ce6887ebf..97f4827d4991ce258728fb285cf82c747a62ae80 100644
--- a/chrome/browser/chromeos/cros/mount_library.cc
+++ b/chrome/browser/chromeos/cros/mount_library.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/cros/mount_library.h"
#include <set>
+#include <sys/statvfs.h>
#include <vector>
#include "base/message_loop.h"
@@ -202,6 +203,25 @@ class MountLibraryImpl : public MountLibrary {
this);
}
+ virtual void GetSizeStatsOnFileThread(const char* mount_path,
+ size_t* total_size_kb, size_t* remaining_size_kb) OVERRIDE {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+
+ uint64_t total_size_uint64 = 0;
+ uint64_t remaining_size_uint64 = 0;
+
+ struct statvfs stat;
+ if (statvfs(mount_path, &stat) == 0) {
+ total_size_uint64 =
+ static_cast<uint64_t>(stat.f_blocks) * stat.f_frsize;
+ remaining_size_uint64 =
+ static_cast<uint64_t>(stat.f_bfree) * stat.f_frsize;
+ }
+
+ *total_size_kb = static_cast<size_t>(total_size_uint64 / 1024);
+ *remaining_size_kb = static_cast<size_t>(remaining_size_uint64 / 1024);
+ }
+
virtual void FormatUnmountedDevice(const char* file_path) OVERRIDE {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
for (MountLibrary::DiskMap::iterator it = disks_.begin();
@@ -789,6 +809,8 @@ class MountLibraryStubImpl : public MountLibrary {
virtual void MountPath(const char* source_path, MountType type,
const MountPathOptions& options) OVERRIDE {}
virtual void UnmountPath(const char* mount_path) OVERRIDE {}
+ virtual void GetSizeStatsOnFileThread(const char* mount_path,
+ size_t* total_size_kb, size_t* remaining_size_kb) OVERRIDE {}
virtual void FormatUnmountedDevice(const char* device_path) OVERRIDE {}
virtual void FormatMountedDevice(const char* mount_path) OVERRIDE {}
virtual void UnmountDeviceRecursive(const char* device_path,
« no previous file with comments | « chrome/browser/chromeos/cros/mount_library.h ('k') | chrome/browser/extensions/extension_file_browser_private_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698