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

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

Powered by Google App Engine
This is Rietveld 408576698