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

Side by Side Diff: chrome/browser/browsing_data/site_data_size_collector.h

Issue 2092663002: Add a counter to calculate the total size of site data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
(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_quota_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_service_worker_helper.h"
21 #include "chrome/browser/profiles/profile.h"
22 #include "content/public/browser/storage_partition.h"
23
24 namespace {
25
26 typedef std::list<net::CanonicalCookie> CookieList;
27 typedef std::list<BrowsingDataDatabaseHelper::DatabaseInfo> DatabaseInfoList;
28 typedef std::list<BrowsingDataLocalStorageHelper::LocalStorageInfo>
29 LocalStorageInfoList;
30 typedef std::list<content::IndexedDBInfo>
31 IndexedDBInfoList;
32 typedef std::list<BrowsingDataFileSystemHelper::FileSystemInfo>
33 FileSystemInfoList;
34 typedef std::list<BrowsingDataQuotaHelper::QuotaInfo> QuotaInfoList;
35 typedef net::ChannelIDStore::ChannelIDList ChannelIDList;
36 typedef std::list<content::ServiceWorkerUsageInfo> ServiceWorkerUsageInfoList;
37 typedef std::list<content::CacheStorageUsageInfo> CacheStorageUsageInfoList;
38 typedef std::map<GURL, std::list<content::AppCacheInfo> > AppCacheInfoMap;
39 typedef std::vector<std::string> FlashLSODomainList;
40
41 } // namespace
42
43 class SiteDataSizeCollector {
44 public:
45 explicit SiteDataSizeCollector(Profile* profile);
46 virtual ~SiteDataSizeCollector();
47
48 using FetchCallback = base::Callback<void(int64_t)>;
49
50 // Requests to fetch the total storage space used by site data.
51 void Fetch(const FetchCallback& callback);
52
53 private:
54 // Callback methods to be invoked when fetching the data is complete.
55 void OnAppCacheModelInfoLoaded(
56 scoped_refptr<content::AppCacheInfoCollection>);
57 void OnCookiesModelInfoLoaded(const net::CookieList& cookie_list);
58 void OnDatabaseModelInfoLoaded(const DatabaseInfoList& database_info);
59 void OnLocalStorageModelInfoLoaded(
60 const LocalStorageInfoList& local_storage_info);
61 void OnIndexedDBModelInfoLoaded(
62 const IndexedDBInfoList& indexed_db_info);
63 void OnFileSystemModelInfoLoaded(
64 const FileSystemInfoList& file_system_info);
65 void OnQuotaModelInfoLoaded(const QuotaInfoList& quota_info);
66 void OnChannelIDModelInfoLoaded(const ChannelIDList& channel_id_list);
67 void OnServiceWorkerModelInfoLoaded(
68 const ServiceWorkerUsageInfoList& service_worker_info);
69 void OnCacheStorageModelInfoLoaded(
70 const CacheStorageUsageInfoList& cache_storage_info);
71 void OnFlashLSOInfoLoaded(const FlashLSODomainList& domains);
72
73 // Pointers to the helper objects, needed to retreive all the types of locally
74 // stored data.
75 scoped_refptr<BrowsingDataAppCacheHelper> appcache_helper_;
76 scoped_refptr<BrowsingDataCookieHelper> cookie_helper_;
77 scoped_refptr<BrowsingDataDatabaseHelper> database_helper_;
78 scoped_refptr<BrowsingDataLocalStorageHelper> local_storage_helper_;
79 scoped_refptr<BrowsingDataIndexedDBHelper> indexed_db_helper_;
80 scoped_refptr<BrowsingDataFileSystemHelper> file_system_helper_;
81 scoped_refptr<BrowsingDataQuotaHelper> quota_helper_;
82 scoped_refptr<BrowsingDataChannelIDHelper> channel_id_helper_;
83 scoped_refptr<BrowsingDataServiceWorkerHelper> service_worker_helper_;
84 scoped_refptr<BrowsingDataCacheStorageHelper> cache_storage_helper_;
85 scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper_;
86
87 // Callback for when the size is fetched from each storage backend.
88 void OnStorageSizeFetched(int64_t size);
89
90 // Callback called when sizes of all site data are fetched and accumulated.
91 FetchCallback fetch_callback_;
92
93 // Profile whose browsing data should be counted.
94 Profile* profile_;
95
96 // Default storage partition of the browser context.
msramek 2016/06/23 21:30:35 nit: "...of this profile." (it's not called browse
fukino 2016/06/30 09:21:24 I removed storage_partition_. Only storage_partiti
97 content::StoragePartition* storage_partition_;
98
99 // Keeps track of how many fetch operations are ongoing.
100 int in_flight_operations_;
101
102 // Keeps track of the sum of all fetched size.
103 int64_t total_bytes_;
104
105 base::WeakPtrFactory<SiteDataSizeCollector> weak_ptr_factory_;
106
107 DISALLOW_COPY_AND_ASSIGN(SiteDataSizeCollector);
108 };
109
110 #endif // CHROME_BROWSER_BROWSING_DATA_SITE_DATA_SIZE_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698