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

Side by Side Diff: chrome/browser/browsing_data_remover.cc

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move to content namespace. Update usages. Update extract_actions tool. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data_remover.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/sessions/session_service.h" 36 #include "chrome/browser/sessions/session_service.h"
37 #include "chrome/browser/sessions/session_service_factory.h" 37 #include "chrome/browser/sessions/session_service_factory.h"
38 #include "chrome/browser/sessions/tab_restore_service.h" 38 #include "chrome/browser/sessions/tab_restore_service.h"
39 #include "chrome/browser/sessions/tab_restore_service_factory.h" 39 #include "chrome/browser/sessions/tab_restore_service_factory.h"
40 #include "chrome/browser/webdata/web_data_service.h" 40 #include "chrome/browser/webdata/web_data_service.h"
41 #include "chrome/common/chrome_notification_types.h" 41 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
43 #include "chrome/common/url_constants.h" 43 #include "chrome/common/url_constants.h"
44 #include "content/browser/download/download_manager.h" 44 #include "content/browser/download/download_manager.h"
45 #include "content/browser/in_process_webkit/webkit_context.h" 45 #include "content/browser/in_process_webkit/webkit_context.h"
46 #include "content/browser/user_metrics.h"
47 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
48 #include "content/public/browser/notification_source.h" 47 #include "content/public/browser/notification_source.h"
49 #include "content/public/browser/plugin_data_remover.h" 48 #include "content/public/browser/plugin_data_remover.h"
49 #include "content/public/browser/user_metrics.h"
50 #include "net/base/cookie_monster.h" 50 #include "net/base/cookie_monster.h"
51 #include "net/base/net_errors.h" 51 #include "net/base/net_errors.h"
52 #include "net/base/transport_security_state.h" 52 #include "net/base/transport_security_state.h"
53 #include "net/disk_cache/disk_cache.h" 53 #include "net/disk_cache/disk_cache.h"
54 #include "net/http/http_cache.h" 54 #include "net/http/http_cache.h"
55 #include "net/url_request/url_request_context.h" 55 #include "net/url_request/url_request_context.h"
56 #include "net/url_request/url_request_context_getter.h" 56 #include "net/url_request/url_request_context_getter.h"
57 #include "webkit/quota/quota_manager.h" 57 #include "webkit/quota/quota_manager.h"
58 #include "webkit/quota/quota_types.h" 58 #include "webkit/quota/quota_types.h"
59 59
60 using content::BrowserThread; 60 using content::BrowserThread;
61 using content::UserMetricsAction;
61 62
62 // Done so that we can use PostTask on BrowsingDataRemovers and not have 63 // Done so that we can use PostTask on BrowsingDataRemovers and not have
63 // BrowsingDataRemover implement RefCounted. 64 // BrowsingDataRemover implement RefCounted.
64 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover); 65 DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover);
65 66
66 bool BrowsingDataRemover::removing_ = false; 67 bool BrowsingDataRemover::removing_ = false;
67 68
68 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, 69 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
69 base::Time delete_begin, 70 base::Time delete_begin,
70 base::Time delete_end) 71 base::Time delete_end)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 void BrowsingDataRemover::Remove(int remove_mask) { 125 void BrowsingDataRemover::Remove(int remove_mask) {
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
126 set_removing(true); 127 set_removing(true);
127 128
128 if (remove_mask & REMOVE_HISTORY) { 129 if (remove_mask & REMOVE_HISTORY) {
129 HistoryService* history_service = 130 HistoryService* history_service =
130 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 131 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
131 if (history_service) { 132 if (history_service) {
132 std::set<GURL> restrict_urls; 133 std::set<GURL> restrict_urls;
133 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 134 content::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
134 waiting_for_clear_history_ = true; 135 waiting_for_clear_history_ = true;
135 history_service->ExpireHistoryBetween(restrict_urls, 136 history_service->ExpireHistoryBetween(restrict_urls,
136 delete_begin_, delete_end_, 137 delete_begin_, delete_end_,
137 &request_consumer_, 138 &request_consumer_,
138 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, 139 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
139 base::Unretained(this))); 140 base::Unretained(this)));
140 } 141 }
141 142
142 // Need to clear the host cache and accumulated speculative data, as it also 143 // Need to clear the host cache and accumulated speculative data, as it also
143 // reveals some history. 144 // reveals some history.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 prerender::PrerenderManager* prerender_manager = 182 prerender::PrerenderManager* prerender_manager =
182 prerender::PrerenderManagerFactory::GetForProfile(profile_); 183 prerender::PrerenderManagerFactory::GetForProfile(profile_);
183 if (prerender_manager) { 184 if (prerender_manager) {
184 prerender_manager->ClearData( 185 prerender_manager->ClearData(
185 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | 186 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS |
186 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); 187 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY);
187 } 188 }
188 } 189 }
189 190
190 if (remove_mask & REMOVE_DOWNLOADS) { 191 if (remove_mask & REMOVE_DOWNLOADS) {
191 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); 192 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
192 DownloadManager* download_manager = 193 DownloadManager* download_manager =
193 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager(); 194 DownloadServiceFactory::GetForProfile(profile_)->GetDownloadManager();
194 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_); 195 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_);
195 download_manager->ClearLastDownloadPath(); 196 download_manager->ClearLastDownloadPath();
196 } 197 }
197 198
198 if (remove_mask & REMOVE_COOKIES) { 199 if (remove_mask & REMOVE_COOKIES) {
199 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); 200 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
200 // Since we are running on the UI thread don't call GetURLRequestContext(). 201 // Since we are running on the UI thread don't call GetURLRequestContext().
201 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); 202 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext();
202 if (rq_context) { 203 if (rq_context) {
203 waiting_for_clear_cookies_ = true; 204 waiting_for_clear_cookies_ = true;
204 BrowserThread::PostTask( 205 BrowserThread::PostTask(
205 BrowserThread::IO, FROM_HERE, 206 BrowserThread::IO, FROM_HERE,
206 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread, 207 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread,
207 base::Unretained(this), base::Unretained(rq_context))); 208 base::Unretained(this), base::Unretained(rq_context)));
208 } 209 }
209 } 210 }
(...skipping 16 matching lines...) Expand all
226 if (quota_manager_) { 227 if (quota_manager_) {
227 waiting_for_clear_quota_managed_data_ = true; 228 waiting_for_clear_quota_managed_data_ = true;
228 BrowserThread::PostTask( 229 BrowserThread::PostTask(
229 BrowserThread::IO, FROM_HERE, 230 BrowserThread::IO, FROM_HERE,
230 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread, 231 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread,
231 base::Unretained(this))); 232 base::Unretained(this)));
232 } 233 }
233 } 234 }
234 235
235 if (remove_mask & REMOVE_LSO_DATA) { 236 if (remove_mask & REMOVE_LSO_DATA) {
236 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); 237 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData"));
237 238
238 waiting_for_clear_lso_data_ = true; 239 waiting_for_clear_lso_data_ = true;
239 if (!plugin_data_remover_.get()) { 240 if (!plugin_data_remover_.get()) {
240 plugin_data_remover_.reset( 241 plugin_data_remover_.reset(
241 content::PluginDataRemover::Create(profile_->GetResourceContext())); 242 content::PluginDataRemover::Create(profile_->GetResourceContext()));
242 } 243 }
243 base::WaitableEvent* event = 244 base::WaitableEvent* event =
244 plugin_data_remover_->StartRemoving(delete_begin_); 245 plugin_data_remover_->StartRemoving(delete_begin_);
245 watcher_.StartWatching(event, this); 246 watcher_.StartWatching(event, this);
246 } 247 }
247 248
248 if (remove_mask & REMOVE_PASSWORDS) { 249 if (remove_mask & REMOVE_PASSWORDS) {
249 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); 250 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
250 PasswordStore* password_store = 251 PasswordStore* password_store =
251 profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS); 252 profile_->GetPasswordStore(Profile::EXPLICIT_ACCESS);
252 253
253 if (password_store) 254 if (password_store)
254 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_); 255 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_);
255 } 256 }
256 257
257 if (remove_mask & REMOVE_FORM_DATA) { 258 if (remove_mask & REMOVE_FORM_DATA) {
258 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); 259 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
259 WebDataService* web_data_service = 260 WebDataService* web_data_service =
260 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); 261 profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
261 262
262 if (web_data_service) { 263 if (web_data_service) {
263 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, 264 web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
264 delete_end_); 265 delete_end_);
265 web_data_service->RemoveAutofillProfilesAndCreditCardsModifiedBetween( 266 web_data_service->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
266 delete_begin_, delete_end_); 267 delete_begin_, delete_end_);
267 PersonalDataManager* data_manager = 268 PersonalDataManager* data_manager =
268 PersonalDataManagerFactory::GetForProfile(profile_); 269 PersonalDataManagerFactory::GetForProfile(profile_);
269 if (data_manager) { 270 if (data_manager) {
270 data_manager->Refresh(); 271 data_manager->Refresh();
271 } 272 }
272 } 273 }
273 } 274 }
274 275
275 if (remove_mask & REMOVE_CACHE) { 276 if (remove_mask & REMOVE_CACHE) {
276 // Tell the renderers to clear their cache. 277 // Tell the renderers to clear their cache.
277 WebCacheManager::GetInstance()->ClearCache(); 278 WebCacheManager::GetInstance()->ClearCache();
278 279
279 // Invoke DoClearCache on the IO thread. 280 // Invoke DoClearCache on the IO thread.
280 waiting_for_clear_cache_ = true; 281 waiting_for_clear_cache_ = true;
281 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); 282 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache"));
282 283
283 BrowserThread::PostTask( 284 BrowserThread::PostTask(
284 BrowserThread::IO, FROM_HERE, 285 BrowserThread::IO, FROM_HERE,
285 base::Bind(&BrowsingDataRemover::ClearCacheOnIOThread, 286 base::Bind(&BrowsingDataRemover::ClearCacheOnIOThread,
286 base::Unretained(this))); 287 base::Unretained(this)));
287 288
288 // The PrerenderManager may have a page actively being prerendered, which 289 // The PrerenderManager may have a page actively being prerendered, which
289 // is essentially a preemptively cached page. 290 // is essentially a preemptively cached page.
290 prerender::PrerenderManager* prerender_manager = 291 prerender::PrerenderManager* prerender_manager =
291 prerender::PrerenderManagerFactory::GetForProfile(profile_); 292 prerender::PrerenderManagerFactory::GetForProfile(profile_);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 GetURLRequestContext()->cookie_store()->GetCookieMonster(); 587 GetURLRequestContext()->cookie_store()->GetCookieMonster();
587 if (cookie_monster) { 588 if (cookie_monster) {
588 cookie_monster->DeleteAllCreatedBetweenAsync( 589 cookie_monster->DeleteAllCreatedBetweenAsync(
589 delete_begin_, delete_end_, 590 delete_begin_, delete_end_,
590 base::Bind(&BrowsingDataRemover::OnClearedCookies, 591 base::Bind(&BrowsingDataRemover::OnClearedCookies,
591 base::Unretained(this))); 592 base::Unretained(this)));
592 } else { 593 } else {
593 OnClearedCookies(0); 594 OnClearedCookies(0);
594 } 595 }
595 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698