| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_shutdown.h" | 5 #include "chrome/browser/browser_shutdown.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // consider putting it in BrowserProcessImpl::EndSession. | 163 // consider putting it in BrowserProcessImpl::EndSession. |
| 164 PrefService* prefs = g_browser_process->local_state(); | 164 PrefService* prefs = g_browser_process->local_state(); |
| 165 | 165 |
| 166 // Log the amount of times the user switched profiles during this session. | 166 // Log the amount of times the user switched profiles during this session. |
| 167 ProfileMetrics::LogNumberOfProfileSwitches(); | 167 ProfileMetrics::LogNumberOfProfileSwitches(); |
| 168 | 168 |
| 169 metrics::MetricsService* metrics = g_browser_process->metrics_service(); | 169 metrics::MetricsService* metrics = g_browser_process->metrics_service(); |
| 170 if (metrics) | 170 if (metrics) |
| 171 metrics->RecordCompletedSessionEnd(); | 171 metrics->RecordCompletedSessionEnd(); |
| 172 | 172 |
| 173 bool restart_last_session = RecordShutdownInfoPrefs(); |
| 174 |
| 175 prefs->CommitPendingWrite(); |
| 176 |
| 177 #if defined(ENABLE_RLZ) |
| 178 // Cleanup any statics created by RLZ. Must be done before NotificationService |
| 179 // is destroyed. |
| 180 rlz::RLZTracker::CleanupRlz(); |
| 181 #endif |
| 182 |
| 183 return restart_last_session; |
| 184 } |
| 185 |
| 186 bool RecordShutdownInfoPrefs() { |
| 187 PrefService* prefs = g_browser_process->local_state(); |
| 173 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { | 188 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { |
| 174 // Record the shutdown info so that we can put it into a histogram at next | 189 // Record the shutdown info so that we can put it into a histogram at next |
| 175 // startup. | 190 // startup. |
| 176 prefs->SetInteger(prefs::kShutdownType, g_shutdown_type); | 191 prefs->SetInteger(prefs::kShutdownType, g_shutdown_type); |
| 177 prefs->SetInteger(prefs::kShutdownNumProcesses, g_shutdown_num_processes); | 192 prefs->SetInteger(prefs::kShutdownNumProcesses, g_shutdown_num_processes); |
| 178 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, | 193 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, |
| 179 g_shutdown_num_processes_slow); | 194 g_shutdown_num_processes_slow); |
| 180 } | 195 } |
| 181 | 196 |
| 182 // Check local state for the restart flag so we can restart the session below. | 197 // Check local state for the restart flag so we can restart the session later. |
| 183 bool restart_last_session = false; | 198 bool restart_last_session = false; |
| 184 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { | 199 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { |
| 185 restart_last_session = | 200 restart_last_session = |
| 186 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); | 201 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); |
| 187 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); | 202 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); |
| 188 } | 203 } |
| 189 | |
| 190 prefs->CommitPendingWrite(); | |
| 191 | |
| 192 #if defined(ENABLE_RLZ) | |
| 193 // Cleanup any statics created by RLZ. Must be done before NotificationService | |
| 194 // is destroyed. | |
| 195 rlz::RLZTracker::CleanupRlz(); | |
| 196 #endif | |
| 197 | |
| 198 return restart_last_session; | 204 return restart_last_session; |
| 199 } | 205 } |
| 200 | 206 |
| 201 void ShutdownPostThreadsStop(int shutdown_flags) { | 207 void ShutdownPostThreadsStop(int shutdown_flags) { |
| 202 delete g_browser_process; | 208 delete g_browser_process; |
| 203 g_browser_process = NULL; | 209 g_browser_process = NULL; |
| 204 | 210 |
| 205 // crbug.com/95079 - This needs to happen after the browser process object | 211 // crbug.com/95079 - This needs to happen after the browser process object |
| 206 // goes away. | 212 // goes away. |
| 207 ProfileManager::NukeDeletedProfilesFromDisk(); | 213 ProfileManager::NukeDeletedProfilesFromDisk(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 PrefService* prefs = g_browser_process->local_state(); | 326 PrefService* prefs = g_browser_process->local_state(); |
| 321 ShutdownType type = | 327 ShutdownType type = |
| 322 static_cast<ShutdownType>(prefs->GetInteger(prefs::kShutdownType)); | 328 static_cast<ShutdownType>(prefs->GetInteger(prefs::kShutdownType)); |
| 323 int num_procs = prefs->GetInteger(prefs::kShutdownNumProcesses); | 329 int num_procs = prefs->GetInteger(prefs::kShutdownNumProcesses); |
| 324 int num_procs_slow = prefs->GetInteger(prefs::kShutdownNumProcessesSlow); | 330 int num_procs_slow = prefs->GetInteger(prefs::kShutdownNumProcessesSlow); |
| 325 // clear the prefs immediately so we don't pick them up on a future run | 331 // clear the prefs immediately so we don't pick them up on a future run |
| 326 prefs->SetInteger(prefs::kShutdownType, NOT_VALID); | 332 prefs->SetInteger(prefs::kShutdownType, NOT_VALID); |
| 327 prefs->SetInteger(prefs::kShutdownNumProcesses, 0); | 333 prefs->SetInteger(prefs::kShutdownNumProcesses, 0); |
| 328 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 0); | 334 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 0); |
| 329 | 335 |
| 336 UMA_HISTOGRAM_ENUMERATION("Shutdown.ShutdownType", type, kNumShutdownTypes); |
| 337 |
| 330 // Read and delete the file on the file thread. | 338 // Read and delete the file on the file thread. |
| 331 BrowserThread::PostTask( | 339 BrowserThread::PostTask( |
| 332 BrowserThread::FILE, FROM_HERE, | 340 BrowserThread::FILE, FROM_HERE, |
| 333 base::Bind(&ReadLastShutdownFile, type, num_procs, num_procs_slow)); | 341 base::Bind(&ReadLastShutdownFile, type, num_procs, num_procs_slow)); |
| 334 } | 342 } |
| 335 | 343 |
| 336 void SetTryingToQuit(bool quitting) { | 344 void SetTryingToQuit(bool quitting) { |
| 337 g_trying_to_quit = quitting; | 345 g_trying_to_quit = quitting; |
| 338 | 346 |
| 339 if (quitting) | 347 if (quitting) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 366 base::trace_event::TraceConfig trace_config( | 374 base::trace_event::TraceConfig trace_config( |
| 367 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); | 375 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); |
| 368 content::TracingController::GetInstance()->StartTracing( | 376 content::TracingController::GetInstance()->StartTracing( |
| 369 trace_config, | 377 trace_config, |
| 370 content::TracingController::StartTracingDoneCallback()); | 378 content::TracingController::StartTracingDoneCallback()); |
| 371 } | 379 } |
| 372 TRACE_EVENT0("shutdown", "StartShutdownTracing"); | 380 TRACE_EVENT0("shutdown", "StartShutdownTracing"); |
| 373 } | 381 } |
| 374 | 382 |
| 375 } // namespace browser_shutdown | 383 } // namespace browser_shutdown |
| OLD | NEW |