| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <numeric> | 8 #include <numeric> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 has_browser_cache_size_ = false; | 299 has_browser_cache_size_ = false; |
| 300 has_browser_site_data_size_ = false; | 300 has_browser_site_data_size_ = false; |
| 301 Profile* const profile = Profile::FromWebUI(web_ui()); | 301 Profile* const profile = Profile::FromWebUI(web_ui()); |
| 302 // Fetch the size of http cache in browsing data. | 302 // Fetch the size of http cache in browsing data. |
| 303 // ConditionalCacheCountingHelper deletes itself when it is done. | 303 // ConditionalCacheCountingHelper deletes itself when it is done. |
| 304 browsing_data::ConditionalCacheCountingHelper::CreateForRange( | 304 browsing_data::ConditionalCacheCountingHelper::CreateForRange( |
| 305 content::BrowserContext::GetDefaultStoragePartition(profile), | 305 content::BrowserContext::GetDefaultStoragePartition(profile), |
| 306 base::Time(), base::Time::Max()) | 306 base::Time(), base::Time::Max()) |
| 307 ->CountAndDestroySelfWhenFinished( | 307 ->CountAndDestroySelfWhenFinished( |
| 308 base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, | 308 base::Bind(&StorageManagerHandler::OnGetCacheSize, |
| 309 weak_ptr_factory_.GetWeakPtr(), false)); | 309 weak_ptr_factory_.GetWeakPtr())); |
| 310 | 310 |
| 311 // Fetch the size of site data in browsing data. | 311 // Fetch the size of site data in browsing data. |
| 312 if (!site_data_size_collector_.get()) { | 312 if (!site_data_size_collector_.get()) { |
| 313 content::StoragePartition* storage_partition = | 313 content::StoragePartition* storage_partition = |
| 314 content::BrowserContext::GetDefaultStoragePartition(profile); | 314 content::BrowserContext::GetDefaultStoragePartition(profile); |
| 315 site_data_size_collector_.reset(new SiteDataSizeCollector( | 315 site_data_size_collector_.reset(new SiteDataSizeCollector( |
| 316 storage_partition->GetPath(), | 316 storage_partition->GetPath(), |
| 317 new BrowsingDataCookieHelper(profile->GetRequestContext()), | 317 new BrowsingDataCookieHelper(profile->GetRequestContext()), |
| 318 new BrowsingDataDatabaseHelper(profile), | 318 new BrowsingDataDatabaseHelper(profile), |
| 319 new BrowsingDataLocalStorageHelper(profile), | 319 new BrowsingDataLocalStorageHelper(profile), |
| 320 new BrowsingDataAppCacheHelper(profile), | 320 new BrowsingDataAppCacheHelper(profile), |
| 321 new BrowsingDataIndexedDBHelper( | 321 new BrowsingDataIndexedDBHelper( |
| 322 storage_partition->GetIndexedDBContext()), | 322 storage_partition->GetIndexedDBContext()), |
| 323 BrowsingDataFileSystemHelper::Create( | 323 BrowsingDataFileSystemHelper::Create( |
| 324 storage_partition->GetFileSystemContext()), | 324 storage_partition->GetFileSystemContext()), |
| 325 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), | 325 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), |
| 326 new BrowsingDataServiceWorkerHelper( | 326 new BrowsingDataServiceWorkerHelper( |
| 327 storage_partition->GetServiceWorkerContext()), | 327 storage_partition->GetServiceWorkerContext()), |
| 328 new BrowsingDataCacheStorageHelper( | 328 new BrowsingDataCacheStorageHelper( |
| 329 storage_partition->GetCacheStorageContext()), | 329 storage_partition->GetCacheStorageContext()), |
| 330 BrowsingDataFlashLSOHelper::Create(profile))); | 330 BrowsingDataFlashLSOHelper::Create(profile))); |
| 331 } | 331 } |
| 332 site_data_size_collector_->Fetch( | 332 site_data_size_collector_->Fetch( |
| 333 base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, | 333 base::Bind(&StorageManagerHandler::OnGetBrowsingDataSize, |
| 334 weak_ptr_factory_.GetWeakPtr(), true)); | 334 weak_ptr_factory_.GetWeakPtr(), true)); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void StorageManagerHandler::OnGetCacheSize(int64_t size, bool is_upper_limit) { |
| 338 DCHECK(!is_upper_limit); |
| 339 OnGetBrowsingDataSize(false, size); |
| 340 } |
| 341 |
| 337 void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data, | 342 void StorageManagerHandler::OnGetBrowsingDataSize(bool is_site_data, |
| 338 int64_t size) { | 343 int64_t size) { |
| 339 if (is_site_data) { | 344 if (is_site_data) { |
| 340 has_browser_site_data_size_ = true; | 345 has_browser_site_data_size_ = true; |
| 341 browser_site_data_size_ = size; | 346 browser_site_data_size_ = size; |
| 342 } else { | 347 } else { |
| 343 has_browser_cache_size_ = true; | 348 has_browser_cache_size_ = true; |
| 344 browser_cache_size_ = size; | 349 browser_cache_size_ = size; |
| 345 } | 350 } |
| 346 if (has_browser_cache_size_ && has_browser_site_data_size_) { | 351 if (has_browser_cache_size_ && has_browser_site_data_size_) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", | 448 web_ui()->CallJavascriptFunctionUnsafe("options.StorageManager.setArcSize", |
| 444 base::StringValue(size_string)); | 449 base::StringValue(size_string)); |
| 445 } | 450 } |
| 446 | 451 |
| 447 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { | 452 void StorageManagerHandler::OnClearDriveCacheDone(bool success) { |
| 448 UpdateDriveCacheSize(); | 453 UpdateDriveCacheSize(); |
| 449 } | 454 } |
| 450 | 455 |
| 451 } // namespace options | 456 } // namespace options |
| 452 } // namespace chromeos | 457 } // namespace chromeos |
| OLD | NEW |