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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // Observer is notified when the removal is done. Done means keywords have | 145 // Observer is notified when the removal is done. Done means keywords have |
146 // been deleted, cache cleared and all other tasks scheduled. | 146 // been deleted, cache cleared and all other tasks scheduled. |
147 class Observer { | 147 class Observer { |
148 public: | 148 public: |
149 virtual void OnBrowsingDataRemoverDone() = 0; | 149 virtual void OnBrowsingDataRemoverDone() = 0; |
150 | 150 |
151 protected: | 151 protected: |
152 virtual ~Observer() {} | 152 virtual ~Observer() {} |
153 }; | 153 }; |
154 | 154 |
| 155 using Callback = base::Callback<void(const NotificationDetails&)>; |
| 156 using CallbackSubscription = scoped_ptr< |
| 157 base::CallbackList<void(const NotificationDetails&)>::Subscription>; |
| 158 |
155 // The completion inhibitor can artificially delay completion of the browsing | 159 // The completion inhibitor can artificially delay completion of the browsing |
156 // data removal process. It is used during testing to simulate scenarios in | 160 // data removal process. It is used during testing to simulate scenarios in |
157 // which the deletion stalls or takes a very long time. | 161 // which the deletion stalls or takes a very long time. |
158 class CompletionInhibitor { | 162 class CompletionInhibitor { |
159 public: | 163 public: |
160 // Invoked when a |remover| is just about to complete clearing browser data, | 164 // Invoked when a |remover| is just about to complete clearing browser data, |
161 // and will be prevented from completing until after the callback | 165 // and will be prevented from completing until after the callback |
162 // |continue_to_completion| is run. | 166 // |continue_to_completion| is run. |
163 virtual void OnBrowsingDataRemoverWouldComplete( | 167 virtual void OnBrowsingDataRemoverWouldComplete( |
164 BrowsingDataRemover* remover, | 168 BrowsingDataRemover* remover, |
(...skipping 28 matching lines...) Expand all Loading... |
193 static bool is_removing() { return is_removing_; } | 197 static bool is_removing() { return is_removing_; } |
194 | 198 |
195 // Sets a CompletionInhibitor, which will be notified each time an instance is | 199 // Sets a CompletionInhibitor, which will be notified each time an instance is |
196 // about to complete a browsing data removal process, and will be able to | 200 // about to complete a browsing data removal process, and will be able to |
197 // artificially delay the completion. | 201 // artificially delay the completion. |
198 static void set_completion_inhibitor_for_testing( | 202 static void set_completion_inhibitor_for_testing( |
199 CompletionInhibitor* inhibitor) { | 203 CompletionInhibitor* inhibitor) { |
200 completion_inhibitor_ = inhibitor; | 204 completion_inhibitor_ = inhibitor; |
201 } | 205 } |
202 | 206 |
| 207 // Add a callback to the list of callbacks to be called during a browsing data |
| 208 // removal event. Returns a subscription object that can be used to |
| 209 // un-register the callback. |
| 210 static CallbackSubscription RegisterOnBrowsingDataRemovedCallback( |
| 211 const Callback& callback); |
| 212 |
203 // Removes the specified items related to browsing for all origins that match | 213 // Removes the specified items related to browsing for all origins that match |
204 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). | 214 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). |
205 void Remove(int remove_mask, int origin_set_mask); | 215 void Remove(int remove_mask, int origin_set_mask); |
206 | 216 |
207 void AddObserver(Observer* observer); | 217 void AddObserver(Observer* observer); |
208 void RemoveObserver(Observer* observer); | 218 void RemoveObserver(Observer* observer); |
209 | 219 |
210 // Called when history deletion is done. | 220 // Called when history deletion is done. |
211 void OnHistoryDeletionDone(); | 221 void OnHistoryDeletionDone(); |
212 | 222 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 | 475 |
466 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; | 476 scoped_ptr<TemplateURLService::Subscription> template_url_sub_; |
467 | 477 |
468 // We do not own this. | 478 // We do not own this. |
469 content::StoragePartition* storage_partition_for_testing_; | 479 content::StoragePartition* storage_partition_for_testing_; |
470 | 480 |
471 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); | 481 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); |
472 }; | 482 }; |
473 | 483 |
474 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 484 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
OLD | NEW |