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_BROWSING_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // Observer is notified when the removal is done. Done means keywords have | 109 // Observer is notified when the removal is done. Done means keywords have |
110 // been deleted, cache cleared and all other tasks scheduled. | 110 // been deleted, cache cleared and all other tasks scheduled. |
111 class Observer { | 111 class Observer { |
112 public: | 112 public: |
113 virtual void OnBrowsingDataRemoverDone() = 0; | 113 virtual void OnBrowsingDataRemoverDone() = 0; |
114 | 114 |
115 protected: | 115 protected: |
116 virtual ~Observer() {} | 116 virtual ~Observer() {} |
117 }; | 117 }; |
118 | 118 |
119 // Creates a BrowsingDataRemover to remove browser data from the specified | 119 // Creates a BrowsingDataRemover object that removes data regardless of the |
120 // profile in the specified time range. Use Remove to initiate the removal. | 120 // time it was last modified. |
121 BrowsingDataRemover(Profile* profile, base::Time delete_begin, | 121 static BrowsingDataRemover* CreateForUnboundedRange(Profile* profile); |
122 base::Time delete_end); | |
123 | 122 |
124 // Creates a BrowsingDataRemover to remove browser data from the specified | 123 // Creates a BrowsingDataRemover object bound on both sides by a time. |
125 // profile in the specified time range. | 124 static BrowsingDataRemover* CreateForRange(Profile* profile, |
126 BrowsingDataRemover(Profile* profile, TimePeriod time_period, | 125 base::Time delete_begin, |
127 base::Time delete_end); | 126 base::Time delete_end); |
127 | |
128 // Creates a BrowsingDataRemover bound to a specific period of time (as | |
129 // defined via a TimePeriod). | |
130 static BrowsingDataRemover* CreateForPeriod(Profile* profile, | |
131 TimePeriod deletionPeriod); | |
132 | |
133 // Quota managed data uses a different bitmask for types than | |
134 // BrowsingDataRemover uses. This method generates that mask. | |
135 static int GenerateQuotaClientMask(int remove_mask); | |
136 | |
137 static bool is_removing() { return removing_; } | |
markusheintz_
2012/08/28 13:10:23
Please add a comment about the meaning of the retu
Mike West
2012/08/28 13:28:39
Done.
| |
128 | 138 |
129 // Removes the specified items related to browsing for all origins that match | 139 // Removes the specified items related to browsing for all origins that match |
130 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). | 140 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). |
131 void Remove(int remove_mask, int origin_set_mask); | 141 void Remove(int remove_mask, int origin_set_mask); |
132 | 142 |
133 void AddObserver(Observer* observer); | 143 void AddObserver(Observer* observer); |
134 void RemoveObserver(Observer* observer); | 144 void RemoveObserver(Observer* observer); |
135 | 145 |
136 // Called when history deletion is done. | 146 // Called when history deletion is done. |
137 void OnHistoryDeletionDone(); | 147 void OnHistoryDeletionDone(); |
138 | 148 |
139 // Quota managed data uses a different bitmask for types than | |
140 // BrowsingDataRemover uses. This method generates that mask. | |
141 static int GenerateQuotaClientMask(int remove_mask); | |
142 | |
143 // Used for testing. | 149 // Used for testing. |
144 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); | 150 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); |
145 | 151 |
146 static bool is_removing() { return removing_; } | |
147 | |
148 private: | 152 private: |
149 // The clear API needs to be able to toggle removing_ in order to test that | 153 // The clear API needs to be able to toggle removing_ in order to test that |
150 // only one BrowsingDataRemover instance can be called at a time. | 154 // only one BrowsingDataRemover instance can be called at a time. |
151 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); | 155 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); |
152 | 156 |
153 // The BrowsingDataRemover tests need to be able to access the implementation | 157 // The BrowsingDataRemover tests need to be able to access the implementation |
154 // of Remove(), as it exposes details that aren't yet available in the public | 158 // of Remove(), as it exposes details that aren't yet available in the public |
155 // API. As soon as those details are exposed via new methods, this should be | 159 // API. As soon as those details are exposed via new methods, this should be |
156 // removed. | 160 // removed. |
157 // | 161 // |
158 // TODO(mkwst): See http://crbug.com/113621 | 162 // TODO(mkwst): See http://crbug.com/113621 |
159 friend class BrowsingDataRemoverTest; | 163 friend class BrowsingDataRemoverTest; |
160 | 164 |
161 enum CacheState { | 165 enum CacheState { |
162 STATE_NONE, | 166 STATE_NONE, |
163 STATE_CREATE_MAIN, | 167 STATE_CREATE_MAIN, |
164 STATE_CREATE_MEDIA, | 168 STATE_CREATE_MEDIA, |
165 STATE_DELETE_MAIN, | 169 STATE_DELETE_MAIN, |
166 STATE_DELETE_MEDIA, | 170 STATE_DELETE_MEDIA, |
167 STATE_DONE | 171 STATE_DONE |
168 }; | 172 }; |
169 | 173 |
174 // Creates a BrowsingDataRemover to remove browser data from the specified | |
175 // profile in the specified time range. Use Remove to initiate the removal. | |
176 // The constructor is private: use the static Create* methods instead. | |
markusheintz_
2012/08/28 13:10:23
I think this line is not needed. The pure existenc
Mike West
2012/08/28 13:28:39
Done.
| |
177 BrowsingDataRemover(Profile* profile, base::Time delete_begin, | |
178 base::Time delete_end); | |
179 | |
170 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed | 180 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed |
171 // to be deleted by other objects so make destructor private and DeleteHelper | 181 // to be deleted by other objects so make destructor private and DeleteHelper |
172 // a friend. | 182 // a friend. |
173 friend class base::DeleteHelper<BrowsingDataRemover>; | 183 friend class base::DeleteHelper<BrowsingDataRemover>; |
174 virtual ~BrowsingDataRemover(); | 184 virtual ~BrowsingDataRemover(); |
175 | 185 |
176 // content::NotificationObserver method. Callback when TemplateURLService has | 186 // content::NotificationObserver method. Callback when TemplateURLService has |
177 // finished loading. Deletes the entries from the model, and if we're not | 187 // finished loading. Deletes the entries from the model, and if we're not |
178 // waiting on anything else notifies observers and deletes this | 188 // waiting on anything else notifies observers and deletes this |
179 // BrowsingDataRemover. | 189 // BrowsingDataRemover. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 void OnClearedServerBoundCerts(); | 290 void OnClearedServerBoundCerts(); |
281 | 291 |
282 // Callback on the DB thread so that we can wait for the form data to be | 292 // Callback on the DB thread so that we can wait for the form data to be |
283 // cleared. | 293 // cleared. |
284 void FormDataDBThreadHop(); | 294 void FormDataDBThreadHop(); |
285 | 295 |
286 // Callback from the above method. | 296 // Callback from the above method. |
287 void OnClearedFormData(); | 297 void OnClearedFormData(); |
288 | 298 |
289 // Calculate the begin time for the deletion range specified by |time_period|. | 299 // Calculate the begin time for the deletion range specified by |time_period|. |
290 base::Time CalculateBeginDeleteTime(TimePeriod time_period); | 300 static base::Time CalculateBeginDeleteTime(TimePeriod time_period); |
markusheintz_
2012/08/28 13:10:23
Now that this method is static, please move the me
Mike West
2012/08/28 13:28:39
Done.
| |
291 | 301 |
292 // Returns true if we're all done. | 302 // Returns true if we're all done. |
293 bool AllDone(); | 303 bool AllDone(); |
294 | 304 |
295 // Setter for removing_; DCHECKs that we can only start removing if we're not | 305 // Setter for removing_; DCHECKs that we can only start removing if we're not |
296 // already removing, and vice-versa. | 306 // already removing, and vice-versa. |
297 static void set_removing(bool removing); | 307 static void set_removing(bool removing); |
298 | 308 |
299 content::NotificationRegistrar registrar_; | 309 content::NotificationRegistrar registrar_; |
300 | 310 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 | 376 |
367 ObserverList<Observer> observer_list_; | 377 ObserverList<Observer> observer_list_; |
368 | 378 |
369 // Used if we need to clear history. | 379 // Used if we need to clear history. |
370 CancelableRequestConsumer request_consumer_; | 380 CancelableRequestConsumer request_consumer_; |
371 | 381 |
372 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 382 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
373 }; | 383 }; |
374 | 384 |
375 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 385 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |