| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 this, &BrowsingDataRemover::DoClearCache)), | 97 this, &BrowsingDataRemover::DoClearCache)), |
| 98 next_cache_state_(STATE_NONE), | 98 next_cache_state_(STATE_NONE), |
| 99 cache_(NULL), | 99 cache_(NULL), |
| 100 main_context_getter_(profile->GetRequestContext()), | 100 main_context_getter_(profile->GetRequestContext()), |
| 101 media_context_getter_(profile->GetRequestContextForMedia()), | 101 media_context_getter_(profile->GetRequestContextForMedia()), |
| 102 waiting_for_clear_history_(false), | 102 waiting_for_clear_history_(false), |
| 103 waiting_for_clear_quota_managed_data_(false), | 103 waiting_for_clear_quota_managed_data_(false), |
| 104 waiting_for_clear_networking_history_(false), | 104 waiting_for_clear_networking_history_(false), |
| 105 waiting_for_clear_cookies_(false), | 105 waiting_for_clear_cookies_(false), |
| 106 waiting_for_clear_cache_(false), | 106 waiting_for_clear_cache_(false), |
| 107 waiting_for_clear_lso_data_(false), | 107 waiting_for_clear_plugin_data_(false), |
| 108 remove_mask_(0) { | 108 remove_mask_(0) { |
| 109 DCHECK(profile); | 109 DCHECK(profile); |
| 110 } | 110 } |
| 111 | 111 |
| 112 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 112 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
| 113 TimePeriod time_period, | 113 TimePeriod time_period, |
| 114 base::Time delete_end) | 114 base::Time delete_end) |
| 115 : profile_(profile), | 115 : profile_(profile), |
| 116 quota_manager_(NULL), | 116 quota_manager_(NULL), |
| 117 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 117 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
| 118 delete_begin_(CalculateBeginDeleteTime(time_period)), | 118 delete_begin_(CalculateBeginDeleteTime(time_period)), |
| 119 delete_end_(delete_end), | 119 delete_end_(delete_end), |
| 120 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 120 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
| 121 this, &BrowsingDataRemover::DoClearCache)), | 121 this, &BrowsingDataRemover::DoClearCache)), |
| 122 next_cache_state_(STATE_NONE), | 122 next_cache_state_(STATE_NONE), |
| 123 cache_(NULL), | 123 cache_(NULL), |
| 124 main_context_getter_(profile->GetRequestContext()), | 124 main_context_getter_(profile->GetRequestContext()), |
| 125 media_context_getter_(profile->GetRequestContextForMedia()), | 125 media_context_getter_(profile->GetRequestContextForMedia()), |
| 126 waiting_for_clear_history_(false), | 126 waiting_for_clear_history_(false), |
| 127 waiting_for_clear_quota_managed_data_(false), | 127 waiting_for_clear_quota_managed_data_(false), |
| 128 waiting_for_clear_networking_history_(false), | 128 waiting_for_clear_networking_history_(false), |
| 129 waiting_for_clear_cookies_(false), | 129 waiting_for_clear_cookies_(false), |
| 130 waiting_for_clear_cache_(false), | 130 waiting_for_clear_cache_(false), |
| 131 waiting_for_clear_lso_data_(false), | 131 waiting_for_clear_plugin_data_(false), |
| 132 remove_mask_(0) { | 132 remove_mask_(0) { |
| 133 DCHECK(profile); | 133 DCHECK(profile); |
| 134 } | 134 } |
| 135 | 135 |
| 136 BrowsingDataRemover::~BrowsingDataRemover() { | 136 BrowsingDataRemover::~BrowsingDataRemover() { |
| 137 DCHECK(all_done()); | 137 DCHECK(all_done()); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Static. | 140 // Static. |
| 141 void BrowsingDataRemover::set_removing(bool removing) { | 141 void BrowsingDataRemover::set_removing(bool removing) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 quota_manager_ = profile_->GetQuotaManager(); | 248 quota_manager_ = profile_->GetQuotaManager(); |
| 249 if (quota_manager_) { | 249 if (quota_manager_) { |
| 250 waiting_for_clear_quota_managed_data_ = true; | 250 waiting_for_clear_quota_managed_data_ = true; |
| 251 BrowserThread::PostTask( | 251 BrowserThread::PostTask( |
| 252 BrowserThread::IO, FROM_HERE, | 252 BrowserThread::IO, FROM_HERE, |
| 253 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread, | 253 base::Bind(&BrowsingDataRemover::ClearQuotaManagedDataOnIOThread, |
| 254 base::Unretained(this))); | 254 base::Unretained(this))); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 if (remove_mask & REMOVE_LSO_DATA) { | 258 if (remove_mask & REMOVE_PLUGIN_DATA) { |
| 259 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); | 259 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
| 260 | 260 |
| 261 waiting_for_clear_lso_data_ = true; | 261 waiting_for_clear_plugin_data_ = true; |
| 262 if (!plugin_data_remover_.get()) { | 262 if (!plugin_data_remover_.get()) { |
| 263 plugin_data_remover_.reset( | 263 plugin_data_remover_.reset( |
| 264 content::PluginDataRemover::Create(profile_->GetResourceContext())); | 264 content::PluginDataRemover::Create(profile_->GetResourceContext())); |
| 265 } | 265 } |
| 266 base::WaitableEvent* event = | 266 base::WaitableEvent* event = |
| 267 plugin_data_remover_->StartRemoving(delete_begin_); | 267 plugin_data_remover_->StartRemoving(delete_begin_); |
| 268 watcher_.StartWatching(event, this); | 268 watcher_.StartWatching(event, this); |
| 269 } | 269 } |
| 270 | 270 |
| 271 if (remove_mask & REMOVE_PASSWORDS) { | 271 if (remove_mask & REMOVE_PASSWORDS) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 } | 586 } |
| 587 | 587 |
| 588 void BrowsingDataRemover::OnQuotaManagedDataDeleted() { | 588 void BrowsingDataRemover::OnQuotaManagedDataDeleted() { |
| 589 DCHECK(waiting_for_clear_quota_managed_data_); | 589 DCHECK(waiting_for_clear_quota_managed_data_); |
| 590 waiting_for_clear_quota_managed_data_ = false; | 590 waiting_for_clear_quota_managed_data_ = false; |
| 591 NotifyAndDeleteIfDone(); | 591 NotifyAndDeleteIfDone(); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void BrowsingDataRemover::OnWaitableEventSignaled( | 594 void BrowsingDataRemover::OnWaitableEventSignaled( |
| 595 base::WaitableEvent* waitable_event) { | 595 base::WaitableEvent* waitable_event) { |
| 596 waiting_for_clear_lso_data_ = false; | 596 waiting_for_clear_plugin_data_ = false; |
| 597 NotifyAndDeleteIfDone(); | 597 NotifyAndDeleteIfDone(); |
| 598 } | 598 } |
| 599 | 599 |
| 600 void BrowsingDataRemover::OnClearedCookies(int num_deleted) { | 600 void BrowsingDataRemover::OnClearedCookies(int num_deleted) { |
| 601 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 601 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 602 BrowserThread::PostTask( | 602 BrowserThread::PostTask( |
| 603 BrowserThread::UI, FROM_HERE, | 603 BrowserThread::UI, FROM_HERE, |
| 604 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 604 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 605 base::Unretained(this), num_deleted)); | 605 base::Unretained(this), num_deleted)); |
| 606 return; | 606 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 617 GetURLRequestContext()->cookie_store()->GetCookieMonster(); | 617 GetURLRequestContext()->cookie_store()->GetCookieMonster(); |
| 618 if (cookie_monster) { | 618 if (cookie_monster) { |
| 619 cookie_monster->DeleteAllCreatedBetweenAsync( | 619 cookie_monster->DeleteAllCreatedBetweenAsync( |
| 620 delete_begin_, delete_end_, | 620 delete_begin_, delete_end_, |
| 621 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 621 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
| 622 base::Unretained(this))); | 622 base::Unretained(this))); |
| 623 } else { | 623 } else { |
| 624 OnClearedCookies(0); | 624 OnClearedCookies(0); |
| 625 } | 625 } |
| 626 } | 626 } |
| OLD | NEW |