| 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/settings/chromeos/device_storage_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/device_storage_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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 has_browser_cache_size_ = false; | 231 has_browser_cache_size_ = false; |
| 232 has_browser_site_data_size_ = false; | 232 has_browser_site_data_size_ = false; |
| 233 Profile* const profile = Profile::FromWebUI(web_ui()); | 233 Profile* const profile = Profile::FromWebUI(web_ui()); |
| 234 // Fetch the size of http cache in browsing data. | 234 // Fetch the size of http cache in browsing data. |
| 235 // ConditionalCacheCountingHelper deletes itself when it is done. | 235 // ConditionalCacheCountingHelper deletes itself when it is done. |
| 236 browsing_data::ConditionalCacheCountingHelper::CreateForRange( | 236 browsing_data::ConditionalCacheCountingHelper::CreateForRange( |
| 237 content::BrowserContext::GetDefaultStoragePartition(profile), | 237 content::BrowserContext::GetDefaultStoragePartition(profile), |
| 238 base::Time(), base::Time::Max()) | 238 base::Time(), base::Time::Max()) |
| 239 ->CountAndDestroySelfWhenFinished( | 239 ->CountAndDestroySelfWhenFinished( |
| 240 base::Bind(&StorageHandler::OnGetBrowsingDataSize, | 240 base::Bind(&StorageHandler::OnGetCacheSize, base::Unretained(this))); |
| 241 base::Unretained(this), false)); | |
| 242 | 241 |
| 243 // Fetch the size of site data in browsing data. | 242 // Fetch the size of site data in browsing data. |
| 244 if (!site_data_size_collector_.get()) { | 243 if (!site_data_size_collector_.get()) { |
| 245 content::StoragePartition* storage_partition = | 244 content::StoragePartition* storage_partition = |
| 246 content::BrowserContext::GetDefaultStoragePartition(profile); | 245 content::BrowserContext::GetDefaultStoragePartition(profile); |
| 247 site_data_size_collector_.reset(new SiteDataSizeCollector( | 246 site_data_size_collector_.reset(new SiteDataSizeCollector( |
| 248 storage_partition->GetPath(), | 247 storage_partition->GetPath(), |
| 249 new BrowsingDataCookieHelper(profile->GetRequestContext()), | 248 new BrowsingDataCookieHelper(profile->GetRequestContext()), |
| 250 new BrowsingDataDatabaseHelper(profile), | 249 new BrowsingDataDatabaseHelper(profile), |
| 251 new BrowsingDataLocalStorageHelper(profile), | 250 new BrowsingDataLocalStorageHelper(profile), |
| 252 new BrowsingDataAppCacheHelper(profile), | 251 new BrowsingDataAppCacheHelper(profile), |
| 253 new BrowsingDataIndexedDBHelper( | 252 new BrowsingDataIndexedDBHelper( |
| 254 storage_partition->GetIndexedDBContext()), | 253 storage_partition->GetIndexedDBContext()), |
| 255 BrowsingDataFileSystemHelper::Create( | 254 BrowsingDataFileSystemHelper::Create( |
| 256 storage_partition->GetFileSystemContext()), | 255 storage_partition->GetFileSystemContext()), |
| 257 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), | 256 BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), |
| 258 new BrowsingDataServiceWorkerHelper( | 257 new BrowsingDataServiceWorkerHelper( |
| 259 storage_partition->GetServiceWorkerContext()), | 258 storage_partition->GetServiceWorkerContext()), |
| 260 new BrowsingDataCacheStorageHelper( | 259 new BrowsingDataCacheStorageHelper( |
| 261 storage_partition->GetCacheStorageContext()), | 260 storage_partition->GetCacheStorageContext()), |
| 262 BrowsingDataFlashLSOHelper::Create(profile))); | 261 BrowsingDataFlashLSOHelper::Create(profile))); |
| 263 } | 262 } |
| 264 site_data_size_collector_->Fetch( | 263 site_data_size_collector_->Fetch( |
| 265 base::Bind(&StorageHandler::OnGetBrowsingDataSize, | 264 base::Bind(&StorageHandler::OnGetBrowsingDataSize, |
| 266 base::Unretained(this), true)); | 265 base::Unretained(this), true)); |
| 267 } | 266 } |
| 268 | 267 |
| 268 void StorageHandler::OnGetCacheSize(int64_t size, bool is_upper_limit) { |
| 269 DCHECK(!is_upper_limit); |
| 270 OnGetBrowsingDataSize(false, size); |
| 271 } |
| 272 |
| 269 void StorageHandler::OnGetBrowsingDataSize(bool is_site_data, int64_t size) { | 273 void StorageHandler::OnGetBrowsingDataSize(bool is_site_data, int64_t size) { |
| 270 if (is_site_data) { | 274 if (is_site_data) { |
| 271 has_browser_site_data_size_ = true; | 275 has_browser_site_data_size_ = true; |
| 272 browser_site_data_size_ = size; | 276 browser_site_data_size_ = size; |
| 273 } else { | 277 } else { |
| 274 has_browser_cache_size_ = true; | 278 has_browser_cache_size_ = true; |
| 275 browser_cache_size_ = size; | 279 browser_cache_size_ = size; |
| 276 } | 280 } |
| 277 if (has_browser_cache_size_ && has_browser_site_data_size_) { | 281 if (has_browser_cache_size_ && has_browser_site_data_size_) { |
| 278 base::string16 size_string; | 282 base::string16 size_string; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 base::StringValue("storage-android-size-changed"), | 383 base::StringValue("storage-android-size-changed"), |
| 380 base::StringValue(size_string)); | 384 base::StringValue(size_string)); |
| 381 } | 385 } |
| 382 | 386 |
| 383 void StorageHandler::OnClearDriveCacheDone(bool success) { | 387 void StorageHandler::OnClearDriveCacheDone(bool success) { |
| 384 UpdateDriveCacheSize(); | 388 UpdateDriveCacheSize(); |
| 385 } | 389 } |
| 386 | 390 |
| 387 } // namespace settings | 391 } // namespace settings |
| 388 } // namespace chromeos | 392 } // namespace chromeos |
| OLD | NEW |