OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_BROWSING_DATA_SITE_DATA_SIZE_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_SITE_DATA_SIZE_COLLECTOR_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_cache_storage_helper.h" |
| 11 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 12 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_counter.h" |
| 14 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h" |
| 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "content/public/browser/storage_partition.h" |
| 22 |
| 23 namespace { |
| 24 |
| 25 typedef std::list<net::CanonicalCookie> CookieList; |
| 26 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList; |
| 27 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo> |
| 28 LocalStorageInfoList; |
| 29 typedef std::list<content::IndexedDBInfo> |
| 30 IndexedDBInfoList; |
| 31 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo> |
| 32 FileSystemInfoList; |
| 33 typedef net::ChannelIDStore::ChannelIDList ChannelIDList; |
| 34 typedef std::list<content::ServiceWorkerUsageInfo> ServiceWorkerUsageInfoList; |
| 35 typedef std::list<content::CacheStorageUsageInfo> CacheStorageUsageInfoList; |
| 36 typedef std::map<GURL, std::list<content::AppCacheInfo> > AppCacheInfoMap; |
| 37 typedef std::vector<std::string> FlashLSODomainList; |
| 38 |
| 39 } // namespace |
| 40 |
| 41 class SiteDataSizeCollector { |
| 42 public: |
| 43 SiteDataSizeCollector(const base::FilePath& default_storage_partition_path, |
| 44 BrowsingDataCookieHelper* cookie_helper, |
| 45 BrowsingDataDatabaseHelper* database_helper, |
| 46 BrowsingDataLocalStorageHelper* local_storage_helper, |
| 47 BrowsingDataAppCacheHelper* appcache_helper, |
| 48 BrowsingDataIndexedDBHelper* indexed_db_helper, |
| 49 BrowsingDataFileSystemHelper* file_system_helper, |
| 50 BrowsingDataChannelIDHelper* channel_id_helper, |
| 51 BrowsingDataServiceWorkerHelper* service_worker_helper, |
| 52 BrowsingDataCacheStorageHelper* cache_storage_helper, |
| 53 BrowsingDataFlashLSOHelper* flash_lso_helper); |
| 54 virtual ~SiteDataSizeCollector(); |
| 55 |
| 56 using FetchCallback = base::Callback<void(int64_t)>; |
| 57 |
| 58 // Requests to fetch the total storage space used by site data. |
| 59 void Fetch(const FetchCallback& callback); |
| 60 |
| 61 private: |
| 62 // Callback methods to be invoked when fetching the data is complete. |
| 63 void OnAppCacheModelInfoLoaded( |
| 64 scoped_refptr<content::AppCacheInfoCollection>); |
| 65 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list); |
| 66 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info_list); |
| 67 void OnLocalStorageModelInfoLoaded( |
| 68 const LocalStorageInfoList& local_storage_info_list); |
| 69 void OnIndexedDBModelInfoLoaded( |
| 70 const IndexedDBInfoList& indexed_db_info_list); |
| 71 void OnFileSystemModelInfoLoaded( |
| 72 const FileSystemInfoList& file_system_info_list); |
| 73 void OnChannelIDModelInfoLoaded(const ChannelIDList& channel_id_list); |
| 74 void OnServiceWorkerModelInfoLoaded( |
| 75 const ServiceWorkerUsageInfoList& service_worker_info_list); |
| 76 void OnCacheStorageModelInfoLoaded( |
| 77 const CacheStorageUsageInfoList& cache_storage_info_list); |
| 78 void OnFlashLSOInfoLoaded(const FlashLSODomainList& domains); |
| 79 |
| 80 // Callback for when the size is fetched from each storage backend. |
| 81 void OnStorageSizeFetched(int64_t size); |
| 82 |
| 83 // Path of the default storage partition of this profile. |
| 84 base::FilePath default_storage_partition_path_; |
| 85 |
| 86 // Pointers to the helper objects, needed to retreive all the types of locally |
| 87 // stored data. |
| 88 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_; |
| 89 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_; |
| 90 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_; |
| 91 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_; |
| 92 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_; |
| 93 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_; |
| 94 scoped_refptr<BrowsingDataChannelIDHelper> channel_id_helper_; |
| 95 scoped_refptr<BrowsingDataServiceWorkerHelper> service_worker_helper_; |
| 96 scoped_refptr<BrowsingDataCacheStorageHelper> cache_storage_helper_; |
| 97 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper_; |
| 98 |
| 99 // Callback called when sizes of all site data are fetched and accumulated. |
| 100 FetchCallback fetch_callback_; |
| 101 |
| 102 // Keeps track of how many fetch operations are ongoing. |
| 103 int in_flight_operations_; |
| 104 |
| 105 // Keeps track of the sum of all fetched size. |
| 106 int64_t total_bytes_; |
| 107 |
| 108 base::WeakPtrFactory<SiteDataSizeCollector> weak_ptr_factory_; |
| 109 |
| 110 DISALLOW_COPY_AND_ASSIGN(SiteDataSizeCollector); |
| 111 }; |
| 112 |
| 113 #endif // CHROME_BROWSER_BROWSING_DATA_SITE_DATA_SIZE_COLLECTOR_H_ |
OLD | NEW |