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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/device_storage_handler.cc

Issue 2556363003: Refactor cache counting into a separate helper class (Closed)
Patch Set: Remove code depending on GetEntrySize() Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 10 matching lines...) Expand all
21 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" 21 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
22 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 22 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
23 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h" 23 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h"
24 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 24 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
25 #include "chrome/browser/chromeos/drive/file_system_util.h" 25 #include "chrome/browser/chromeos/drive/file_system_util.h"
26 #include "chrome/browser/chromeos/file_manager/path_util.h" 26 #include "chrome/browser/chromeos/file_manager/path_util.h"
27 #include "chrome/browser/platform_util.h" 27 #include "chrome/browser/platform_util.h"
28 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
29 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
30 #include "chromeos/cryptohome/homedir_methods.h" 30 #include "chromeos/cryptohome/homedir_methods.h"
31 #include "components/browsing_data/content/storage_partition_http_cache_data_rem over.h" 31 #include "components/browsing_data/content/conditional_cache_counting_helper.h"
32 #include "components/drive/chromeos/file_system_interface.h" 32 #include "components/drive/chromeos/file_system_interface.h"
33 #include "components/user_manager/user_manager.h" 33 #include "components/user_manager/user_manager.h"
34 #include "content/public/browser/browser_context.h" 34 #include "content/public/browser/browser_context.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/storage_partition.h" 36 #include "content/public/browser/storage_partition.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/text/bytes_formatting.h" 38 #include "ui/base/text/bytes_formatting.h"
39 39
40 namespace chromeos { 40 namespace chromeos {
41 namespace settings { 41 namespace settings {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 void StorageHandler::UpdateBrowsingDataSize() { 226 void StorageHandler::UpdateBrowsingDataSize() {
227 if (updating_browsing_data_size_) 227 if (updating_browsing_data_size_)
228 return; 228 return;
229 updating_browsing_data_size_ = true; 229 updating_browsing_data_size_ = true;
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 // StoragePartitionHttpCacheDataRemover deletes itself when it is done. 235 // ConditionalCacheCountingHelper deletes itself when it is done.
236 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( 236 browsing_data::ConditionalCacheCountingHelper::CreateForRange(
237 content::BrowserContext::GetDefaultStoragePartition(profile), 237 content::BrowserContext::GetDefaultStoragePartition(profile),
238 base::Time(), 238 base::Time(), base::Time::Max())
239 base::Time::Max())->Count( 239 ->CountAndDestroySelfWhenFinished(
240 base::Bind(&StorageHandler::OnGetBrowsingDataSize, 240 base::Bind(&StorageHandler::OnGetBrowsingDataSize,
241 base::Unretained(this), false)); 241 base::Unretained(this), false));
242 242
243 // Fetch the size of site data in browsing data. 243 // Fetch the size of site data in browsing data.
244 if (!site_data_size_collector_.get()) { 244 if (!site_data_size_collector_.get()) {
245 content::StoragePartition* storage_partition = 245 content::StoragePartition* storage_partition =
246 content::BrowserContext::GetDefaultStoragePartition(profile); 246 content::BrowserContext::GetDefaultStoragePartition(profile);
247 site_data_size_collector_.reset(new SiteDataSizeCollector( 247 site_data_size_collector_.reset(new SiteDataSizeCollector(
248 storage_partition->GetPath(), 248 storage_partition->GetPath(),
249 new BrowsingDataCookieHelper(profile->GetRequestContext()), 249 new BrowsingDataCookieHelper(profile->GetRequestContext()),
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 base::StringValue("storage-android-size-changed"), 379 base::StringValue("storage-android-size-changed"),
380 base::StringValue(size_string)); 380 base::StringValue(size_string));
381 } 381 }
382 382
383 void StorageHandler::OnClearDriveCacheDone(bool success) { 383 void StorageHandler::OnClearDriveCacheDone(bool success) {
384 UpdateDriveCacheSize(); 384 UpdateDriveCacheSize();
385 } 385 }
386 386
387 } // namespace settings 387 } // namespace settings
388 } // namespace chromeos 388 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/storage_manager_handler.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698