| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 waiting_for_clear_networking_history_(false), | 96 waiting_for_clear_networking_history_(false), |
| 97 waiting_for_clear_cache_(false), | 97 waiting_for_clear_cache_(false), |
| 98 waiting_for_clear_lso_data_(false) { | 98 waiting_for_clear_lso_data_(false) { |
| 99 DCHECK(profile); | 99 DCHECK(profile); |
| 100 } | 100 } |
| 101 | 101 |
| 102 BrowsingDataRemover::~BrowsingDataRemover() { | 102 BrowsingDataRemover::~BrowsingDataRemover() { |
| 103 DCHECK(all_done()); | 103 DCHECK(all_done()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Static. |
| 107 void BrowsingDataRemover::set_removing(bool removing) { |
| 108 DCHECK(removing_ != removing); |
| 109 removing_ = removing; |
| 110 } |
| 111 |
| 106 void BrowsingDataRemover::Remove(int remove_mask) { | 112 void BrowsingDataRemover::Remove(int remove_mask) { |
| 107 DCHECK(!removing_); | 113 set_removing(true); |
| 108 removing_ = true; | |
| 109 | 114 |
| 110 if (remove_mask & REMOVE_HISTORY) { | 115 if (remove_mask & REMOVE_HISTORY) { |
| 111 HistoryService* history_service = | 116 HistoryService* history_service = |
| 112 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 117 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
| 113 if (history_service) { | 118 if (history_service) { |
| 114 std::set<GURL> restrict_urls; | 119 std::set<GURL> restrict_urls; |
| 115 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 120 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
| 116 waiting_for_clear_history_ = true; | 121 waiting_for_clear_history_ = true; |
| 117 history_service->ExpireHistoryBetween(restrict_urls, | 122 history_service->ExpireHistoryBetween(restrict_urls, |
| 118 delete_begin_, delete_end_, | 123 delete_begin_, delete_end_, |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 if (!all_done()) | 346 if (!all_done()) |
| 342 return; | 347 return; |
| 343 | 348 |
| 344 // The NetLog contains download history, but may also contain form data, | 349 // The NetLog contains download history, but may also contain form data, |
| 345 // cookies and passwords. Simplest just to always clear it. Must be cleared | 350 // cookies and passwords. Simplest just to always clear it. Must be cleared |
| 346 // after the cache, as cleaning up the disk cache exposes some of the history | 351 // after the cache, as cleaning up the disk cache exposes some of the history |
| 347 // in the NetLog. | 352 // in the NetLog. |
| 348 if (g_browser_process->net_log()) | 353 if (g_browser_process->net_log()) |
| 349 g_browser_process->net_log()->ClearAllPassivelyCapturedEvents(); | 354 g_browser_process->net_log()->ClearAllPassivelyCapturedEvents(); |
| 350 | 355 |
| 351 removing_ = false; | 356 set_removing(false); |
| 352 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); | 357 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); |
| 353 | 358 |
| 354 // History requests aren't happy if you delete yourself from the callback. | 359 // History requests aren't happy if you delete yourself from the callback. |
| 355 // As such, we do a delete later. | 360 // As such, we do a delete later. |
| 356 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 361 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 357 } | 362 } |
| 358 | 363 |
| 359 void BrowsingDataRemover::ClearedNetworkHistory() { | 364 void BrowsingDataRemover::ClearedNetworkHistory() { |
| 360 waiting_for_clear_networking_history_ = false; | 365 waiting_for_clear_networking_history_ = false; |
| 361 | 366 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 NewRunnableMethod( | 537 NewRunnableMethod( |
| 533 this, | 538 this, |
| 534 &BrowsingDataRemover::NotifyAndDeleteIfDone)); | 539 &BrowsingDataRemover::NotifyAndDeleteIfDone)); |
| 535 } | 540 } |
| 536 | 541 |
| 537 void BrowsingDataRemover::OnWaitableEventSignaled( | 542 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 538 base::WaitableEvent* waitable_event) { | 543 base::WaitableEvent* waitable_event) { |
| 539 waiting_for_clear_lso_data_ = false; | 544 waiting_for_clear_lso_data_ = false; |
| 540 NotifyAndDeleteIfDone(); | 545 NotifyAndDeleteIfDone(); |
| 541 } | 546 } |
| OLD | NEW |