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

Unified Diff: chrome/browser/browsing_data/browsing_data_remover.cc

Issue 11238034: Added completion notification to Profile's ClearNetworkingHistorySince. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final touches. Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_remover.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index f723a3f0176f5f7727077d8e6ce0bfced886e8ef..c8f80887937c724d8264979ab86714f037fd30f1 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -147,6 +147,8 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
waiting_for_clear_quota_managed_data_(false),
waiting_for_clear_content_licenses_(false),
waiting_for_clear_form_(false),
+ waiting_for_clear_hostname_resolution_cache_(false),
+ waiting_for_clear_network_predictor_(false),
remove_mask_(0),
remove_origin_(GURL()),
origin_set_mask_(0) {
@@ -248,11 +250,20 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
// reveals some history: we have no mechanism to track when these items were
// created, so we'll clear them all. Better safe than sorry.
if (g_browser_process->io_thread()) {
- waiting_for_clear_networking_history_ = true;
+ waiting_for_clear_hostname_resolution_cache_ = true;
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
- base::Bind(&BrowsingDataRemover::ClearNetworkingHistory,
- base::Unretained(this), g_browser_process->io_thread()));
+ base::Bind(
+ &BrowsingDataRemover::ClearHostnameResolutionCacheOnIOThread,
+ base::Unretained(this),
+ g_browser_process->io_thread()));
+ }
+ if (profile_->GetNetworkPredictor()) {
+ waiting_for_clear_network_predictor_ = true;
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread,
+ base::Unretained(this)));
}
// As part of history deletion we also delete the auto-generated keywords.
@@ -490,11 +501,13 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
pepper_flash_settings_manager_->DeauthorizeContentLicenses();
}
- // Also delete cached network related data (like TransportSecurityState,
- // HttpServerProperties data).
- profile_->ClearNetworkingHistorySince(delete_begin_);
-
- NotifyAndDeleteIfDone();
+ // Always wipe accumulated network related data (TransportSecurityState and
+ // HttpServerPropertiesManager data).
+ waiting_for_clear_networking_history_ = true;
+ profile_->ClearNetworkingHistorySince(
+ delete_begin_,
+ base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory,
+ base::Unretained(this)));
}
void BrowsingDataRemover::AddObserver(Observer* observer) {
@@ -555,7 +568,9 @@ bool BrowsingDataRemover::AllDone() {
!waiting_for_clear_plugin_data_ &&
!waiting_for_clear_quota_managed_data_ &&
!waiting_for_clear_content_licenses_ &&
- !waiting_for_clear_form_;
+ !waiting_for_clear_form_ &&
+ !waiting_for_clear_hostname_resolution_cache_ &&
+ !waiting_for_clear_network_predictor_;
Mike West 2012/10/30 10:33:22 Nit: Since you're already touching this, can you s
engedy 2012/10/30 11:01:14 Done.
}
void BrowsingDataRemover::Observe(int type,
@@ -595,18 +610,35 @@ void BrowsingDataRemover::NotifyAndDeleteIfDone() {
MessageLoop::current()->DeleteSoon(FROM_HERE, this);
}
-void BrowsingDataRemover::ClearedNetworkHistory() {
- waiting_for_clear_networking_history_ = false;
-
+void BrowsingDataRemover::OnClearedHostnameResolutionCache() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ waiting_for_clear_hostname_resolution_cache_ = false;
NotifyAndDeleteIfDone();
}
-void BrowsingDataRemover::ClearNetworkingHistory(IOThread* io_thread) {
- // This function should be called on the IO thread.
+void BrowsingDataRemover::ClearHostnameResolutionCacheOnIOThread(
+ IOThread* io_thread) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
io_thread->ClearHostCache();
+ // Notify the UI thread that we are done.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache,
+ base::Unretained(this)));
+}
+
+void BrowsingDataRemover::OnClearedNetworkPredictor() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ waiting_for_clear_network_predictor_ = false;
+ NotifyAndDeleteIfDone();
+}
+
+void BrowsingDataRemover::ClearNetworkPredictorOnIOThread() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
chrome_browser_net::Predictor* predictor = profile_->GetNetworkPredictor();
if (predictor) {
predictor->DiscardInitialNavigationHistory();
@@ -615,11 +647,18 @@ void BrowsingDataRemover::ClearNetworkingHistory(IOThread* io_thread) {
// Notify the UI thread that we are done.
BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&BrowsingDataRemover::ClearedNetworkHistory,
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor,
base::Unretained(this)));
}
+void BrowsingDataRemover::OnClearedNetworkingHistory() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ waiting_for_clear_networking_history_ = false;
+ NotifyAndDeleteIfDone();
+}
+
void BrowsingDataRemover::ClearedCache() {
waiting_for_clear_cache_ = false;

Powered by Google App Engine
This is Rietveld 408576698