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

Unified Diff: chrome/browser/browser_process_impl.cc

Issue 5579002: Add a preference to clear plugin data on browser shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 10 years 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
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/plugin_data_remover_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_process_impl.cc
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 756aa6ca1b5211650ea183eb65225a56162855c3..d60b672dc87bb6f4986b29b279db2d25464c2ec8 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -37,6 +37,7 @@
#include "chrome/browser/net/predictor_api.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
+#include "chrome/browser/plugin_data_remover.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/plugin_updater.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -110,6 +111,10 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
clipboard_.reset(new Clipboard);
main_notification_service_.reset(new NotificationService);
+ notification_registrar_.Add(this,
+ NotificationType::APP_TERMINATING,
+ NotificationService::AllSources());
+
// Must be created after the NotificationService.
print_job_manager_.reset(new printing::PrintJobManager);
@@ -175,6 +180,9 @@ BrowserProcessImpl::~BrowserProcessImpl() {
background_x11_thread_.reset();
#endif
+ // Wait for removing plugin data to finish before shutting down the IO thread.
+ WaitForPluginDataRemoverToFinish();
+
// Need to stop io_thread_ before resource_dispatcher_host_, since
// io_thread_ may still deref ResourceDispatcherHost and handle resource
// request before going away.
@@ -507,6 +515,34 @@ void BrowserProcessImpl::CheckForInspectorFiles() {
NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck));
}
+void BrowserProcessImpl::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::APP_TERMINATING) {
+ Profile* profile = ProfileManager::GetDefaultProfile();
+ if (profile) {
+ PrefService* prefs = profile->GetPrefs();
+ if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) &&
+ local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) {
+ plugin_data_remover_ = new PluginDataRemover();
+ plugin_data_remover_->StartRemoving(base::Time(), NULL);
+ }
+ }
+ } else {
+ NOTREACHED();
+ }
+}
+
+void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() {
+ if (!plugin_data_remover_.get() || !plugin_data_remover_->is_removing())
+ return;
+ plugin_data_remover_->set_done_task(new MessageLoop::QuitTask());
+ base::Time start_time(base::Time::Now());
+ MessageLoop::current()->Run();
+ UMA_HISTOGRAM_TIMES("ClearPluginData.wait_at_shutdown",
+ base::Time::Now() - start_time);
+}
+
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
void BrowserProcessImpl::StartAutoupdateTimer() {
autoupdate_timer_.Start(
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/plugin_data_remover_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698