OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/synchronization/waitable_event_watcher.h" |
13 #include "base/time.h" | 14 #include "base/time.h" |
14 #include "chrome/browser/appcache/chrome_appcache_service.h" | 15 #include "chrome/browser/appcache/chrome_appcache_service.h" |
15 #include "chrome/browser/cancelable_request.h" | 16 #include "chrome/browser/cancelable_request.h" |
16 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
17 | 18 |
18 class PluginDataRemover; | 19 class PluginDataRemover; |
19 class Profile; | 20 class Profile; |
20 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
21 | 22 |
22 namespace disk_cache { | 23 namespace disk_cache { |
23 class Backend; | 24 class Backend; |
24 } | 25 } |
25 | 26 |
26 namespace webkit_database { | 27 namespace webkit_database { |
27 class DatabaseTracker; | 28 class DatabaseTracker; |
28 } | 29 } |
29 | 30 |
30 // BrowsingDataRemover is responsible for removing data related to browsing: | 31 // BrowsingDataRemover is responsible for removing data related to browsing: |
31 // visits in url database, downloads, cookies ... | 32 // visits in url database, downloads, cookies ... |
32 | 33 |
33 class BrowsingDataRemover : public NotificationObserver { | 34 class BrowsingDataRemover : public NotificationObserver, |
| 35 public base::WaitableEventWatcher::Delegate { |
34 public: | 36 public: |
35 // Time period ranges available when doing browsing data removals. | 37 // Time period ranges available when doing browsing data removals. |
36 enum TimePeriod { | 38 enum TimePeriod { |
37 LAST_HOUR = 0, | 39 LAST_HOUR = 0, |
38 LAST_DAY, | 40 LAST_DAY, |
39 LAST_WEEK, | 41 LAST_WEEK, |
40 FOUR_WEEKS, | 42 FOUR_WEEKS, |
41 EVERYTHING | 43 EVERYTHING |
42 }; | 44 }; |
43 | 45 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 friend class DeleteTask<BrowsingDataRemover>; | 101 friend class DeleteTask<BrowsingDataRemover>; |
100 ~BrowsingDataRemover(); | 102 ~BrowsingDataRemover(); |
101 | 103 |
102 // NotificationObserver method. Callback when TemplateURLModel has finished | 104 // NotificationObserver method. Callback when TemplateURLModel has finished |
103 // loading. Deletes the entries from the model, and if we're not waiting on | 105 // loading. Deletes the entries from the model, and if we're not waiting on |
104 // anything else notifies observers and deletes this BrowsingDataRemover. | 106 // anything else notifies observers and deletes this BrowsingDataRemover. |
105 virtual void Observe(NotificationType type, | 107 virtual void Observe(NotificationType type, |
106 const NotificationSource& source, | 108 const NotificationSource& source, |
107 const NotificationDetails& details); | 109 const NotificationDetails& details); |
108 | 110 |
| 111 // WaitableEventWatcher implementation. |
| 112 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. |
| 113 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
| 114 |
109 // If we're not waiting on anything, notifies observers and deletes this | 115 // If we're not waiting on anything, notifies observers and deletes this |
110 // object. | 116 // object. |
111 void NotifyAndDeleteIfDone(); | 117 void NotifyAndDeleteIfDone(); |
112 | 118 |
113 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. | 119 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. |
114 void ClearedCache(); | 120 void ClearedCache(); |
115 | 121 |
116 // Invoked on the IO thread to delete from the cache. | 122 // Invoked on the IO thread to delete from the cache. |
117 void ClearCacheOnIOThread(); | 123 void ClearCacheOnIOThread(); |
118 | 124 |
(...skipping 16 matching lines...) Expand all Loading... |
135 // Invoked on the IO thread to delete from the AppCache, ignoring data from | 141 // Invoked on the IO thread to delete from the AppCache, ignoring data from |
136 // any origins within the |origin_whitelist|. | 142 // any origins within the |origin_whitelist|. |
137 void ClearAppCacheOnIOThread(base::Time delete_begin, | 143 void ClearAppCacheOnIOThread(base::Time delete_begin, |
138 const std::vector<GURL>& origin_whitelist); | 144 const std::vector<GURL>& origin_whitelist); |
139 | 145 |
140 // Lower level helpers. | 146 // Lower level helpers. |
141 void OnGotAppCacheInfo(int rv); | 147 void OnGotAppCacheInfo(int rv); |
142 void OnAppCacheDeleted(int rv); | 148 void OnAppCacheDeleted(int rv); |
143 ChromeAppCacheService* GetAppCacheService(); | 149 ChromeAppCacheService* GetAppCacheService(); |
144 | 150 |
145 // Callback when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. | |
146 void OnClearedPluginData(); | |
147 | |
148 // Calculate the begin time for the deletion range specified by |time_period|. | 151 // Calculate the begin time for the deletion range specified by |time_period|. |
149 base::Time CalculateBeginDeleteTime(TimePeriod time_period); | 152 base::Time CalculateBeginDeleteTime(TimePeriod time_period); |
150 | 153 |
151 // Returns true if we're all done. | 154 // Returns true if we're all done. |
152 bool all_done() { | 155 bool all_done() { |
153 return registrar_.IsEmpty() && !waiting_for_clear_cache_ && | 156 return registrar_.IsEmpty() && !waiting_for_clear_cache_ && |
154 !waiting_for_clear_history_ && !waiting_for_clear_databases_ && | 157 !waiting_for_clear_history_ && !waiting_for_clear_databases_ && |
155 !waiting_for_clear_appcache_ && !waiting_for_clear_lso_data_; | 158 !waiting_for_clear_appcache_ && !waiting_for_clear_lso_data_; |
156 } | 159 } |
157 | 160 |
(...skipping 26 matching lines...) Expand all Loading... |
184 int appcaches_to_be_deleted_count_; | 187 int appcaches_to_be_deleted_count_; |
185 | 188 |
186 // Used to delete data from the HTTP caches. | 189 // Used to delete data from the HTTP caches. |
187 CacheState next_cache_state_; | 190 CacheState next_cache_state_; |
188 disk_cache::Backend* cache_; | 191 disk_cache::Backend* cache_; |
189 scoped_refptr<URLRequestContextGetter> main_context_getter_; | 192 scoped_refptr<URLRequestContextGetter> main_context_getter_; |
190 scoped_refptr<URLRequestContextGetter> media_context_getter_; | 193 scoped_refptr<URLRequestContextGetter> media_context_getter_; |
191 | 194 |
192 // Used to delete plugin data. | 195 // Used to delete plugin data. |
193 scoped_refptr<PluginDataRemover> plugin_data_remover_; | 196 scoped_refptr<PluginDataRemover> plugin_data_remover_; |
| 197 base::WaitableEventWatcher watcher_; |
194 | 198 |
195 // True if we're waiting for various data to be deleted. | 199 // True if we're waiting for various data to be deleted. |
196 bool waiting_for_clear_databases_; | 200 bool waiting_for_clear_databases_; |
197 bool waiting_for_clear_history_; | 201 bool waiting_for_clear_history_; |
198 bool waiting_for_clear_cache_; | 202 bool waiting_for_clear_cache_; |
199 bool waiting_for_clear_appcache_; | 203 bool waiting_for_clear_appcache_; |
200 bool waiting_for_clear_lso_data_; | 204 bool waiting_for_clear_lso_data_; |
201 | 205 |
202 ObserverList<Observer> observer_list_; | 206 ObserverList<Observer> observer_list_; |
203 | 207 |
204 // Used if we need to clear history. | 208 // Used if we need to clear history. |
205 CancelableRequestConsumer request_consumer_; | 209 CancelableRequestConsumer request_consumer_; |
206 | 210 |
207 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 211 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
208 }; | 212 }; |
209 | 213 |
210 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ | 214 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |