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

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: removed AddRef/Release from file_browser_private_api.cc 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/chromeos/cros/mount_library.cc
diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc
index 12f969b6401d5d05acecb51449d6f21bca5a18fb..6ec0d07d6e8b462139bc0dfc003e137bdbb107a2 100644
--- a/chrome/browser/chromeos/cros/mount_library.cc
+++ b/chrome/browser/chromeos/cros/mount_library.cc
@@ -6,6 +6,7 @@
#include <set>
#include <vector>
+#include <sys/statvfs.h>
#include "base/message_loop.h"
#include "base/string_util.h"
@@ -210,6 +211,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));
if (!CrosLibrary::Get()->EnsureLoaded()) {
@@ -803,6 +823,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,

Powered by Google App Engine
This is Rietveld 408576698