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

Unified Diff: chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc

Issue 2073903002: Storage manager: Add browsing data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a minor issue on closure annotation. Created 4 years, 6 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/ui/webui/options/chromeos/storage_manager_handler.h ('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/options/chromeos/storage_manager_handler.cc
diff --git a/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc b/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc
index c847ac7f4d035b70d8b876cf579e8fa86153b386..9131ac8ab50d1d5ce7f39ecdcd070d9c37ddfa32 100644
--- a/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc
@@ -15,7 +15,9 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/grit/generated_resources.h"
+#include "components/browsing_data/storage_partition_http_cache_data_remover.h"
#include "components/drive/chromeos/file_system_interface.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"
@@ -43,7 +45,10 @@ const int64_t kSpaceLowBytes = 1 * 1024 * 1024 * 1024;
} // namespace
-StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) {
+StorageManagerHandler::StorageManagerHandler()
+ : browser_cache_size_(0),
+ browser_site_data_size_(0),
+ weak_ptr_factory_(this) {
}
StorageManagerHandler::~StorageManagerHandler() {
@@ -74,6 +79,9 @@ void StorageManagerHandler::GetLocalizedValues(
"storageSubitemLabelDriveCache", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_DRIVE_CACHE));
localized_strings->SetString(
+ "storageSubitemLabelBrowsingData", l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_BROWSING_DATA));
+ localized_strings->SetString(
"storageSubitemLabelArc", l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_STORAGE_SUBITEM_LABEL_ARC));
localized_strings->SetString(
@@ -135,6 +143,7 @@ void StorageManagerHandler::HandleUpdateStorageInfo(
UpdateSizeStat();
UpdateDownloadsSize();
UpdateDriveCacheSize();
+ UpdateBrowsingDataSize();
UpdateArcSize();
}
@@ -237,6 +246,33 @@ void StorageManagerHandler::OnGetDriveCacheSize(int64_t size) {
base::StringValue(ui::FormatBytes(size)));
}
+void StorageManagerHandler::UpdateBrowsingDataSize() {
+ Profile* const profile = Profile::FromWebUI(web_ui());
+ // Fetch the size of http cache in browsing data.
+ // StoragePartitionHttpCacheDataRemover deletes itself when it is done.
+ browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange(
+ content::BrowserContext::GetDefaultStoragePartition(profile),
+ base::Time(),
+ base::Time::Max())->Count(
+ base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize,
+ weak_ptr_factory_.GetWeakPtr(), false));
+
+ // TODO(fukino): fetch the size of site data in browsing data.
+}
+
+void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data,
+ int64_t size) {
+ if (is_site_data)
+ browser_site_data_size_ = size;
+ else
+ browser_cache_size_ = size;
+
+ web_ui()->CallJavascriptFunctionUnsafe(
+ "options.StorageManager.setBrowsingDataSize",
+ base::StringValue(ui::FormatBytes(static_cast<int64_t>(
+ browser_cache_size_ + browser_site_data_size_))));
+}
+
void StorageManagerHandler::UpdateArcSize() {
Profile* const profile = Profile::FromWebUI(web_ui());
if (!arc::ArcAuthService::IsAllowedForProfile(profile) ||
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698