OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/cancelable_request.h" | 10 #include "chrome/browser/cancelable_request.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Observer is notified when the removal is done. Done means keywords have | 30 // Observer is notified when the removal is done. Done means keywords have |
31 // been deleted, cache cleared and all other tasks scheduled. | 31 // been deleted, cache cleared and all other tasks scheduled. |
32 class Observer { | 32 class Observer { |
33 public: | 33 public: |
34 virtual void OnBrowsingDataRemoverDone() = 0; | 34 virtual void OnBrowsingDataRemoverDone() = 0; |
35 }; | 35 }; |
36 | 36 |
37 // Creates a BrowsingDataRemover to remove browser data from the specified | 37 // Creates a BrowsingDataRemover to remove browser data from the specified |
38 // profile in the specified time range. Use Remove to initiate the removal. | 38 // profile in the specified time range. Use Remove to initiate the removal. |
39 BrowsingDataRemover(Profile* profile, Time delete_begin, Time delete_end); | 39 BrowsingDataRemover(Profile* profile, base::Time delete_begin, |
| 40 base::Time delete_end); |
40 ~BrowsingDataRemover(); | 41 ~BrowsingDataRemover(); |
41 | 42 |
42 // Removes the specified items related to browsing. | 43 // Removes the specified items related to browsing. |
43 void Remove(int remove_mask); | 44 void Remove(int remove_mask); |
44 | 45 |
45 void AddObserver(Observer* observer); | 46 void AddObserver(Observer* observer); |
46 void RemoveObserver(Observer* observer); | 47 void RemoveObserver(Observer* observer); |
47 | 48 |
48 // Called when history deletion is done. | 49 // Called when history deletion is done. |
49 void OnHistoryDeletionDone(); | 50 void OnHistoryDeletionDone(); |
50 | 51 |
51 private: | 52 private: |
52 // NotificationObserver method. Callback when TemplateURLModel has finished | 53 // NotificationObserver method. Callback when TemplateURLModel has finished |
53 // loading. Deletes the entries from the model, and if we're not waiting on | 54 // loading. Deletes the entries from the model, and if we're not waiting on |
54 // anything else notifies observers and deletes this BrowsingDataRemover. | 55 // anything else notifies observers and deletes this BrowsingDataRemover. |
55 void Observe(NotificationType type, | 56 void Observe(NotificationType type, |
56 const NotificationSource& source, | 57 const NotificationSource& source, |
57 const NotificationDetails& details); | 58 const NotificationDetails& details); |
58 | 59 |
59 // If we're not waiting on anything, notifies observers and deletes this | 60 // If we're not waiting on anything, notifies observers and deletes this |
60 // object. | 61 // object. |
61 void NotifyAndDeleteIfDone(); | 62 void NotifyAndDeleteIfDone(); |
62 | 63 |
63 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. | 64 // Callback when the cache has been deleted. Invokes NotifyAndDeleteIfDone. |
64 void ClearedCache(); | 65 void ClearedCache(); |
65 | 66 |
66 // Invoked on the IO thread to delete from the cache. | 67 // Invoked on the IO thread to delete from the cache. |
67 void ClearCacheOnIOThread(Time delete_begin, | 68 void ClearCacheOnIOThread(base::Time delete_begin, |
68 Time delete_end, | 69 base::Time delete_end, |
69 MessageLoop* ui_loop); | 70 MessageLoop* ui_loop); |
70 | 71 |
71 // Returns true if we're all done. | 72 // Returns true if we're all done. |
72 bool all_done() { | 73 bool all_done() { |
73 return !waiting_for_keywords_ && !waiting_for_clear_cache_ && | 74 return !waiting_for_keywords_ && !waiting_for_clear_cache_ && |
74 !waiting_for_clear_history_; | 75 !waiting_for_clear_history_; |
75 } | 76 } |
76 | 77 |
77 // Profile we're to remove from. | 78 // Profile we're to remove from. |
78 Profile* profile_; | 79 Profile* profile_; |
79 | 80 |
80 // Start time to delete from. | 81 // Start time to delete from. |
81 const Time delete_begin_; | 82 const base::Time delete_begin_; |
82 | 83 |
83 // End time to delete to. | 84 // End time to delete to. |
84 const Time delete_end_; | 85 const base::Time delete_end_; |
85 | 86 |
86 // True if Remove has been invoked. | 87 // True if Remove has been invoked. |
87 bool removing_; | 88 bool removing_; |
88 | 89 |
89 // True if we're waiting for the TemplateURLModel to finish loading. | 90 // True if we're waiting for the TemplateURLModel to finish loading. |
90 bool waiting_for_keywords_; | 91 bool waiting_for_keywords_; |
91 | 92 |
92 // True if we're waiting for the history to be deleted. | 93 // True if we're waiting for the history to be deleted. |
93 bool waiting_for_clear_history_; | 94 bool waiting_for_clear_history_; |
94 | 95 |
95 // True if we're waiting for the cache to be cleared. | 96 // True if we're waiting for the cache to be cleared. |
96 bool waiting_for_clear_cache_; | 97 bool waiting_for_clear_cache_; |
97 | 98 |
98 ObserverList<Observer> observer_list_; | 99 ObserverList<Observer> observer_list_; |
99 | 100 |
100 // Used if we need to clear history. | 101 // Used if we need to clear history. |
101 CancelableRequestConsumer request_consumer_; | 102 CancelableRequestConsumer request_consumer_; |
102 | 103 |
103 DISALLOW_EVIL_CONSTRUCTORS(BrowsingDataRemover); | 104 DISALLOW_EVIL_CONSTRUCTORS(BrowsingDataRemover); |
104 }; | 105 }; |
105 | 106 |
106 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H__ | 107 #endif // CHROME_BROWSER_BROWSING_DATA_REMOVER_H__ |
107 | |
OLD | NEW |