Chromium Code Reviews| 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 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { | 173 RecordShutdownInfoPrefs(); |
| 174 // Record the shutdown info so that we can put it into a histogram at next | |
| 175 // startup. | |
| 176 prefs->SetInteger(prefs::kShutdownType, g_shutdown_type); | |
| 177 prefs->SetInteger(prefs::kShutdownNumProcesses, g_shutdown_num_processes); | |
| 178 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, | |
| 179 g_shutdown_num_processes_slow); | |
| 180 } | |
| 181 | 174 |
| 182 // Check local state for the restart flag so we can restart the session below. | 175 // Check local state for the restart flag so we can restart the session below. |
| 183 bool restart_last_session = false; | 176 bool restart_last_session = false; |
| 184 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { | 177 if (prefs->HasPrefPath(prefs::kRestartLastSessionOnShutdown)) { |
|
sky
2016/09/12 16:58:20
Don't we want to clear this one too?
hashimoto
2016/09/13 01:19:49
I think kRestartLastSessionOnShutdown is different
sky
2016/09/13 02:17:59
My understanding is that if kRestartLastSessionOnS
hashimoto
2016/09/13 03:58:38
OK, done.
Moved kRestartLastSessionOnShutdown rela
| |
| 185 restart_last_session = | 178 restart_last_session = |
| 186 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); | 179 prefs->GetBoolean(prefs::kRestartLastSessionOnShutdown); |
| 187 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); | 180 prefs->ClearPref(prefs::kRestartLastSessionOnShutdown); |
| 188 } | 181 } |
| 189 | 182 |
| 190 prefs->CommitPendingWrite(); | 183 prefs->CommitPendingWrite(); |
| 191 | 184 |
| 192 #if defined(ENABLE_RLZ) | 185 #if defined(ENABLE_RLZ) |
| 193 // Cleanup any statics created by RLZ. Must be done before NotificationService | 186 // Cleanup any statics created by RLZ. Must be done before NotificationService |
| 194 // is destroyed. | 187 // is destroyed. |
| 195 rlz::RLZTracker::CleanupRlz(); | 188 rlz::RLZTracker::CleanupRlz(); |
| 196 #endif | 189 #endif |
| 197 | 190 |
| 198 return restart_last_session; | 191 return restart_last_session; |
| 199 } | 192 } |
| 200 | 193 |
| 194 void RecordShutdownInfoPrefs() { | |
| 195 if (g_shutdown_type > NOT_VALID && g_shutdown_num_processes > 0) { | |
| 196 PrefService* prefs = g_browser_process->local_state(); | |
| 197 // Record the shutdown info so that we can put it into a histogram at next | |
| 198 // startup. | |
| 199 prefs->SetInteger(prefs::kShutdownType, g_shutdown_type); | |
| 200 prefs->SetInteger(prefs::kShutdownNumProcesses, g_shutdown_num_processes); | |
| 201 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, | |
| 202 g_shutdown_num_processes_slow); | |
| 203 } | |
| 204 } | |
| 205 | |
| 201 void ShutdownPostThreadsStop(int shutdown_flags) { | 206 void ShutdownPostThreadsStop(int shutdown_flags) { |
| 202 delete g_browser_process; | 207 delete g_browser_process; |
| 203 g_browser_process = NULL; | 208 g_browser_process = NULL; |
| 204 | 209 |
| 205 // crbug.com/95079 - This needs to happen after the browser process object | 210 // crbug.com/95079 - This needs to happen after the browser process object |
| 206 // goes away. | 211 // goes away. |
| 207 ProfileManager::NukeDeletedProfilesFromDisk(); | 212 ProfileManager::NukeDeletedProfilesFromDisk(); |
| 208 | 213 |
| 209 #if defined(OS_CHROMEOS) | 214 #if defined(OS_CHROMEOS) |
| 210 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("BrowserDeleted", | 215 chromeos::BootTimesRecorder::Get()->AddLogoutTimeMarker("BrowserDeleted", |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 PrefService* prefs = g_browser_process->local_state(); | 325 PrefService* prefs = g_browser_process->local_state(); |
| 321 ShutdownType type = | 326 ShutdownType type = |
| 322 static_cast<ShutdownType>(prefs->GetInteger(prefs::kShutdownType)); | 327 static_cast<ShutdownType>(prefs->GetInteger(prefs::kShutdownType)); |
| 323 int num_procs = prefs->GetInteger(prefs::kShutdownNumProcesses); | 328 int num_procs = prefs->GetInteger(prefs::kShutdownNumProcesses); |
| 324 int num_procs_slow = prefs->GetInteger(prefs::kShutdownNumProcessesSlow); | 329 int num_procs_slow = prefs->GetInteger(prefs::kShutdownNumProcessesSlow); |
| 325 // clear the prefs immediately so we don't pick them up on a future run | 330 // clear the prefs immediately so we don't pick them up on a future run |
| 326 prefs->SetInteger(prefs::kShutdownType, NOT_VALID); | 331 prefs->SetInteger(prefs::kShutdownType, NOT_VALID); |
| 327 prefs->SetInteger(prefs::kShutdownNumProcesses, 0); | 332 prefs->SetInteger(prefs::kShutdownNumProcesses, 0); |
| 328 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 0); | 333 prefs->SetInteger(prefs::kShutdownNumProcessesSlow, 0); |
| 329 | 334 |
| 335 UMA_HISTOGRAM_ENUMERATION("Shutdown.ShutdownType", type, kNumShutdownTypes); | |
| 336 | |
| 330 // Read and delete the file on the file thread. | 337 // Read and delete the file on the file thread. |
| 331 BrowserThread::PostTask( | 338 BrowserThread::PostTask( |
| 332 BrowserThread::FILE, FROM_HERE, | 339 BrowserThread::FILE, FROM_HERE, |
| 333 base::Bind(&ReadLastShutdownFile, type, num_procs, num_procs_slow)); | 340 base::Bind(&ReadLastShutdownFile, type, num_procs, num_procs_slow)); |
| 334 } | 341 } |
| 335 | 342 |
| 336 void SetTryingToQuit(bool quitting) { | 343 void SetTryingToQuit(bool quitting) { |
| 337 g_trying_to_quit = quitting; | 344 g_trying_to_quit = quitting; |
| 338 | 345 |
| 339 if (quitting) | 346 if (quitting) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 366 base::trace_event::TraceConfig trace_config( | 373 base::trace_event::TraceConfig trace_config( |
| 367 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); | 374 command_line.GetSwitchValueASCII(switches::kTraceShutdown), ""); |
| 368 content::TracingController::GetInstance()->StartTracing( | 375 content::TracingController::GetInstance()->StartTracing( |
| 369 trace_config, | 376 trace_config, |
| 370 content::TracingController::StartTracingDoneCallback()); | 377 content::TracingController::StartTracingDoneCallback()); |
| 371 } | 378 } |
| 372 TRACE_EVENT0("shutdown", "StartShutdownTracing"); | 379 TRACE_EVENT0("shutdown", "StartShutdownTracing"); |
| 373 } | 380 } |
| 374 | 381 |
| 375 } // namespace browser_shutdown | 382 } // namespace browser_shutdown |
| OLD | NEW |