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

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: Mac 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. Returns a raw pointer, as BrowsingDataRemover
121 BrowsingDataRemover(Profile* profile, base::Time delete_begin, 121 // retains ownership of itself, and deletes itself once finished.
122 base::Time delete_end); 122 static BrowsingDataRemover* CreateForUnboundedRange(Profile* profile);
123 123
124 // Creates a BrowsingDataRemover to remove browser data from the specified 124 // Creates a BrowsingDataRemover object bound on both sides by a time. Returns
125 // profile in the specified time range. 125 // a raw pointer, as BrowsingDataRemover retains ownership of itself, and
126 BrowsingDataRemover(Profile* profile, TimePeriod time_period, 126 // deletes itself once finished.
127 base::Time delete_end); 127 static BrowsingDataRemover* CreateForRange(Profile* profile,
128 base::Time delete_begin,
129 base::Time delete_end);
130
131 // Creates a BrowsingDataRemover bound to a specific period of time (as
132 // defined via a TimePeriod). Returns a raw pointer, as BrowsingDataRemover
133 // retains ownership of itself, and deletes itself once finished.
134 static BrowsingDataRemover* CreateForPeriod(Profile* profile,
135 TimePeriod period);
136
137 // Quota managed data uses a different bitmask for types than
138 // BrowsingDataRemover uses. This method generates that mask.
139 static int GenerateQuotaClientMask(int remove_mask);
140
141 // Is the BrowsingDataRemover currently in the process of removing data?
142 static bool is_removing() { return is_removing_; }
128 143
129 // Removes the specified items related to browsing for all origins that match 144 // Removes the specified items related to browsing for all origins that match
130 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask). 145 // the provided |origin_set_mask| (see BrowsingDataHelper::OriginSetMask).
131 void Remove(int remove_mask, int origin_set_mask); 146 void Remove(int remove_mask, int origin_set_mask);
132 147
133 void AddObserver(Observer* observer); 148 void AddObserver(Observer* observer);
134 void RemoveObserver(Observer* observer); 149 void RemoveObserver(Observer* observer);
135 150
136 // Called when history deletion is done. 151 // Called when history deletion is done.
137 void OnHistoryDeletionDone(); 152 void OnHistoryDeletionDone();
138 153
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. 154 // Used for testing.
144 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager); 155 void OverrideQuotaManagerForTesting(quota::QuotaManager* quota_manager);
145 156
146 static bool is_removing() { return removing_; }
147
148 private: 157 private:
149 // The clear API needs to be able to toggle removing_ in order to test that 158 // 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. 159 // only one BrowsingDataRemover instance can be called at a time.
151 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime); 160 FRIEND_TEST_ALL_PREFIXES(ExtensionBrowsingDataTest, OneAtATime);
152 161
153 // The BrowsingDataRemover tests need to be able to access the implementation 162 // 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 163 // 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 164 // API. As soon as those details are exposed via new methods, this should be
156 // removed. 165 // removed.
157 // 166 //
158 // TODO(mkwst): See http://crbug.com/113621 167 // TODO(mkwst): See http://crbug.com/113621
159 friend class BrowsingDataRemoverTest; 168 friend class BrowsingDataRemoverTest;
160 169
161 enum CacheState { 170 enum CacheState {
162 STATE_NONE, 171 STATE_NONE,
163 STATE_CREATE_MAIN, 172 STATE_CREATE_MAIN,
164 STATE_CREATE_MEDIA, 173 STATE_CREATE_MEDIA,
165 STATE_DELETE_MAIN, 174 STATE_DELETE_MAIN,
166 STATE_DELETE_MEDIA, 175 STATE_DELETE_MEDIA,
167 STATE_DONE 176 STATE_DONE
168 }; 177 };
169 178
179 // Calculate the begin time for the deletion range specified by |time_period|.
180 static base::Time CalculateBeginDeleteTime(TimePeriod time_period);
181
182 // Setter for |is_removing_|; DCHECKs that we can only start removing if we're
183 // not already removing, and vice-versa.
184 static void set_removing(bool is_removing);
185
186 // Creates a BrowsingDataRemover to remove browser data from the specified
187 // profile in the specified time range. Use Remove to initiate the removal.
188 BrowsingDataRemover(Profile* profile,
189 base::Time delete_begin,
190 base::Time delete_end);
191
170 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed 192 // BrowsingDataRemover deletes itself (using DeleteHelper) and is not supposed
171 // to be deleted by other objects so make destructor private and DeleteHelper 193 // to be deleted by other objects so make destructor private and DeleteHelper
172 // a friend. 194 // a friend.
173 friend class base::DeleteHelper<BrowsingDataRemover>; 195 friend class base::DeleteHelper<BrowsingDataRemover>;
174 virtual ~BrowsingDataRemover(); 196 virtual ~BrowsingDataRemover();
175 197
176 // content::NotificationObserver method. Callback when TemplateURLService has 198 // content::NotificationObserver method. Callback when TemplateURLService has
177 // finished loading. Deletes the entries from the model, and if we're not 199 // finished loading. Deletes the entries from the model, and if we're not
178 // waiting on anything else notifies observers and deletes this 200 // waiting on anything else notifies observers and deletes this
179 // BrowsingDataRemover. 201 // BrowsingDataRemover.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // NotifyAndDeleteIfDone. 301 // NotifyAndDeleteIfDone.
280 void OnClearedServerBoundCerts(); 302 void OnClearedServerBoundCerts();
281 303
282 // Callback on the DB thread so that we can wait for the form data to be 304 // Callback on the DB thread so that we can wait for the form data to be
283 // cleared. 305 // cleared.
284 void FormDataDBThreadHop(); 306 void FormDataDBThreadHop();
285 307
286 // Callback from the above method. 308 // Callback from the above method.
287 void OnClearedFormData(); 309 void OnClearedFormData();
288 310
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. 311 // Returns true if we're all done.
293 bool AllDone(); 312 bool AllDone();
294 313
295 // Setter for removing_; DCHECKs that we can only start removing if we're not
296 // already removing, and vice-versa.
297 static void set_removing(bool removing);
298
299 content::NotificationRegistrar registrar_; 314 content::NotificationRegistrar registrar_;
300 315
301 // Profile we're to remove from. 316 // Profile we're to remove from.
302 Profile* profile_; 317 Profile* profile_;
303 318
304 // The QuotaManager is owned by the profile; we can use a raw pointer here, 319 // The QuotaManager is owned by the profile; we can use a raw pointer here,
305 // and rely on the profile to destroy the object whenever it's reasonable. 320 // and rely on the profile to destroy the object whenever it's reasonable.
306 quota::QuotaManager* quota_manager_; 321 quota::QuotaManager* quota_manager_;
307 322
308 // The DOMStorageContext is owned by the profile; we'll store a raw pointer. 323 // The DOMStorageContext is owned by the profile; we'll store a raw pointer.
309 content::DOMStorageContext* dom_storage_context_; 324 content::DOMStorageContext* dom_storage_context_;
310 325
311 // 'Protected' origins are not subject to data removal. 326 // 'Protected' origins are not subject to data removal.
312 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; 327 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_;
313 328
314 // Start time to delete from. 329 // Start time to delete from.
315 const base::Time delete_begin_; 330 const base::Time delete_begin_;
316 331
317 // End time to delete to. 332 // End time to delete to.
318 base::Time delete_end_; 333 base::Time delete_end_;
319 334
320 // True if Remove has been invoked. 335 // True if Remove has been invoked.
321 static bool removing_; 336 static bool is_removing_;
322 337
323 CacheState next_cache_state_; 338 CacheState next_cache_state_;
324 disk_cache::Backend* cache_; 339 disk_cache::Backend* cache_;
325 340
326 // Used to delete data from HTTP cache. 341 // Used to delete data from HTTP cache.
327 scoped_refptr<net::URLRequestContextGetter> main_context_getter_; 342 scoped_refptr<net::URLRequestContextGetter> main_context_getter_;
328 scoped_refptr<net::URLRequestContextGetter> media_context_getter_; 343 scoped_refptr<net::URLRequestContextGetter> media_context_getter_;
329 344
330 // Used to delete plugin data. 345 // Used to delete plugin data.
331 scoped_ptr<content::PluginDataRemover> plugin_data_remover_; 346 scoped_ptr<content::PluginDataRemover> plugin_data_remover_;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 381
367 ObserverList<Observer> observer_list_; 382 ObserverList<Observer> observer_list_;
368 383
369 // Used if we need to clear history. 384 // Used if we need to clear history.
370 CancelableRequestConsumer request_consumer_; 385 CancelableRequestConsumer request_consumer_;
371 386
372 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover); 387 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemover);
373 }; 388 };
374 389
375 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ 390 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider.cc ('k') | chrome/browser/browsing_data/browsing_data_remover.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698