1 // Copyright 2014 Samsung Electronics. 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.
5 #ifndef BROWSING_DATA_MANAGER_EFL_H
6 #define BROWSING_DATA_MANAGER_EFL_H
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "storage/common/quota/quota_types.h"
19 class URLRequestContextGetter;
22 class AppCacheService;
24 class DOMStorageContext;
25 struct LocalStorageUsageInfo;
26 class StoragePartition;
28 namespace disk_cache {
34 class BrowsingDataRemoverEfl {
36 // Mask used for Remove.
38 REMOVE_LOCAL_STORAGE = 1 << 0,
39 REMOVE_INDEXEDDB = 1 << 1,
40 REMOVE_WEBSQL = 1 << 2,
41 REMOVE_FILE_SYSTEMS = 1 << 3,
42 REMOVE_APPCACHE = 1 << 4,
45 static BrowsingDataRemoverEfl* CreateForUnboundedRange(content::BrowserContext*);
46 static BrowsingDataRemoverEfl* CreateForRange(content::BrowserContext*, base::Time, base::Time);
47 void RemoveImpl(int, const GURL&);
49 virtual ~BrowsingDataRemoverEfl();
50 void ClearNetworkCache();
52 // deletes app cache for given origin
53 void DeleteAppCachesForOrigin(const GURL& origin);
56 BrowsingDataRemoverEfl(content::BrowserContext*, base::Time start, base::Time end);
58 // Quota managed data uses a different bitmask for types than
59 // BrowsingDataRemover uses. This method generates that mask.
60 static int GenerateQuotaClientMask(int);
63 void ClearNetworkCacheOnIOThread();
65 // Callback when the cache has been cleared.
66 void DoClearCache(int);
68 // Invoked on the UI thread to delete local storage.
69 void ClearLocalStorageOnUIThread();
71 // Callback to deal with the list gathered in ClearLocalStorageOnUIThread.
72 void OnGotLocalStorageUsageInfo(const std::vector<content::LocalStorageUsageInfo>&);
74 // Invoked on the IO thread to delete all storage types managed by the quota
75 // system: AppCache, Databases, FileSystems.
76 void ClearQuotaManagedDataOnIOThread();
78 // Callback to respond to QuotaManager::GetOriginsModifiedSince, which is the
79 // core of 'ClearQuotaManagedDataOnIOThread'.
80 void OnGotQuotaManagedOrigins(const std::set<GURL>&, storage::StorageType);
82 // Callback responding to deletion of a single quota managed origin's
84 void OnQuotaManagedOriginDeletion(const GURL&, storage::StorageType, storage::QuotaStatusCode);
86 // Called to check whether all temporary and persistent origin data that
87 // should be deleted has been deleted. If everything's good to go, invokes
88 // OnQuotaManagedDataDeleted on the UI thread.
89 void CheckQuotaManagedDataDeletionStatus();
91 // Completion handler that runs on the UI thread once persistent data has been
92 // deleted. Updates the waiting flag and invokes NotifyAndDeleteIfDone.
93 void OnQuotaManagedDataDeleted();
99 content::BrowserContext* browser_context_;
100 content::AppCacheService* app_cache_service_;
102 // The QuotaManager is owned by the profile; we can use a raw pointer here,
103 // and rely on the profile to destroy the object whenever it's reasonable.
104 storage::QuotaManager* quota_manager_;
106 // The DOMStorageContext is owned by the profile; we'll store a raw pointer.
107 content::DOMStorageContext* dom_storage_context_;
109 // Start time to delete from.
110 base::Time delete_begin_;
112 // End time to delete to.
113 base::Time delete_end_;
123 CacheState next_cache_state_;
124 disk_cache::Backend* cache_;
126 content::NotificationRegistrar registrar_;
127 std::set<int> renderers_;
129 // Used to delete data from HTTP cache.
130 scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
131 scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
133 bool waiting_for_clear_cache_;
134 bool waiting_for_clear_local_storage_;
135 bool waiting_for_clear_quota_managed_data_;
137 // Tracking how many origins need to be deleted, and whether we're finished
138 // gathering origins.
139 int quota_managed_origins_to_delete_count_;
140 int quota_managed_storage_types_to_delete_count_;
142 // The removal mask for the current removal operation.
145 // The origin for the current removal operation.