diff options
author | Kristian Monsen <kristianm@google.com> | 2011-05-31 20:30:28 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-06-14 20:31:41 -0700 |
commit | 72a454cd3513ac24fbdd0e0cb9ad70b86a99b801 (patch) | |
tree | 382278a54ce7a744d62fa510a9a80688cc12434b /chrome/browser/browsing_data_remover.cc | |
parent | c4becdd46e31d261b930e4b5a539cbc1d45c23a6 (diff) | |
download | external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.zip external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.gz external_chromium-72a454cd3513ac24fbdd0e0cb9ad70b86a99b801.tar.bz2 |
Merge Chromium.org at r11.0.672.0: Initial merge by git.
Change-Id: I8b4aaf611a2a405fe3fe10e8a94ea7658645c192
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 64 |
1 files changed, 50 insertions, 14 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 3b138ad..b9cae94 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -9,16 +9,19 @@ #include "base/callback.h" #include "chrome/browser/autofill/personal_data_manager.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_thread.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/history/history.h" #include "chrome/browser/in_process_webkit/webkit_context.h" -#include "chrome/browser/plugin_data_remover.h" -#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/io_thread.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/password_manager/password_store.h" +#include "chrome/browser/plugin_data_remover.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_host/web_cache_manager.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/browser/sessions/session_service.h" @@ -56,12 +59,14 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, this, &BrowsingDataRemover::OnGotAppCacheInfo)), ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( this, &BrowsingDataRemover::OnAppCacheDeleted)), - request_context_getter_(profile->GetRequestContext()), appcaches_to_be_deleted_count_(0), next_cache_state_(STATE_NONE), cache_(NULL), + main_context_getter_(profile->GetRequestContext()), + media_context_getter_(profile->GetRequestContextForMedia()), waiting_for_clear_databases_(false), waiting_for_clear_history_(false), + waiting_for_clear_host_cache_(false), waiting_for_clear_cache_(false), waiting_for_clear_appcache_(false) { DCHECK(profile); @@ -81,12 +86,14 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, this, &BrowsingDataRemover::OnGotAppCacheInfo)), ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( this, &BrowsingDataRemover::OnAppCacheDeleted)), - request_context_getter_(profile->GetRequestContext()), appcaches_to_be_deleted_count_(0), next_cache_state_(STATE_NONE), cache_(NULL), + main_context_getter_(profile->GetRequestContext()), + media_context_getter_(profile->GetRequestContextForMedia()), waiting_for_clear_databases_(false), waiting_for_clear_history_(false), + waiting_for_clear_host_cache_(false), waiting_for_clear_cache_(false), waiting_for_clear_appcache_(false), waiting_for_clear_lso_data_(false) { @@ -134,6 +141,15 @@ void BrowsingDataRemover::Remove(int remove_mask) { NewCallback(this, &BrowsingDataRemover::OnHistoryDeletionDone)); } + // Need to clear the host cache, as it also reveals some history. + waiting_for_clear_host_cache_ = true; + BrowserThread::PostTask( + BrowserThread::IO, FROM_HERE, + NewRunnableMethod( + this, + &BrowsingDataRemover::ClearHostCacheOnIOThread, + g_browser_process->io_thread())); + // As part of history deletion we also delete the auto-generated keywords. TemplateURLModel* keywords_model = profile_->GetTemplateURLModel(); if (keywords_model && !keywords_model->loaded()) { @@ -246,9 +262,6 @@ void BrowsingDataRemover::Remove(int remove_mask) { UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cache"), profile_); - main_context_getter_ = profile_->GetRequestContext(); - media_context_getter_ = profile_->GetRequestContextForMedia(); - BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, NewRunnableMethod(this, &BrowsingDataRemover::ClearCacheOnIOThread)); @@ -260,9 +273,9 @@ void BrowsingDataRemover::Remove(int remove_mask) { waiting_for_clear_lso_data_ = true; if (!plugin_data_remover_.get()) plugin_data_remover_ = new PluginDataRemover(); - plugin_data_remover_->StartRemoving( - delete_begin_, - NewRunnableMethod(this, &BrowsingDataRemover::OnClearedPluginData)); + base::WaitableEvent* event = + plugin_data_remover_->StartRemoving(delete_begin_); + watcher_.StartWatching(event, this); } NotifyAndDeleteIfDone(); @@ -328,6 +341,12 @@ void BrowsingDataRemover::NotifyAndDeleteIfDone() { if (!all_done()) return; + // The NetLog contains download history, but may also contain form data, + // cookies and passwords. Simplest just to always clear it. Must be cleared + // after the cache, as cleaning up the disk cache exposes some of the history + // in the NetLog. + g_browser_process->net_log()->ClearAllPassivelyCapturedEvents(); + removing_ = false; FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone()); @@ -336,6 +355,24 @@ void BrowsingDataRemover::NotifyAndDeleteIfDone() { MessageLoop::current()->DeleteSoon(FROM_HERE, this); } +void BrowsingDataRemover::ClearedNetworkHistory() { + waiting_for_clear_host_cache_ = false; + + NotifyAndDeleteIfDone(); +} + +void BrowsingDataRemover::ClearHostCacheOnIOThread(IOThread* io_thread) { + // This function should be called on the IO thread. + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + + io_thread->ClearHostCache(); + + // Notify the UI thread that we are done. + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + NewRunnableMethod(this, &BrowsingDataRemover::ClearedNetworkHistory)); +} + void BrowsingDataRemover::ClearedCache() { waiting_for_clear_cache_ = false; @@ -392,8 +429,6 @@ void BrowsingDataRemover::DoClearCache(int rv) { break; } case STATE_DONE: { - main_context_getter_ = NULL; - media_context_getter_ = NULL; cache_ = NULL; // Notify the UI thread that we are done. @@ -504,12 +539,13 @@ ChromeAppCacheService* BrowsingDataRemover::GetAppCacheService() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); ChromeURLRequestContext* request_context = reinterpret_cast<ChromeURLRequestContext*>( - request_context_getter_->GetURLRequestContext()); + main_context_getter_->GetURLRequestContext()); return request_context ? request_context->appcache_service() : NULL; } -void BrowsingDataRemover::OnClearedPluginData() { +void BrowsingDataRemover::OnWaitableEventSignaled( + base::WaitableEvent* waitable_event) { waiting_for_clear_lso_data_ = false; NotifyAndDeleteIfDone(); } |