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

Side by Side Diff: chrome/browser/browsing_data_remover.h

Issue 10413072: Teaching BrowsingDataRemover how to delete application data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bernhard #2. Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 9 #include <set>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/message_loop_helpers.h" 13 #include "base/message_loop_helpers.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/synchronization/waitable_event_watcher.h" 15 #include "base/synchronization/waitable_event_watcher.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/cancelable_request.h" 17 #include "chrome/browser/cancelable_request.h"
18 #include "chrome/browser/pepper_flash_settings_manager.h" 18 #include "chrome/browser/pepper_flash_settings_manager.h"
19 #include "chrome/browser/prefs/pref_member.h" 19 #include "chrome/browser/prefs/pref_member.h"
20 #include "content/public/browser/dom_storage_context.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "webkit/quota/quota_types.h" 24 #include "webkit/quota/quota_types.h"
24 25
25 class ExtensionSpecialStoragePolicy; 26 class ExtensionSpecialStoragePolicy;
26 class IOThread; 27 class IOThread;
27 class Profile; 28 class Profile;
28 29
29 namespace content { 30 namespace content {
30 class DOMStorageContext;
31 class PluginDataRemover; 31 class PluginDataRemover;
32 } 32 }
33 33
34 namespace disk_cache { 34 namespace disk_cache {
35 class Backend; 35 class Backend;
36 } 36 }
37 37
38 namespace net { 38 namespace net {
39 class URLRequestContextGetter; 39 class URLRequestContextGetter;
40 } 40 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Creates a BrowsingDataRemover to remove browser data from the specified 115 // Creates a BrowsingDataRemover to remove browser data from the specified
116 // profile in the specified time range. Use Remove to initiate the removal. 116 // profile in the specified time range. Use Remove to initiate the removal.
117 BrowsingDataRemover(Profile* profile, base::Time delete_begin, 117 BrowsingDataRemover(Profile* profile, base::Time delete_begin,
118 base::Time delete_end); 118 base::Time delete_end);
119 119
120 // Creates a BrowsingDataRemover to remove browser data from the specified 120 // Creates a BrowsingDataRemover to remove browser data from the specified
121 // profile in the specified time range. 121 // profile in the specified time range.
122 BrowsingDataRemover(Profile* profile, TimePeriod time_period, 122 BrowsingDataRemover(Profile* profile, TimePeriod time_period,
123 base::Time delete_end); 123 base::Time delete_end);
124 124
125 // Removes the specified items related to browsing for all origins. 125 // Removes the specified items related to browsing for all origins that match
126 void Remove(int remove_mask); 126 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask).
127 void Remove(int remove_mask, int origin_set_mask);
127 128
128 void AddObserver(Observer* observer); 129 void AddObserver(Observer* observer);
129 void RemoveObserver(Observer* observer); 130 void RemoveObserver(Observer* observer);
130 131
131 // Called when history deletion is done. 132 // Called when history deletion is done.
132 void OnHistoryDeletionDone(); 133 void OnHistoryDeletionDone();
133 134
134 // Quota managed data uses a different bitmask for types than 135 // Quota managed data uses a different bitmask for types than
135 // BrowsingDataRemover uses. This method generates that mask. 136 // BrowsingDataRemover uses. This method generates that mask.
136 static int GenerateQuotaClientMask(int remove_mask); 137 static int GenerateQuotaClientMask(int remove_mask);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // WaitableEventWatcher implementation. 180 // WaitableEventWatcher implementation.
180 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. 181 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone.
181 virtual void OnWaitableEventSignaled( 182 virtual void OnWaitableEventSignaled(
182 base::WaitableEvent* waitable_event) OVERRIDE; 183 base::WaitableEvent* waitable_event) OVERRIDE;
183 184
184 // PepperFlashSettingsManager::Client implementation. 185 // PepperFlashSettingsManager::Client implementation.
185 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id, 186 virtual void OnDeauthorizeContentLicensesCompleted(uint32 request_id,
186 bool success) OVERRIDE; 187 bool success) OVERRIDE;
187 188
188 // Removes the specified items related to browsing for a specific host. If the 189 // Removes the specified items related to browsing for a specific host. If the
189 // provided |origin| is empty, data is removed for all origins. If 190 // provided |origin| is empty, data is removed for all origins. The
190 // |remove_protected_origins| is true, then data is removed even if the origin 191 // |origin_set_mask| parameter defines the set of origins from which data
191 // is otherwise protected (e.g. as an installed application). 192 // should be removed (protected, unprotected, or both).
192 void RemoveImpl(int remove_mask, 193 void RemoveImpl(int remove_mask,
193 const GURL& origin, 194 const GURL& origin,
194 bool remove_protected_origins); 195 int origin_set_mask);
195 196
196 // If we're not waiting on anything, notifies observers and deletes this 197 // If we're not waiting on anything, notifies observers and deletes this
197 // object. 198 // object.
198 void NotifyAndDeleteIfDone(); 199 void NotifyAndDeleteIfDone();
199 200
200 // Callback when the network history has been deleted. Invokes 201 // Callback when the network history has been deleted. Invokes
201 // NotifyAndDeleteIfDone. 202 // NotifyAndDeleteIfDone.
202 void ClearedNetworkHistory(); 203 void ClearedNetworkHistory();
203 204
204 // Invoked on the IO thread to clear the HostCache, speculative data about 205 // Invoked on the IO thread to clear the HostCache, speculative data about
205 // subresources on visited sites, and initial navigation history. 206 // subresources on visited sites, and initial navigation history.
206 void ClearNetworkingHistory(IOThread* io_thread); 207 void ClearNetworkingHistory(IOThread* io_thread);
207 208
208 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. 209 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone.
209 void ClearedCache(); 210 void ClearedCache();
210 211
211 // Invoked on the IO thread to delete from the cache. 212 // Invoked on the IO thread to delete from the cache.
212 void ClearCacheOnIOThread(); 213 void ClearCacheOnIOThread();
213 214
214 // Performs the actual work to delete the cache. 215 // Performs the actual work to delete the cache.
215 void DoClearCache(int rv); 216 void DoClearCache(int rv);
216 217
218 // Invoked on the IO thread to delete local storage.
219 void ClearLocalStorageOnIOThread();
220
221 // Callback to deal with the list gathered in ClearLocalStorageOnIOThread.
222 void OnGotLocalStorageUsageInfo(
223 const std::vector<content::DOMStorageContext::UsageInfo>& infos);
224
225 // Callback on deletion of local storage data. Invokes NotifyAndDeleteIfDone.
226 void OnLocalStorageCleared();
227
217 // Invoked on the IO thread to delete all storage types managed by the quota 228 // Invoked on the IO thread to delete all storage types managed by the quota
218 // system: AppCache, Databases, FileSystems. 229 // system: AppCache, Databases, FileSystems.
219 void ClearQuotaManagedDataOnIOThread(); 230 void ClearQuotaManagedDataOnIOThread();
220 231
221 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the 232 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the
222 // core of 'ClearQuotaManagedDataOnIOThread'. 233 // core of 'ClearQuotaManagedDataOnIOThread'.
223 void OnGotQuotaManagedOrigins(const std::set<GURL>& origins, 234 void OnGotQuotaManagedOrigins(const std::set<GURL>& origins,
224 quota::StorageType type); 235 quota::StorageType type);
225 236
226 // Callback responding to deletion of a single quota managed origin's 237 // Callback responding to deletion of a single quota managed origin's
(...skipping 24 matching lines...) Expand all
251 void OnClearedServerBoundCerts(); 262 void OnClearedServerBoundCerts();
252 263
253 // Calculate the begin time for the deletion range specified by |time_period|. 264 // Calculate the begin time for the deletion range specified by |time_period|.
254 base::Time CalculateBeginDeleteTime(TimePeriod time_period); 265 base::Time CalculateBeginDeleteTime(TimePeriod time_period);
255 266
256 // Returns true if we're all done. 267 // Returns true if we're all done.
257 bool all_done() { 268 bool all_done() {
258 return registrar_.IsEmpty() && !waiting_for_clear_cache_ && 269 return registrar_.IsEmpty() && !waiting_for_clear_cache_ &&
259 !waiting_for_clear_cookies_count_&& 270 !waiting_for_clear_cookies_count_&&
260 !waiting_for_clear_history_ && 271 !waiting_for_clear_history_ &&
272 !waiting_for_clear_local_storage_ &&
261 !waiting_for_clear_networking_history_ && 273 !waiting_for_clear_networking_history_ &&
262 !waiting_for_clear_server_bound_certs_ && 274 !waiting_for_clear_server_bound_certs_ &&
263 !waiting_for_clear_plugin_data_ && 275 !waiting_for_clear_plugin_data_ &&
264 !waiting_for_clear_quota_managed_data_ && 276 !waiting_for_clear_quota_managed_data_ &&
265 !waiting_for_clear_content_licenses_; 277 !waiting_for_clear_content_licenses_;
266 } 278 }
267 279
268 // Setter for removing_; DCHECKs that we can only start removing if we're not 280 // Setter for removing_; DCHECKs that we can only start removing if we're not
269 // already removing, and vice-versa. 281 // already removing, and vice-versa.
270 static void set_removing(bool removing); 282 static void set_removing(bool removing);
271 283
272 content::NotificationRegistrar registrar_; 284 content::NotificationRegistrar registrar_;
273 285
274 // Profile we're to remove from. 286 // Profile we're to remove from.
275 Profile* profile_; 287 Profile* profile_;
276 288
277 // The QuotaManager is owned by the profile; we can use a raw pointer here, 289 // The QuotaManager is owned by the profile; we can use a raw pointer here,
278 // and rely on the profile to destroy the object whenever it's reasonable. 290 // and rely on the profile to destroy the object whenever it's reasonable.
279 quota::QuotaManager* quota_manager_; 291 quota::QuotaManager* quota_manager_;
280 292
293 // The DOMStorageContext is owned by the profile; we'll store a raw pointer.
294 content::DOMStorageContext* dom_storage_context_;
295
281 // 'Protected' origins are not subject to data removal. 296 // 'Protected' origins are not subject to data removal.
282 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; 297 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_;
283 298
284 // Start time to delete from. 299 // Start time to delete from.
285 const base::Time delete_begin_; 300 const base::Time delete_begin_;
286 301
287 // End time to delete to. 302 // End time to delete to.
288 const base::Time delete_end_; 303 const base::Time delete_end_;
289 304
290 // True if Remove has been invoked. 305 // True if Remove has been invoked.
(...skipping 13 matching lines...) Expand all
304 // Used to deauthorize content licenses for Pepper Flash. 319 // Used to deauthorize content licenses for Pepper Flash.
305 scoped_ptr<PepperFlashSettingsManager> pepper_flash_settings_manager_; 320 scoped_ptr<PepperFlashSettingsManager> pepper_flash_settings_manager_;
306 uint32 deauthorize_content_licenses_request_id_; 321 uint32 deauthorize_content_licenses_request_id_;
307 322
308 // True if we're waiting for various data to be deleted. 323 // True if we're waiting for various data to be deleted.
309 // These may only be accessed from UI thread in order to avoid races! 324 // These may only be accessed from UI thread in order to avoid races!
310 bool waiting_for_clear_cache_; 325 bool waiting_for_clear_cache_;
311 // Non-zero if waiting for cookies to be cleared. 326 // Non-zero if waiting for cookies to be cleared.
312 int waiting_for_clear_cookies_count_; 327 int waiting_for_clear_cookies_count_;
313 bool waiting_for_clear_history_; 328 bool waiting_for_clear_history_;
329 bool waiting_for_clear_local_storage_;
314 bool waiting_for_clear_networking_history_; 330 bool waiting_for_clear_networking_history_;
315 bool waiting_for_clear_server_bound_certs_; 331 bool waiting_for_clear_server_bound_certs_;
316 bool waiting_for_clear_plugin_data_; 332 bool waiting_for_clear_plugin_data_;
317 bool waiting_for_clear_quota_managed_data_; 333 bool waiting_for_clear_quota_managed_data_;
318 bool waiting_for_clear_content_licenses_; 334 bool waiting_for_clear_content_licenses_;
319 335
320 // Tracking how many origins need to be deleted, and whether we're finished 336 // Tracking how many origins need to be deleted, and whether we're finished
321 // gathering origins. 337 // gathering origins.
322 int quota_managed_origins_to_delete_count_; 338 int quota_managed_origins_to_delete_count_;
323 int quota_managed_storage_types_to_delete_count_; 339 int quota_managed_storage_types_to_delete_count_;
324 340
325 // The removal mask for the current removal operation. 341 // The removal mask for the current removal operation.
326 int remove_mask_; 342 int remove_mask_;
327 343
328 // The origin for the current removal operation. 344 // The origin for the current removal operation.
329 GURL remove_origin_; 345 GURL remove_origin_;
330 346
331 // Should data for protected origins be removed? 347 // From which types of origins should we remove data?
332 bool remove_protected_; 348 int origin_set_mask_;
333 349
334 ObserverList<Observer> observer_list_; 350 ObserverList<Observer> observer_list_;
335 351
336 // Used if we need to clear history. 352 // Used if we need to clear history.
337 CancelableRequestConsumer request_consumer_; 353 CancelableRequestConsumer request_consumer_;
338 354
339 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); 355 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover);
340 }; 356 };
341 357
342 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ 358 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698