Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/synchronization/waitable_event_watcher.h" | 13 #include "base/synchronization/waitable_event_watcher.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "content/browser/appcache/chrome_appcache_service.h" | 15 #include "content/browser/appcache/chrome_appcache_service.h" |
| 16 #include "content/browser/cancelable_request.h" | 16 #include "content/browser/cancelable_request.h" |
| 17 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
| 18 #include "content/common/notification_registrar.h" | 18 #include "content/common/notification_registrar.h" |
| 19 #include "webkit/quota/quota_types.h" | |
| 19 | 20 |
| 20 class ExtensionSpecialStoragePolicy; | 21 class ExtensionSpecialStoragePolicy; |
| 21 class IOThread; | 22 class IOThread; |
| 22 class PluginDataRemover; | 23 class PluginDataRemover; |
| 23 class Profile; | 24 class Profile; |
| 24 | 25 |
| 25 namespace disk_cache { | 26 namespace disk_cache { |
| 26 class Backend; | 27 class Backend; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace net { | 30 namespace net { |
| 30 class URLRequestContextGetter; | 31 class URLRequestContextGetter; |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace webkit_database { | 34 namespace webkit_database { |
| 34 class DatabaseTracker; | 35 class DatabaseTracker; |
| 35 } | 36 } |
| 36 | 37 |
| 38 namespace quota { | |
| 39 class QuotaManager; | |
| 40 } | |
| 41 | |
| 37 // BrowsingDataRemover is responsible for removing data related to browsing: | 42 // BrowsingDataRemover is responsible for removing data related to browsing: |
| 38 // visits in url database, downloads, cookies ... | 43 // visits in url database, downloads, cookies ... |
| 39 | 44 |
| 40 class BrowsingDataRemover : public NotificationObserver, | 45 class BrowsingDataRemover : public NotificationObserver, |
| 41 public base::WaitableEventWatcher::Delegate { | 46 public base::WaitableEventWatcher::Delegate { |
| 42 public: | 47 public: |
| 43 // Time period ranges available when doing browsing data removals. | 48 // Time period ranges available when doing browsing data removals. |
| 44 enum TimePeriod { | 49 enum TimePeriod { |
| 45 LAST_HOUR = 0, | 50 LAST_HOUR = 0, |
| 46 LAST_DAY, | 51 LAST_DAY, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 | 141 |
| 137 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. | 142 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. |
| 138 void ClearedCache(); | 143 void ClearedCache(); |
| 139 | 144 |
| 140 // Invoked on the IO thread to delete from the cache. | 145 // Invoked on the IO thread to delete from the cache. |
| 141 void ClearCacheOnIOThread(); | 146 void ClearCacheOnIOThread(); |
| 142 | 147 |
| 143 // Performs the actual work to delete the cache. | 148 // Performs the actual work to delete the cache. |
| 144 void DoClearCache(int rv); | 149 void DoClearCache(int rv); |
| 145 | 150 |
| 151 // Callback responding to deletion of a single quota managed origin's | |
| 152 // temporary data. | |
| 153 void OnTemporaryQuotaManagedOriginDeletion(quota::QuotaStatusCode); | |
| 154 | |
| 155 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the | |
| 156 // core of 'ClearQuotaManagedDataOnIOThread'. | |
| 157 void OnGotTemporaryQuotaManagedOrigins(const std::set<GURL>&); | |
| 158 | |
| 159 // Callback responding to deletion of a single quota managed origin's | |
| 160 // persistent data | |
| 161 void OnPersistentQuotaManagedOriginDeletion(quota::QuotaStatusCode); | |
| 162 | |
| 163 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the | |
| 164 // core of `ClearQuotaManagedDataOnIOThread` | |
| 165 void OnGotPersistentQuotaManagedOrigins(const std::set<GURL>&); | |
| 166 | |
| 167 // Called to check whether all temporary and persistent origin data that | |
| 168 // should be deleted has been deleted. If everything's good to go, invokes | |
| 169 // NotifyAndDeleteIfDone on the UI thread. | |
| 170 void CheckTemporaryQuotaManagedDataDeletionStatus(); | |
| 171 void CheckPersistentQuotaManagedDataDeletionStatus(); | |
| 172 | |
| 173 // Invoked on the IO thread to delete all storage types managed by the quota | |
| 174 // system: AppCache, Databases, FileSystems. | |
| 175 void ClearQuotaManagedDataOnIOThread(); | |
| 176 | |
| 146 // Callback when HTML5 databases have been deleted. Invokes | 177 // Callback when HTML5 databases have been deleted. Invokes |
| 147 // NotifyAndDeleteIfDone. | 178 // NotifyAndDeleteIfDone. |
| 148 void OnClearedDatabases(int rv); | 179 void OnClearedDatabases(int rv); |
|
michaeln
2011/07/26 22:40:19
can this be deleted too?
Mike West
2011/07/27 12:49:18
I was under the impression that this handled Index
| |
| 149 | 180 |
| 150 // Invoked on the FILE thread to delete HTML5 databases. | 181 // Invoked on the FILE thread to delete HTML5 databases. |
| 151 void ClearDatabasesOnFILEThread(); | 182 void ClearDatabasesOnFILEThread(); |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 152 | 183 |
| 153 // Callback when HTML5 file systems have been cleared. Invokes | 184 // Callback when HTML5 file systems have been cleared. Invokes |
| 154 // NotifyAndDeleteIfDone. | 185 // NotifyAndDeleteIfDone. |
| 155 void OnClearedFileSystems(); | 186 void OnClearedFileSystems(); |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 156 | 187 |
| 157 // Invoked on the FILE thread to delete HTML5 file systems. | 188 // Invoked on the FILE thread to delete HTML5 file systems. |
| 158 void ClearFileSystemsOnFILEThread(); | 189 void ClearFileSystemsOnFILEThread(); |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 159 | 190 |
| 160 // Callback when the appcache has been cleared. Invokes | |
| 161 // NotifyAndDeleteIfDone. | |
| 162 void OnClearedAppCache(); | |
| 163 | |
| 164 // Invoked on the IO thread to delete from the AppCache. | |
| 165 void ClearAppCacheOnIOThread(); | |
| 166 | |
| 167 // Lower level helpers. | |
| 168 void OnGotAppCacheInfo(int rv); | |
| 169 void OnAppCacheDeleted(int rv); | |
| 170 | |
| 171 // Callback when Gears data has been deleted. Invokes NotifyAndDeleteIfDone. | 191 // Callback when Gears data has been deleted. Invokes NotifyAndDeleteIfDone. |
| 172 void OnClearedGearsData(); | 192 void OnClearedGearsData(); |
|
Mike West
2011/07/27 12:49:18
Throwing these away too, as we've removed Gears.
| |
| 173 | 193 |
| 174 // Invoked on the FILE thread to delete old Gears data. | 194 // Invoked on the FILE thread to delete old Gears data. |
| 175 void ClearGearsDataOnFILEThread(const FilePath& profile_dir); | 195 void ClearGearsDataOnFILEThread(const FilePath& profile_dir); |
| 176 | 196 |
| 177 // Calculate the begin time for the deletion range specified by |time_period|. | 197 // Calculate the begin time for the deletion range specified by |time_period|. |
| 178 base::Time CalculateBeginDeleteTime(TimePeriod time_period); | 198 base::Time CalculateBeginDeleteTime(TimePeriod time_period); |
| 179 | 199 |
| 180 // Returns true if we're all done. | 200 // Returns true if we're all done. |
| 181 bool all_done() { | 201 bool all_done() { |
| 182 return registrar_.IsEmpty() && !waiting_for_clear_cache_ && | 202 return registrar_.IsEmpty() && !waiting_for_clear_cache_ && |
| 183 !waiting_for_clear_history_ && | 203 !waiting_for_clear_history_ && |
| 204 !waiting_for_clear_temporary_quota_managed_data_ && | |
| 205 !waiting_for_clear_persistent_quota_managed_data_ && | |
| 184 !waiting_for_clear_networking_history_ && | 206 !waiting_for_clear_networking_history_ && |
| 185 !waiting_for_clear_databases_ && !waiting_for_clear_appcache_ && | |
| 186 !waiting_for_clear_lso_data_ && !waiting_for_clear_gears_data_ && | 207 !waiting_for_clear_lso_data_ && !waiting_for_clear_gears_data_ && |
| 187 !waiting_for_clear_file_systems_; | 208 !waiting_for_clear_databases_; |
| 188 } | 209 } |
| 189 | 210 |
| 190 NotificationRegistrar registrar_; | 211 NotificationRegistrar registrar_; |
| 191 | 212 |
| 192 // Profile we're to remove from. | 213 // Profile we're to remove from. |
| 193 Profile* profile_; | 214 Profile* profile_; |
| 194 | 215 |
| 216 // the QuotaManager is owned by the profile; we can use a raw pointer here, | |
| 217 // and rely on the profile to destroy the object whenever it's reasonable. | |
| 218 quota::QuotaManager* quota_manager_; | |
| 219 | |
| 195 // 'Protected' origins are not subject to data removal. | 220 // 'Protected' origins are not subject to data removal. |
| 196 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; | 221 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; |
| 197 | 222 |
| 198 // Start time to delete from. | 223 // Start time to delete from. |
| 199 const base::Time delete_begin_; | 224 const base::Time delete_begin_; |
| 200 | 225 |
| 201 // End time to delete to. | 226 // End time to delete to. |
| 202 const base::Time delete_end_; | 227 const base::Time delete_end_; |
| 203 | 228 |
| 204 // True if Remove has been invoked. | 229 // True if Remove has been invoked. |
| 205 static bool removing_; | 230 static bool removing_; |
| 206 | 231 |
| 207 // Reference to database tracker held while deleting databases. | 232 // Reference to database tracker held while deleting databases. |
| 208 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; | 233 scoped_refptr<webkit_database::DatabaseTracker> database_tracker_; |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 209 | 234 |
| 210 net::CompletionCallbackImpl<BrowsingDataRemover> database_cleared_callback_; | 235 net::CompletionCallbackImpl<BrowsingDataRemover> database_cleared_callback_; |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 211 net::CompletionCallbackImpl<BrowsingDataRemover> cache_callback_; | 236 net::CompletionCallbackImpl<BrowsingDataRemover> cache_callback_; |
| 212 | 237 |
| 213 // Used to clear the appcache. | |
| 214 scoped_refptr<ChromeAppCacheService> appcache_service_; | |
| 215 net::CompletionCallbackImpl<BrowsingDataRemover> appcache_got_info_callback_; | |
| 216 net::CompletionCallbackImpl<BrowsingDataRemover> appcache_deleted_callback_; | |
| 217 scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_; | |
| 218 int appcaches_to_be_deleted_count_; | |
| 219 | |
| 220 // Used to delete data from the HTTP caches. | 238 // Used to delete data from the HTTP caches. |
| 221 CacheState next_cache_state_; | 239 CacheState next_cache_state_; |
| 222 disk_cache::Backend* cache_; | 240 disk_cache::Backend* cache_; |
| 223 | 241 |
| 224 // Used to delete data from HTTP cache and appcache. | 242 // Used to delete data from HTTP cache. |
| 225 scoped_refptr<net::URLRequestContextGetter> main_context_getter_; | 243 scoped_refptr<net::URLRequestContextGetter> main_context_getter_; |
| 226 scoped_refptr<net::URLRequestContextGetter> media_context_getter_; | 244 scoped_refptr<net::URLRequestContextGetter> media_context_getter_; |
| 227 | 245 |
| 228 // Used to delete plugin data. | 246 // Used to delete plugin data. |
| 229 scoped_refptr<PluginDataRemover> plugin_data_remover_; | 247 scoped_refptr<PluginDataRemover> plugin_data_remover_; |
| 230 base::WaitableEventWatcher watcher_; | 248 base::WaitableEventWatcher watcher_; |
| 231 | 249 |
| 232 // True if we're waiting for various data to be deleted. | 250 // True if we're waiting for various data to be deleted. |
| 233 bool waiting_for_clear_databases_; | 251 bool waiting_for_clear_databases_; |
|
michaeln
2011/07/26 22:40:19
ditto
Mike West
2011/07/27 12:49:18
Done.
| |
| 234 bool waiting_for_clear_history_; | 252 bool waiting_for_clear_history_; |
| 253 bool waiting_for_clear_temporary_quota_managed_data_; | |
| 254 bool waiting_for_clear_persistent_quota_managed_data_; | |
|
michaeln
2011/07/26 22:40:19
see comments in the .cc file, maybe consolidate th
Mike West
2011/07/27 12:49:18
I've done this, but I don't really see a way aroun
| |
| 235 bool waiting_for_clear_networking_history_; | 255 bool waiting_for_clear_networking_history_; |
| 236 bool waiting_for_clear_cache_; | 256 bool waiting_for_clear_cache_; |
| 237 bool waiting_for_clear_appcache_; | |
| 238 bool waiting_for_clear_lso_data_; | 257 bool waiting_for_clear_lso_data_; |
| 239 bool waiting_for_clear_gears_data_; | 258 bool waiting_for_clear_gears_data_; |
| 240 bool waiting_for_clear_file_systems_; | 259 |
| 260 // Tracking how many origins need to be deleted. | |
| 261 int temporary_quota_origins_to_delete_count_; | |
| 262 int persistent_quota_origins_to_delete_count_; | |
|
michaeln
2011/07/26 22:40:19
ditto consolidation
Mike West
2011/07/27 12:49:18
ditto explanation. :)
| |
| 241 | 263 |
| 242 ObserverList<Observer> observer_list_; | 264 ObserverList<Observer> observer_list_; |
| 243 | 265 |
| 244 // Used if we need to clear history. | 266 // Used if we need to clear history. |
| 245 CancelableRequestConsumer request_consumer_; | 267 CancelableRequestConsumer request_consumer_; |
| 246 | 268 |
| 247 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 269 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
| 248 }; | 270 }; |
| 249 | 271 |
| 250 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ | 272 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |