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

Unified Diff: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc

Issue 10834168: Drive: Show the total size of cache files at chrome://drive-internals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review (#2) fix & rebase Created 8 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
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index a2eb7357ddffd9dba8cab37d204fbc5dec706903..9f40a9c07f699fd71c9a27ef1a5a2b49d69bdee8 100644
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -39,7 +39,8 @@ namespace {
//
// The list is sorted by the path.
void GetGCacheContents(const FilePath& root_path,
- base::ListValue* gcache_contents) {
+ base::ListValue* gcache_contents,
+ base::DictionaryValue* gcache_summary) {
using file_util::FileEnumerator;
// Use this map to sort the result list by the path.
std::map<FilePath, DictionaryValue*> files;
@@ -52,6 +53,7 @@ void GetGCacheContents(const FilePath& root_path,
true, // recursive
static_cast<FileEnumerator::FileType>(options));
+ int64 total_size = 0;
for (FilePath current = enumerator.Next(); !current.empty();
current = enumerator.Next()) {
FileEnumerator::FindInfo find_info;
@@ -70,8 +72,9 @@ void GetGCacheContents(const FilePath& root_path,
entry->SetBoolean("is_symbolic_link", is_symbolic_link);
entry->SetString("last_modified",
gdata::util::FormatTimeAsString(last_modified));
-
files[current] = entry;
+
+ total_size += size;
}
// Convert |files| into |gcache_contents|.
@@ -79,6 +82,8 @@ void GetGCacheContents(const FilePath& root_path,
iter = files.begin(); iter != files.end(); ++iter) {
gcache_contents->Append(iter->second);
}
+
+ gcache_summary->SetDouble("total_size", total_size);
}
// Formats |entry| into text.
@@ -159,7 +164,8 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
void OnPageLoaded(const base::ListValue* args);
// Called when GetGCacheContents() is complete.
- void OnGetGCacheContents(base::ListValue* gcache_contents);
+ void OnGetGCacheContents(base::ListValue* gcache_contents,
+ base::DictionaryValue* cache_summary);
// Called when ReadDirectoryByPath() is complete.
void OnReadDirectoryByPath(const FilePath& parent_path,
@@ -217,18 +223,27 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
const FilePath root_path =
gdata::GDataCache::GetCacheRootPath(profile);
base::ListValue* gcache_contents = new ListValue;
+ base::DictionaryValue* gcache_summary = new DictionaryValue;
content::BrowserThread::PostBlockingPoolTaskAndReply(
FROM_HERE,
- base::Bind(&GetGCacheContents, root_path, gcache_contents),
+ base::Bind(&GetGCacheContents,
+ root_path,
+ gcache_contents,
+ gcache_summary),
base::Bind(&DriveInternalsWebUIHandler::OnGetGCacheContents,
weak_ptr_factory_.GetWeakPtr(),
- base::Owned(gcache_contents)));
+ base::Owned(gcache_contents),
+ base::Owned(gcache_summary)));
}
void DriveInternalsWebUIHandler::OnGetGCacheContents(
- base::ListValue* gcache_contents) {
+ base::ListValue* gcache_contents,
+ base::DictionaryValue* gcache_summary) {
DCHECK(gcache_contents);
- web_ui()->CallJavascriptFunction("updateGCacheContents", *gcache_contents);
+ DCHECK(gcache_summary);
+ web_ui()->CallJavascriptFunction("updateGCacheContents",
+ *gcache_contents,
+ *gcache_summary);
// Start updating the file system tree section, if we have access token.
gdata::GDataSystemService* system_service = GetSystemService();
« no previous file with comments | « chrome/browser/resources/chromeos/drive_internals.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698