Chromium Code Reviews| Index: chrome/browser/browser_shutdown.cc |
| diff --git a/chrome/browser/browser_shutdown.cc b/chrome/browser/browser_shutdown.cc |
| index e136ef85130298f0ce961f065cf0e4eccf6e1113..87728fdb2a32fb619ac27f052e2baaeb3d512692 100644 |
| --- a/chrome/browser/browser_shutdown.cc |
| +++ b/chrome/browser/browser_shutdown.cc |
| @@ -26,8 +26,10 @@ |
| #include "chrome/browser/first_run/first_run.h" |
| #include "chrome/browser/jankometer.h" |
| #include "chrome/browser/metrics/metrics_service.h" |
| +#include "chrome/browser/plugin_data_remover.h" |
| #include "chrome/browser/plugin_process_host.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/browser/profile_manager.h" |
| #include "chrome/browser/renderer_host/render_process_host.h" |
| #include "chrome/browser/renderer_host/render_view_host.h" |
| #include "chrome/browser/renderer_host/render_widget_host.h" |
| @@ -115,14 +117,6 @@ void Shutdown() { |
| // shutdown. |
| base::ThreadRestrictions::SetIOAllowed(true); |
| - // Unload plugins. This needs to happen on the IO thread. |
| - BrowserThread::PostTask( |
| - BrowserThread::IO, FROM_HERE, |
| - NewRunnableFunction(&ChromePluginLib::UnloadAllPlugins)); |
| - |
| - // Shutdown all IPC channels to service processes. |
| - ServiceProcessControlManager::instance()->Shutdown(); |
| - |
| // WARNING: During logoff/shutdown (WM_ENDSESSION) we may not have enough |
| // time to get here. If you have something that *must* happen on end session, |
| // consider putting it in BrowserProcessImpl::EndSession. |
| @@ -131,9 +125,29 @@ void Shutdown() { |
| // Notifies we are going away. |
| g_browser_process->shutdown_event()->Signal(); |
| - PrefService* prefs = g_browser_process->local_state(); |
| + PrefService* local_state = g_browser_process->local_state(); |
| + |
| + // Unload plugins. This needs to happen on the IO thread. |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + NewRunnableFunction(&ChromePluginLib::UnloadAllPlugins)); |
| + |
| + Profile* profile = ProfileManager::GetDefaultProfile(); |
| + if (profile) { |
| + // Store the profile path for clearing local state data on exit. |
| + PrefService* prefs = profile->GetPrefs(); |
| + if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) && |
| + local_state->GetBoolean(prefs::kClearPluginLSODataEnabled)) { |
| + PluginDataRemover remover; |
| + remover.StartRemoving(base::Time(), new MessageLoop::QuitTask()); |
|
jam
2010/11/29 17:14:08
I have a big concern about blocking our shutdown t
|
| + MessageLoop::current()->Run(); |
| + } |
| + } |
| + |
| + // Shutdown all IPC channels to service processes. |
| + ServiceProcessControlManager::instance()->Shutdown(); |
| - chrome_browser_net::SavePredictorStateForNextStartupAndTrim(prefs); |
| + chrome_browser_net::SavePredictorStateForNextStartupAndTrim(local_state); |
| MetricsService* metrics = g_browser_process->metrics_service(); |
| if (metrics) { |
| @@ -144,21 +158,22 @@ void Shutdown() { |
| if (shutdown_type_ > NOT_VALID && shutdown_num_processes_ > 0) { |
| // Record the shutdown info so that we can put it into a histogram at next |
| // startup. |
| - prefs->SetInteger(prefs::kShutdownType, shutdown_type_); |
| - prefs->SetInteger(prefs::kShutdownNumProcesses, shutdown_num_processes_); |
| - prefs->SetInteger(prefs::kShutdownNumProcessesSlow, |
| - shutdown_num_processes_slow_); |
| + local_state->SetInteger(prefs::kShutdownType, shutdown_type_); |
| + local_state->SetInteger(prefs::kShutdownNumProcesses, |
| + shutdown_num_processes_); |
| + local_state->SetInteger(prefs::kShutdownNumProcessesSlow, |
| + shutdown_num_processes_slow_); |
| } |
| // Check local state for the restart flag so we can restart the session below. |
| bool restart_last_session = false; |
| - if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { |
| + if (local_state->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { |
| restart_last_session = |
| - prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); |
| - prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); |
| + local_state->GetBoolean(prefs::kRestartLastSessionOnShutdown); |
| + local_state->ClearPref(prefs::kRestartLastSessionOnShutdown); |
| } |
| - prefs->SavePersistentPrefs(); |
| + local_state->SavePersistentPrefs(); |
| #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
| // Cleanup any statics created by RLZ. Must be done before NotificationService |