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..e0460e359eab730642a742f1857768ace9fc3568 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" |
| @@ -50,8 +61,8 @@ const int64_t kSpaceLowBytes = 1 * 1024 * 1024 * 1024; |
| } // namespace |
| StorageManagerHandler::StorageManagerHandler() |
| - : browser_cache_size_(0), |
| - browser_site_data_size_(0), |
| + : browser_cache_size_(-1), |
| + browser_site_data_size_(-1), |
| weak_ptr_factory_(this) { |
| } |
| @@ -261,6 +272,7 @@ 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. |
| + browser_cache_size_ = -1; |
| browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( |
| content::BrowserContext::GetDefaultStoragePartition(profile), |
| base::Time(), |
| @@ -268,7 +280,31 @@ void StorageManagerHandler::UpdateBrowsingDataSize() { |
| base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, |
| weak_ptr_factory_.GetWeakPtr(), false)); |
| - // TODO(fukino): fetch the size of site data in browsing data. |
| + // 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))); |
| + } |
| + browser_site_data_size_ = -1; |
| + site_data_size_collector_->Fetch( |
| + base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, |
| + weak_ptr_factory_.GetWeakPtr(), true)); |
| } |
| void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data, |
| @@ -278,10 +314,12 @@ void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data, |
| 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_)))); |
| + if (browser_site_data_size_ >= 0 && browser_cache_size_ >= 0) { |
|
Dan Beam
2016/07/06 18:29:22
what if there was a valid size and now it fails?
fukino
2016/07/07 11:08:18
Ah, yes, when fetching browsing data fails, I thin
|
| + web_ui()->CallJavascriptFunctionUnsafe( |
| + "options.StorageManager.setBrowsingDataSize", |
| + base::StringValue(ui::FormatBytes(static_cast<int64_t>( |
| + browser_cache_size_ + browser_site_data_size_)))); |
| + } |
| } |
| void StorageManagerHandler::UpdateOtherUsersSize() { |