| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/chrome/browser/application_context_impl.h" | 5 #include "ios/chrome/browser/application_context_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Tell the metrics service that the application resumes. | 78 // Tell the metrics service that the application resumes. |
| 79 metrics::MetricsService* metrics_service = GetMetricsService(); | 79 metrics::MetricsService* metrics_service = GetMetricsService(); |
| 80 if (metrics_service && local_state) { | 80 if (metrics_service && local_state) { |
| 81 metrics_service->OnAppEnterForeground(); | 81 metrics_service->OnAppEnterForeground(); |
| 82 local_state->CommitPendingWrite(); | 82 local_state->CommitPendingWrite(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 variations::VariationsService* variations_service = GetVariationsService(); | 85 variations::VariationsService* variations_service = GetVariationsService(); |
| 86 if (variations_service) | 86 if (variations_service) |
| 87 variations_service->OnAppEnterForeground(); | 87 variations_service->OnAppEnterForeground(); |
| 88 | |
| 89 std::vector<ios::ChromeBrowserState*> loaded_browser_state = | |
| 90 GetChromeBrowserStateManager()->GetLoadedBrowserStates(); | |
| 91 for (ios::ChromeBrowserState* browser_state : loaded_browser_state) { | |
| 92 browser_state->SetExitType(ios::ChromeBrowserState::EXIT_CRASHED); | |
| 93 } | |
| 94 } | 88 } |
| 95 | 89 |
| 96 void ApplicationContextImpl::OnAppEnterBackground() { | 90 void ApplicationContextImpl::OnAppEnterBackground() { |
| 97 DCHECK(thread_checker_.CalledOnValidThread()); | 91 DCHECK(thread_checker_.CalledOnValidThread()); |
| 98 // Mark all the ChromeBrowserStates as clean and persist history. | 92 // Mark all the ChromeBrowserStates as clean and persist history. |
| 99 std::vector<ios::ChromeBrowserState*> loaded_browser_state = | 93 std::vector<ios::ChromeBrowserState*> loaded_browser_state = |
| 100 GetChromeBrowserStateManager()->GetLoadedBrowserStates(); | 94 GetChromeBrowserStateManager()->GetLoadedBrowserStates(); |
| 101 for (ios::ChromeBrowserState* browser_state : loaded_browser_state) { | 95 for (ios::ChromeBrowserState* browser_state : loaded_browser_state) { |
| 102 if (history::HistoryService* history_service = | 96 if (history::HistoryService* history_service = |
| 103 ios::HistoryServiceFactory::GetForBrowserStateIfExists( | 97 ios::HistoryServiceFactory::GetForBrowserStateIfExists( |
| 104 browser_state, ServiceAccessType::EXPLICIT_ACCESS)) { | 98 browser_state, ServiceAccessType::EXPLICIT_ACCESS)) { |
| 105 history_service->HandleBackgrounding(); | 99 history_service->HandleBackgrounding(); |
| 106 } | 100 } |
| 107 | 101 |
| 108 browser_state->SetExitType(ios::ChromeBrowserState::EXIT_NORMAL); | |
| 109 PrefService* browser_state_prefs = browser_state->GetPrefs(); | 102 PrefService* browser_state_prefs = browser_state->GetPrefs(); |
| 110 if (browser_state_prefs) | 103 if (browser_state_prefs) |
| 111 browser_state_prefs->CommitPendingWrite(); | 104 browser_state_prefs->CommitPendingWrite(); |
| 112 } | 105 } |
| 113 | 106 |
| 114 PrefService* local_state = GetLocalState(); | 107 PrefService* local_state = GetLocalState(); |
| 115 local_state->SetBoolean(prefs::kLastSessionExitedCleanly, true); | 108 local_state->SetBoolean(prefs::kLastSessionExitedCleanly, true); |
| 116 | 109 |
| 117 // Tell the metrics service it was cleanly shutdown. | 110 // Tell the metrics service it was cleanly shutdown. |
| 118 metrics::MetricsService* metrics_service = GetMetricsService(); | 111 metrics::MetricsService* metrics_service = GetMetricsService(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 std::max(std::min(max_per_proxy, 99), | 200 std::max(std::min(max_per_proxy, 99), |
| 208 net::ClientSocketPoolManager::max_sockets_per_group( | 201 net::ClientSocketPoolManager::max_sockets_per_group( |
| 209 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); | 202 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); |
| 210 | 203 |
| 211 // Register the shutdown state before anything changes it. | 204 // Register the shutdown state before anything changes it. |
| 212 if (local_state_->HasPrefPath(prefs::kLastSessionExitedCleanly)) { | 205 if (local_state_->HasPrefPath(prefs::kLastSessionExitedCleanly)) { |
| 213 was_last_shutdown_clean_ = | 206 was_last_shutdown_clean_ = |
| 214 local_state_->GetBoolean(prefs::kLastSessionExitedCleanly); | 207 local_state_->GetBoolean(prefs::kLastSessionExitedCleanly); |
| 215 } | 208 } |
| 216 } | 209 } |
| OLD | NEW |