Index: chrome/browser/browsing_data/site_data_counter.cc |
diff --git a/chrome/browser/browsing_data/site_data_counter.cc b/chrome/browser/browsing_data/site_data_counter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f4fdfa353542c8847f13c4b299d31f78eaa1a492 |
--- /dev/null |
+++ b/chrome/browser/browsing_data/site_data_counter.cc |
@@ -0,0 +1,50 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/browsing_data/site_data_counter.h" |
+ |
+#include "chrome/common/pref_names.h" |
+ |
+SiteDataCounter::SiteDataCounter() : pref_name_(prefs::kDeleteCookies), |
+ weak_ptr_factory_(this) { |
+} |
+ |
+SiteDataCounter::~SiteDataCounter() { |
+} |
+ |
+const std::string& SiteDataCounter::GetPrefName() const { |
+ return pref_name_; |
+} |
+ |
+void SiteDataCounter::Count() { |
+ Profile* const profile = GetProfile(); |
+ content::StoragePartition* storage_partition = |
+ content::BrowserContext::GetDefaultStoragePartition(profile); |
+ content::IndexedDBContext* indexed_db_context = |
+ storage_partition->GetIndexedDBContext(); |
+ content::ServiceWorkerContext* service_worker_context = |
+ storage_partition->GetServiceWorkerContext(); |
+ content::CacheStorageContext* cache_storage_context = |
+ storage_partition->GetCacheStorageContext(); |
+ storage::FileSystemContext* file_system_context = |
+ storage_partition->GetFileSystemContext(); |
+ collector_.reset(new SiteDataSizeCollector( |
+ storage_partition->GetPath(), |
+ new BrowsingDataCookieHelper(profile->GetRequestContext()), |
+ new BrowsingDataDatabaseHelper(profile), |
+ new BrowsingDataLocalStorageHelper(profile), |
+ new BrowsingDataAppCacheHelper(profile), |
+ new BrowsingDataIndexedDBHelper(indexed_db_context), |
+ BrowsingDataFileSystemHelper::Create(file_system_context), |
+ BrowsingDataChannelIDHelper::Create(profile->GetRequestContext()), |
+ new BrowsingDataServiceWorkerHelper(service_worker_context), |
+ new BrowsingDataCacheStorageHelper(cache_storage_context), |
+ BrowsingDataFlashLSOHelper::Create(profile))); |
+ collector_->Fetch(base::Bind(&SiteDataCounter::OnSiteDataSizeFetched, |
+ weak_ptr_factory_.GetWeakPtr())); |
+} |
+ |
+void SiteDataCounter::OnSiteDataSizeFetched(int64_t size) { |
+ ReportResult(size); |
+} |