Chromium Code Reviews| 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 7f387eed7ddaafa41e3892cda4d7dfd06b1288ad..3ee82d5383c7b8f54f0434c563a86e8f3320c769 100644 |
| --- a/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc |
| @@ -11,6 +11,16 @@ |
| #include "base/files/file_util.h" |
| #include "base/sys_info.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| +#include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h" |
| #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| #include "chrome/browser/chromeos/drive/file_system_util.h" |
| #include "chrome/browser/chromeos/file_manager/path_util.h" |
| @@ -23,6 +33,7 @@ |
| #include "components/user_manager/user_manager.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/text/bytes_formatting.h" |
| @@ -49,10 +60,7 @@ const int64_t kSpaceLowBytes = 1 * 1024 * 1024 * 1024; |
| } // namespace |
| -StorageManagerHandler::StorageManagerHandler() |
| - : browser_cache_size_(0), |
| - browser_site_data_size_(0), |
| - weak_ptr_factory_(this) { |
| +StorageManagerHandler::StorageManagerHandler() : weak_ptr_factory_(this) { |
| } |
| StorageManagerHandler::~StorageManagerHandler() { |
| @@ -258,6 +266,7 @@ void StorageManagerHandler::OnGetDriveCacheSize(int64_t size) { |
| } |
| void StorageManagerHandler::UpdateBrowsingDataSize() { |
| + browsing_data_size_.clear(); |
| Profile* const profile = Profile::FromWebUI(web_ui()); |
| // Fetch the size of http cache in browsing data. |
| // StoragePartitionHttpCacheDataRemover deletes itself when it is done. |
| @@ -266,22 +275,50 @@ void StorageManagerHandler::UpdateBrowsingDataSize() { |
| 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. |
| + weak_ptr_factory_.GetWeakPtr(), |
| + BROWSING_DATA_TYPE_HTTP_CACHE)); |
| + |
| + // Fetch the size of site data in browsing data. |
| + if (!site_data_size_collector_.get()) { |
| + content::StoragePartition* storage_partition = |
| + content::BrowserContext::GetDefaultStoragePartition(profile); |
| + site_data_size_collector_.reset(new SiteDataSizeCollector( |
| + storage_partition->GetPath(), |
| + new BrowsingDataCookieHelper(profile->GetRequestContext()), |
| + new BrowsingDataDatabaseHelper(profile), |
| + new BrowsingDataLocalStorageHelper(profile), |
| + new BrowsingDataAppCacheHelper(profile), |
| + new BrowsingDataIndexedDBHelper( |
| + storage_partition->GetIndexedDBContext()), |
| + BrowsingDataFileSystemHelper::Create( |
| + storage_partition->GetFileSystemContext()), |
| + BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), |
| + new BrowsingDataServiceWorkerHelper( |
| + storage_partition->GetServiceWorkerContext()), |
| + new BrowsingDataCacheStorageHelper( |
| + storage_partition->GetCacheStorageContext()), |
| + BrowsingDataFlashLSOHelper::Create(profile))); |
| + } |
| + site_data_size_collector_->Fetch( |
| + base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, |
| + weak_ptr_factory_.GetWeakPtr(), BROWSING_DATA_TYPE_SITE_DATA)); |
| } |
| -void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data, |
| +void StorageManagerHandler::OnGetBrowsingDataSize(BrowsingDataType data_type, |
| 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_)))); |
| + browsing_data_size_[data_type] = size; |
| + if (browsing_data_size_.size() == BROWSING_DATA_TYPE_MAX) { |
| + base::StringValue size_string(l10n_util::GetStringUTF16( |
| + IDS_OPTIONS_SETTINGS_STORAGE_SIZE_UNKNOWN)); |
| + if (browsing_data_size_[BROWSING_DATA_TYPE_HTTP_CACHE] >= 0 && |
| + browsing_data_size_[BROWSING_DATA_TYPE_SITE_DATA] >= 0) { |
|
Dan Beam
2016/07/07 18:46:23
you treat everything else like a map then expand o
fukino
2016/07/08 03:47:01
I don't use map in the latest patch.
I'll iterate
|
| + size_string = base::StringValue(ui::FormatBytes( |
| + browsing_data_size_[BROWSING_DATA_TYPE_HTTP_CACHE] + |
| + browsing_data_size_[BROWSING_DATA_TYPE_SITE_DATA])); |
| + } |
|
Dan Beam
2016/07/07 18:46:22
nit:
base::string16 size_string;
if (browsing_da
fukino
2016/07/08 03:47:01
Done. Thank you for the suggestion!
I took the sam
|
| + web_ui()->CallJavascriptFunctionUnsafe( |
| + "options.StorageManager.setBrowsingDataSize", size_string); |
| + } |
| } |
| void StorageManagerHandler::UpdateOtherUsersSize() { |