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

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

Issue 7551008: Strawman proposal for chrome.experimental.clear.* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: License presubmit check. :( Created 9 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
« no previous file with comments | « chrome/browser/browsing_data_remover.h ('k') | chrome/browser/extensions/extension_clear_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback.h" 10 #include "base/callback.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 waiting_for_clear_networking_history_(false), 95 waiting_for_clear_networking_history_(false),
96 waiting_for_clear_cache_(false), 96 waiting_for_clear_cache_(false),
97 waiting_for_clear_lso_data_(false) { 97 waiting_for_clear_lso_data_(false) {
98 DCHECK(profile); 98 DCHECK(profile);
99 } 99 }
100 100
101 BrowsingDataRemover::~BrowsingDataRemover() { 101 BrowsingDataRemover::~BrowsingDataRemover() {
102 DCHECK(all_done()); 102 DCHECK(all_done());
103 } 103 }
104 104
105 // Static.
106 void BrowsingDataRemover::set_removing(bool removing) {
107 DCHECK(removing_ != removing);
108 removing_ = removing;
109 }
110
105 void BrowsingDataRemover::Remove(int remove_mask) { 111 void BrowsingDataRemover::Remove(int remove_mask) {
106 DCHECK(!removing_); 112 set_removing(true);
107 removing_ = true;
108 113
109 if (remove_mask & REMOVE_HISTORY) { 114 if (remove_mask & REMOVE_HISTORY) {
110 HistoryService* history_service = 115 HistoryService* history_service =
111 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 116 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
112 if (history_service) { 117 if (history_service) {
113 std::set<GURL> restrict_urls; 118 std::set<GURL> restrict_urls;
114 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History")); 119 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
115 waiting_for_clear_history_ = true; 120 waiting_for_clear_history_ = true;
116 history_service->ExpireHistoryBetween(restrict_urls, 121 history_service->ExpireHistoryBetween(restrict_urls,
117 delete_begin_, delete_end_, 122 delete_begin_, delete_end_,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 if (!all_done()) 345 if (!all_done())
341 return; 346 return;
342 347
343 // The NetLog contains download history, but may also contain form data, 348 // The NetLog contains download history, but may also contain form data,
344 // cookies and passwords. Simplest just to always clear it. Must be cleared 349 // cookies and passwords. Simplest just to always clear it. Must be cleared
345 // after the cache, as cleaning up the disk cache exposes some of the history 350 // after the cache, as cleaning up the disk cache exposes some of the history
346 // in the NetLog. 351 // in the NetLog.
347 if (g_browser_process->net_log()) 352 if (g_browser_process->net_log())
348 g_browser_process->net_log()->ClearAllPassivelyCapturedEvents(); 353 g_browser_process->net_log()->ClearAllPassivelyCapturedEvents();
349 354
350 removing_ = false; 355 set_removing(false);
351 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); 356 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone());
352 357
353 // History requests aren't happy if you delete yourself from the callback. 358 // History requests aren't happy if you delete yourself from the callback.
354 // As such, we do a delete later. 359 // As such, we do a delete later.
355 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 360 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
356 } 361 }
357 362
358 void BrowsingDataRemover::ClearedNetworkHistory() { 363 void BrowsingDataRemover::ClearedNetworkHistory() {
359 waiting_for_clear_networking_history_ = false; 364 waiting_for_clear_networking_history_ = false;
360 365
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 NewRunnableMethod( 530 NewRunnableMethod(
526 this, 531 this,
527 &BrowsingDataRemover::NotifyAndDeleteIfDone)); 532 &BrowsingDataRemover::NotifyAndDeleteIfDone));
528 } 533 }
529 534
530 void BrowsingDataRemover::OnWaitableEventSignaled( 535 void BrowsingDataRemover::OnWaitableEventSignaled(
531 base::WaitableEvent* waitable_event) { 536 base::WaitableEvent* waitable_event) {
532 waiting_for_clear_lso_data_ = false; 537 waiting_for_clear_lso_data_ = false;
533 NotifyAndDeleteIfDone(); 538 NotifyAndDeleteIfDone();
534 } 539 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_remover.h ('k') | chrome/browser/extensions/extension_clear_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698