Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover.h

Issue 10898002: Refactor BrowsingDataRemover creation for clarity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Markus' feedback. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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);
cbentzel 2012/08/29 01:53:13 Should these return scoped_ptr<BrowsingDataRemover
Mike West 2012/09/03 08:02:57 BrowsingDataRemover has very strange semantics, in
markusheintz_ 2012/09/03 08:58:44 Maybe you should mention in the comment, that the
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);
jam 2012/08/28 16:13:04 nit: google style is deletion_period
Mike West 2012/09/03 08:02:57 Will do.
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 // Is the BrowsingDataRemover currently in the process of removing data?
138 static bool is_removing() { return removing_; }
jam 2012/08/28 16:13:04 nit: this should be beside the set_removing setter
Mike West 2012/09/03 08:02:57 Will do.
128 139
129 // Removes the specified items related to browsing for all origins that match 140 // Removes the specified items related to browsing for all origins that match
130 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). 141 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask).
131 void Remove(int remove_mask, int origin_set_mask); 142 void Remove(int remove_mask, int origin_set_mask);
132 143
133 void AddObserver(Observer* observer); 144 void AddObserver(Observer* observer);
134 void RemoveObserver(Observer* observer); 145 void RemoveObserver(Observer* observer);
135 146
136 // Called when history deletion is done. 147 // Called when history deletion is done.
137 void OnHistoryDeletionDone(); 148 void OnHistoryDeletionDone();
138 149
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. 150 // Used for testing.
144 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); 151 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager);
145 152
146 static bool is_removing() { return removing_; }
147
148 private: 153 private:
149 // The clear API needs to be able to toggle removing_ in order to test that 154 // 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. 155 // only one BrowsingDataRemover instance can be called at a time.
151 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); 156 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime);
152 157
153 // The BrowsingDataRemover tests need to be able to access the implementation 158 // 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 159 // 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 160 // API. As soon as those details are exposed via new methods, this should be
156 // removed. 161 // removed.
157 // 162 //
158 // TODO(mkwst): See http://crbug.com/113621 163 // TODO(mkwst): See http://crbug.com/113621
159 friend class BrowsingDataRemoverTest; 164 friend class BrowsingDataRemoverTest;
160 165
161 enum CacheState { 166 enum CacheState {
162 STATE_NONE, 167 STATE_NONE,
163 STATE_CREATE_MAIN, 168 STATE_CREATE_MAIN,
164 STATE_CREATE_MEDIA, 169 STATE_CREATE_MEDIA,
165 STATE_DELETE_MAIN, 170 STATE_DELETE_MAIN,
166 STATE_DELETE_MEDIA, 171 STATE_DELETE_MEDIA,
167 STATE_DONE 172 STATE_DONE
168 }; 173 };
169 174
175 // Calculate the begin time for the deletion range specified by |time_period|.
176 static base::Time CalculateBeginDeleteTime(TimePeriod time_period);
177
178 // Creates a BrowsingDataRemover to remove browser data from the specified
179 // profile in the specified time range. Use Remove to initiate the removal.
180 BrowsingDataRemover(Profile* profile, base::Time delete_begin,
181 base::Time delete_end);
182
170 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed 183 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed
171 // to be deleted by other objects so make destructor private and DeleteHelper 184 // to be deleted by other objects so make destructor private and DeleteHelper
172 // a friend. 185 // a friend.
173 friend class base::DeleteHelper<BrowsingDataRemover>; 186 friend class base::DeleteHelper<BrowsingDataRemover>;
174 virtual ~BrowsingDataRemover(); 187 virtual ~BrowsingDataRemover();
175 188
176 // content::NotificationObserver method. Callback when TemplateURLService has 189 // content::NotificationObserver method. Callback when TemplateURLService has
177 // finished loading. Deletes the entries from the model, and if we're not 190 // finished loading. Deletes the entries from the model, and if we're not
178 // waiting on anything else notifies observers and deletes this 191 // waiting on anything else notifies observers and deletes this
179 // BrowsingDataRemover. 192 // BrowsingDataRemover.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // NotifyAndDeleteIfDone. 292 // NotifyAndDeleteIfDone.
280 void OnClearedServerBoundCerts(); 293 void OnClearedServerBoundCerts();
281 294
282 // Callback on the DB thread so that we can wait for the form data to be 295 // Callback on the DB thread so that we can wait for the form data to be
283 // cleared. 296 // cleared.
284 void FormDataDBThreadHop(); 297 void FormDataDBThreadHop();
285 298
286 // Callback from the above method. 299 // Callback from the above method.
287 void OnClearedFormData(); 300 void OnClearedFormData();
288 301
289 // Calculate the begin time for the deletion range specified by |time_period|.
290 base::Time CalculateBeginDeleteTime(TimePeriod time_period);
291
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
301 // Profile we're to remove from. 311 // Profile we're to remove from.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698