OLD | NEW |
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 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Creates a BrowsingDataRemover to remove browser data from the specified | 110 // Creates a BrowsingDataRemover to remove browser data from the specified |
111 // profile in the specified time range. Use Remove to initiate the removal. | 111 // profile in the specified time range. Use Remove to initiate the removal. |
112 BrowsingDataRemover(Profile* profile, base::Time delete_begin, | 112 BrowsingDataRemover(Profile* profile, base::Time delete_begin, |
113 base::Time delete_end); | 113 base::Time delete_end); |
114 | 114 |
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. | 116 // profile in the specified time range. |
117 BrowsingDataRemover(Profile* profile, TimePeriod time_period, | 117 BrowsingDataRemover(Profile* profile, TimePeriod time_period, |
118 base::Time delete_end); | 118 base::Time delete_end); |
119 | 119 |
120 // Removes the specified items related to browsing. | 120 // Removes the specified items related to browsing for all origins. |
121 void Remove(int remove_mask); | 121 void Remove(int remove_mask); |
122 | 122 |
123 void AddObserver(Observer* observer); | 123 void AddObserver(Observer* observer); |
124 void RemoveObserver(Observer* observer); | 124 void RemoveObserver(Observer* observer); |
125 | 125 |
126 // Called when history deletion is done. | 126 // Called when history deletion is done. |
127 void OnHistoryDeletionDone(); | 127 void OnHistoryDeletionDone(); |
128 | 128 |
129 // Quota managed data uses a different bitmask for types than | 129 // Quota managed data uses a different bitmask for types than |
130 // BrowsingDataRemover uses. This method generates that mask. | 130 // BrowsingDataRemover uses. This method generates that mask. |
131 static int GenerateQuotaClientMask(int remove_mask); | 131 static int GenerateQuotaClientMask(int remove_mask); |
132 | 132 |
133 static bool is_removing() { return removing_; } | 133 static bool is_removing() { return removing_; } |
134 | 134 |
135 private: | 135 private: |
136 // The clear API needs to be able to toggle removing_ in order to test that | 136 // The clear API needs to be able to toggle removing_ in order to test that |
137 // only one BrowsingDataRemover instance can be called at a time. | 137 // only one BrowsingDataRemover instance can be called at a time. |
138 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); | 138 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
139 | 139 |
| 140 // The BrowsingDataRemover tests need to be able to access the implementation |
| 141 // of Remove(), as it exposes details that aren't yet available in the public |
| 142 // API. As soon as those details are exposed via new methods, this should be |
| 143 // removed. |
| 144 // |
| 145 // TODO(mkwst): See http://crbug.com/113621 |
| 146 friend class BrowsingDataRemoverTest; |
| 147 |
140 enum CacheState { | 148 enum CacheState { |
141 STATE_NONE, | 149 STATE_NONE, |
142 STATE_CREATE_MAIN, | 150 STATE_CREATE_MAIN, |
143 STATE_CREATE_MEDIA, | 151 STATE_CREATE_MEDIA, |
144 STATE_DELETE_MAIN, | 152 STATE_DELETE_MAIN, |
145 STATE_DELETE_MEDIA, | 153 STATE_DELETE_MEDIA, |
146 STATE_DONE | 154 STATE_DONE |
147 }; | 155 }; |
148 | 156 |
149 // BrowsingDataRemover deletes itself (using DeleteTask) and is not supposed | 157 // BrowsingDataRemover deletes itself (using DeleteTask) and is not supposed |
150 // to be deleted by other objects so make destructor private and DeleteTask | 158 // to be deleted by other objects so make destructor private and DeleteTask |
151 // a friend. | 159 // a friend. |
152 friend class base::DeleteHelper<BrowsingDataRemover>; | 160 friend class base::DeleteHelper<BrowsingDataRemover>; |
153 virtual ~BrowsingDataRemover(); | 161 virtual ~BrowsingDataRemover(); |
154 | 162 |
155 // content::NotificationObserver method. Callback when TemplateURLService has | 163 // content::NotificationObserver method. Callback when TemplateURLService has |
156 // finished loading. Deletes the entries from the model, and if we're not | 164 // finished loading. Deletes the entries from the model, and if we're not |
157 // waiting on anything else notifies observers and deletes this | 165 // waiting on anything else notifies observers and deletes this |
158 // BrowsingDataRemover. | 166 // BrowsingDataRemover. |
159 virtual void Observe(int type, | 167 virtual void Observe(int type, |
160 const content::NotificationSource& source, | 168 const content::NotificationSource& source, |
161 const content::NotificationDetails& details) OVERRIDE; | 169 const content::NotificationDetails& details) OVERRIDE; |
162 | 170 |
163 // WaitableEventWatcher implementation. | 171 // WaitableEventWatcher implementation. |
164 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. | 172 // Called when plug-in data has been cleared. Invokes NotifyAndDeleteIfDone. |
165 virtual void OnWaitableEventSignaled( | 173 virtual void OnWaitableEventSignaled( |
166 base::WaitableEvent* waitable_event) OVERRIDE; | 174 base::WaitableEvent* waitable_event) OVERRIDE; |
167 | 175 |
| 176 // Removes the specified items related to browsing for a specific host. If the |
| 177 // provided |origin| is empty, data is removed for all origins. If |
| 178 // |remove_protected_origins| is true, then data is removed even if the origin |
| 179 // is otherwise protected (e.g. as an installed application). |
| 180 void RemoveImpl(int remove_mask, |
| 181 const GURL& origin, |
| 182 bool remove_protected_origins); |
| 183 |
168 // If we're not waiting on anything, notifies observers and deletes this | 184 // If we're not waiting on anything, notifies observers and deletes this |
169 // object. | 185 // object. |
170 void NotifyAndDeleteIfDone(); | 186 void NotifyAndDeleteIfDone(); |
171 | 187 |
172 // Callback when the network history has been deleted. Invokes | 188 // Callback when the network history has been deleted. Invokes |
173 // NotifyAndDeleteIfDone. | 189 // NotifyAndDeleteIfDone. |
174 void ClearedNetworkHistory(); | 190 void ClearedNetworkHistory(); |
175 | 191 |
176 // Invoked on the IO thread to clear the HostCache, speculative data about | 192 // Invoked on the IO thread to clear the HostCache, speculative data about |
177 // subresources on visited sites, and initial navigation history. | 193 // subresources on visited sites, and initial navigation history. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 bool waiting_for_clear_quota_managed_data_; | 299 bool waiting_for_clear_quota_managed_data_; |
284 | 300 |
285 // Tracking how many origins need to be deleted, and whether we're finished | 301 // Tracking how many origins need to be deleted, and whether we're finished |
286 // gathering origins. | 302 // gathering origins. |
287 int quota_managed_origins_to_delete_count_; | 303 int quota_managed_origins_to_delete_count_; |
288 int quota_managed_storage_types_to_delete_count_; | 304 int quota_managed_storage_types_to_delete_count_; |
289 | 305 |
290 // The removal mask for the current removal operation. | 306 // The removal mask for the current removal operation. |
291 int remove_mask_; | 307 int remove_mask_; |
292 | 308 |
| 309 // The origin for the current removal operation. |
| 310 GURL remove_origin_; |
| 311 |
| 312 // Should data for protected origins be removed? |
| 313 bool remove_protected_; |
| 314 |
293 ObserverList<Observer> observer_list_; | 315 ObserverList<Observer> observer_list_; |
294 | 316 |
295 // Used if we need to clear history. | 317 // Used if we need to clear history. |
296 CancelableRequestConsumer request_consumer_; | 318 CancelableRequestConsumer request_consumer_; |
297 | 319 |
298 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 320 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
299 }; | 321 }; |
300 | 322 |
301 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ | 323 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |